babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @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
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * 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".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * 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"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * 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)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * 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
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. 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;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. 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;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * 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"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * 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".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * 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"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * 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".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** 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 */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** 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 */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** 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 */
  4100. static readonly GEQUAL: number;
  4101. /** 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 */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * 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.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. 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;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** 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 */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * 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.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. 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;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. 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;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. 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;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. 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);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * 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;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * 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).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * 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).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * 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.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * 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.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * 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.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * 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.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * 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.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * 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).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * 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).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * 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.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * 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.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * 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.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * 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.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * 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.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * 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).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * 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).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * 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.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * 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.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * 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.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * 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.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * 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.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * 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.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * 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).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * 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).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * 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.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * 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.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * 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.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * 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.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * 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)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @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.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * 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.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * 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
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @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
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @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
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /**
  11559. * An event triggered when the manager is disposed.
  11560. */
  11561. onDisposeObservable: Observable<SpriteManager>;
  11562. private _onDisposeObserver;
  11563. /**
  11564. * Callback called when the manager is disposed
  11565. */
  11566. onDispose: () => void;
  11567. private _capacity;
  11568. private _spriteTexture;
  11569. private _epsilon;
  11570. private _scene;
  11571. private _vertexData;
  11572. private _buffer;
  11573. private _vertexBuffers;
  11574. private _indexBuffer;
  11575. private _effectBase;
  11576. private _effectFog;
  11577. /**
  11578. * Gets or sets the spritesheet texture
  11579. */
  11580. texture: Texture;
  11581. /**
  11582. * Creates a new sprite manager
  11583. * @param name defines the manager's name
  11584. * @param imgUrl defines the sprite sheet url
  11585. * @param capacity defines the maximum allowed number of sprites
  11586. * @param cellSize defines the size of a sprite cell
  11587. * @param scene defines the hosting scene
  11588. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11589. * @param samplingMode defines the smapling mode to use with spritesheet
  11590. */
  11591. constructor(
  11592. /** defines the manager's name */
  11593. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11594. private _appendSpriteVertex;
  11595. /**
  11596. * Intersects the sprites with a ray
  11597. * @param ray defines the ray to intersect with
  11598. * @param camera defines the current active camera
  11599. * @param predicate defines a predicate used to select candidate sprites
  11600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11601. * @returns null if no hit or a PickingInfo
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Render all child sprites
  11606. */
  11607. render(): void;
  11608. /**
  11609. * Release associated resources
  11610. */
  11611. dispose(): void;
  11612. }
  11613. }
  11614. declare module "babylonjs/Sprites/sprite" {
  11615. import { Vector3 } from "babylonjs/Maths/math.vector";
  11616. import { Nullable } from "babylonjs/types";
  11617. import { ActionManager } from "babylonjs/Actions/actionManager";
  11618. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11619. import { Color4 } from "babylonjs/Maths/math.color";
  11620. /**
  11621. * Class used to represent a sprite
  11622. * @see http://doc.babylonjs.com/babylon101/sprites
  11623. */
  11624. export class Sprite {
  11625. /** defines the name */
  11626. name: string;
  11627. /** Gets or sets the current world position */
  11628. position: Vector3;
  11629. /** Gets or sets the main color */
  11630. color: Color4;
  11631. /** Gets or sets the width */
  11632. width: number;
  11633. /** Gets or sets the height */
  11634. height: number;
  11635. /** Gets or sets rotation angle */
  11636. angle: number;
  11637. /** Gets or sets the cell index in the sprite sheet */
  11638. cellIndex: number;
  11639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11640. invertU: number;
  11641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11642. invertV: number;
  11643. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11644. disposeWhenFinishedAnimating: boolean;
  11645. /** Gets the list of attached animations */
  11646. animations: Animation[];
  11647. /** Gets or sets a boolean indicating if the sprite can be picked */
  11648. isPickable: boolean;
  11649. /**
  11650. * Gets or sets the associated action manager
  11651. */
  11652. actionManager: Nullable<ActionManager>;
  11653. private _animationStarted;
  11654. private _loopAnimation;
  11655. private _fromIndex;
  11656. private _toIndex;
  11657. private _delay;
  11658. private _direction;
  11659. private _manager;
  11660. private _time;
  11661. private _onAnimationEnd;
  11662. /**
  11663. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11664. */
  11665. isVisible: boolean;
  11666. /**
  11667. * Gets or sets the sprite size
  11668. */
  11669. size: number;
  11670. /**
  11671. * Creates a new Sprite
  11672. * @param name defines the name
  11673. * @param manager defines the manager
  11674. */
  11675. constructor(
  11676. /** defines the name */
  11677. name: string, manager: ISpriteManager);
  11678. /**
  11679. * Starts an animation
  11680. * @param from defines the initial key
  11681. * @param to defines the end key
  11682. * @param loop defines if the animation must loop
  11683. * @param delay defines the start delay (in ms)
  11684. * @param onAnimationEnd defines a callback to call when animation ends
  11685. */
  11686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11687. /** Stops current animation (if any) */
  11688. stopAnimation(): void;
  11689. /** @hidden */
  11690. _animate(deltaTime: number): void;
  11691. /** Release associated resources */
  11692. dispose(): void;
  11693. }
  11694. }
  11695. declare module "babylonjs/Collisions/pickingInfo" {
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { Ray } from "babylonjs/Culling/ray";
  11701. /**
  11702. * Information about the result of picking within a scene
  11703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11704. */
  11705. export class PickingInfo {
  11706. /** @hidden */
  11707. _pickingUnavailable: boolean;
  11708. /**
  11709. * If the pick collided with an object
  11710. */
  11711. hit: boolean;
  11712. /**
  11713. * Distance away where the pick collided
  11714. */
  11715. distance: number;
  11716. /**
  11717. * The location of pick collision
  11718. */
  11719. pickedPoint: Nullable<Vector3>;
  11720. /**
  11721. * The mesh corresponding the the pick collision
  11722. */
  11723. pickedMesh: Nullable<AbstractMesh>;
  11724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11725. bu: number;
  11726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11727. bv: number;
  11728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11729. faceId: number;
  11730. /** Id of the the submesh that was picked */
  11731. subMeshId: number;
  11732. /** If a sprite was picked, this will be the sprite the pick collided with */
  11733. pickedSprite: Nullable<Sprite>;
  11734. /**
  11735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11736. */
  11737. originMesh: Nullable<AbstractMesh>;
  11738. /**
  11739. * The ray that was used to perform the picking.
  11740. */
  11741. ray: Nullable<Ray>;
  11742. /**
  11743. * Gets the normal correspodning to the face the pick collided with
  11744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11746. * @returns The normal correspodning to the face the pick collided with
  11747. */
  11748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11749. /**
  11750. * Gets the texture coordinates of where the pick occured
  11751. * @returns the vector containing the coordnates of the texture
  11752. */
  11753. getTextureCoordinates(): Nullable<Vector2>;
  11754. }
  11755. }
  11756. declare module "babylonjs/Events/pointerEvents" {
  11757. import { Nullable } from "babylonjs/types";
  11758. import { Vector2 } from "babylonjs/Maths/math.vector";
  11759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11760. import { Ray } from "babylonjs/Culling/ray";
  11761. /**
  11762. * Gather the list of pointer event types as constants.
  11763. */
  11764. export class PointerEventTypes {
  11765. /**
  11766. * 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.
  11767. */
  11768. static readonly POINTERDOWN: number;
  11769. /**
  11770. * The pointerup event is fired when a pointer is no longer active.
  11771. */
  11772. static readonly POINTERUP: number;
  11773. /**
  11774. * The pointermove event is fired when a pointer changes coordinates.
  11775. */
  11776. static readonly POINTERMOVE: number;
  11777. /**
  11778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11779. */
  11780. static readonly POINTERWHEEL: number;
  11781. /**
  11782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11783. */
  11784. static readonly POINTERPICK: number;
  11785. /**
  11786. * The pointertap event is fired when a the object has been touched and released without drag.
  11787. */
  11788. static readonly POINTERTAP: number;
  11789. /**
  11790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11791. */
  11792. static readonly POINTERDOUBLETAP: number;
  11793. }
  11794. /**
  11795. * Base class of pointer info types.
  11796. */
  11797. export class PointerInfoBase {
  11798. /**
  11799. * Defines the type of event (PointerEventTypes)
  11800. */
  11801. type: number;
  11802. /**
  11803. * Defines the related dom event
  11804. */
  11805. event: PointerEvent | MouseWheelEvent;
  11806. /**
  11807. * Instantiates the base class of pointers info.
  11808. * @param type Defines the type of event (PointerEventTypes)
  11809. * @param event Defines the related dom event
  11810. */
  11811. constructor(
  11812. /**
  11813. * Defines the type of event (PointerEventTypes)
  11814. */
  11815. type: number,
  11816. /**
  11817. * Defines the related dom event
  11818. */
  11819. event: PointerEvent | MouseWheelEvent);
  11820. }
  11821. /**
  11822. * This class is used to store pointer related info for the onPrePointerObservable event.
  11823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11824. */
  11825. export class PointerInfoPre extends PointerInfoBase {
  11826. /**
  11827. * Ray from a pointer if availible (eg. 6dof controller)
  11828. */
  11829. ray: Nullable<Ray>;
  11830. /**
  11831. * Defines the local position of the pointer on the canvas.
  11832. */
  11833. localPosition: Vector2;
  11834. /**
  11835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11836. */
  11837. skipOnPointerObservable: boolean;
  11838. /**
  11839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11840. * @param type Defines the type of event (PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param localX Defines the local x coordinates of the pointer when the event occured
  11843. * @param localY Defines the local y coordinates of the pointer when the event occured
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11846. }
  11847. /**
  11848. * This type contains all the data related to a pointer event in Babylon.js.
  11849. * 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.
  11850. */
  11851. export class PointerInfo extends PointerInfoBase {
  11852. /**
  11853. * Defines the picking info associated to the info (if any)\
  11854. */
  11855. pickInfo: Nullable<PickingInfo>;
  11856. /**
  11857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. * @param pickInfo Defines the picking info associated to the info (if any)\
  11861. */
  11862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11863. /**
  11864. * Defines the picking info associated to the info (if any)\
  11865. */
  11866. pickInfo: Nullable<PickingInfo>);
  11867. }
  11868. /**
  11869. * Data relating to a touch event on the screen.
  11870. */
  11871. export interface PointerTouch {
  11872. /**
  11873. * X coordinate of touch.
  11874. */
  11875. x: number;
  11876. /**
  11877. * Y coordinate of touch.
  11878. */
  11879. y: number;
  11880. /**
  11881. * Id of touch. Unique for each finger.
  11882. */
  11883. pointerId: number;
  11884. /**
  11885. * Event type passed from DOM.
  11886. */
  11887. type: any;
  11888. }
  11889. }
  11890. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11891. import { Observable } from "babylonjs/Misc/observable";
  11892. import { Nullable } from "babylonjs/types";
  11893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11971. import { Nullable } from "babylonjs/types";
  11972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12031. import { Nullable } from "babylonjs/types";
  12032. /**
  12033. * Default Inputs manager for the FreeCamera.
  12034. * It groups all the default supported inputs for ease of use.
  12035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12036. */
  12037. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12038. /**
  12039. * @hidden
  12040. */
  12041. _mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. /**
  12069. * Remove all attached input methods from a camera
  12070. */
  12071. clear(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Cameras/freeCamera" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12077. import { Scene } from "babylonjs/scene";
  12078. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12079. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */
  12145. _localDirection: Vector3;
  12146. /** @hidden */
  12147. _transformedDirection: Vector3;
  12148. /**
  12149. * Instantiates a Free Camera.
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. * @param name Define the name of the camera in the scene
  12154. * @param position Define the start position of the camera in the scene
  12155. * @param scene Define the scene the camera belongs to
  12156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12157. */
  12158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12159. /**
  12160. * Attached controls to the current camera.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the camera.
  12167. * The camera will stop reacting to inputs.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: HTMLElement): void;
  12171. private _collisionMask;
  12172. /**
  12173. * Define a collision mask to limit the list of object the camera can collide with
  12174. */
  12175. collisionMask: number;
  12176. /** @hidden */
  12177. _collideWithWorld(displacement: Vector3): void;
  12178. private _onCollisionPositionChange;
  12179. /** @hidden */
  12180. _checkInputs(): void;
  12181. /** @hidden */
  12182. _decideIfNeedsToMove(): boolean;
  12183. /** @hidden */
  12184. _updatePosition(): void;
  12185. /**
  12186. * Destroy the camera and release the current resources hold by it.
  12187. */
  12188. dispose(): void;
  12189. /**
  12190. * Gets the current object class name.
  12191. * @return the class name
  12192. */
  12193. getClassName(): string;
  12194. }
  12195. }
  12196. declare module "babylonjs/Gamepads/gamepad" {
  12197. import { Observable } from "babylonjs/Misc/observable";
  12198. /**
  12199. * Represents a gamepad control stick position
  12200. */
  12201. export class StickValues {
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number;
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number;
  12210. /**
  12211. * Initializes the gamepad x and y control stick values
  12212. * @param x The x component of the gamepad control stick value
  12213. * @param y The y component of the gamepad control stick value
  12214. */
  12215. constructor(
  12216. /**
  12217. * The x component of the control stick
  12218. */
  12219. x: number,
  12220. /**
  12221. * The y component of the control stick
  12222. */
  12223. y: number);
  12224. }
  12225. /**
  12226. * An interface which manages callbacks for gamepad button changes
  12227. */
  12228. export interface GamepadButtonChanges {
  12229. /**
  12230. * Called when a gamepad has been changed
  12231. */
  12232. changed: boolean;
  12233. /**
  12234. * Called when a gamepad press event has been triggered
  12235. */
  12236. pressChanged: boolean;
  12237. /**
  12238. * Called when a touch event has been triggered
  12239. */
  12240. touchChanged: boolean;
  12241. /**
  12242. * Called when a value has changed
  12243. */
  12244. valueChanged: boolean;
  12245. }
  12246. /**
  12247. * Represents a gamepad
  12248. */
  12249. export class Gamepad {
  12250. /**
  12251. * The id of the gamepad
  12252. */
  12253. id: string;
  12254. /**
  12255. * The index of the gamepad
  12256. */
  12257. index: number;
  12258. /**
  12259. * The browser gamepad
  12260. */
  12261. browserGamepad: any;
  12262. /**
  12263. * Specifies what type of gamepad this represents
  12264. */
  12265. type: number;
  12266. private _leftStick;
  12267. private _rightStick;
  12268. /** @hidden */
  12269. _isConnected: boolean;
  12270. private _leftStickAxisX;
  12271. private _leftStickAxisY;
  12272. private _rightStickAxisX;
  12273. private _rightStickAxisY;
  12274. /**
  12275. * Triggered when the left control stick has been changed
  12276. */
  12277. private _onleftstickchanged;
  12278. /**
  12279. * Triggered when the right control stick has been changed
  12280. */
  12281. private _onrightstickchanged;
  12282. /**
  12283. * Represents a gamepad controller
  12284. */
  12285. static GAMEPAD: number;
  12286. /**
  12287. * Represents a generic controller
  12288. */
  12289. static GENERIC: number;
  12290. /**
  12291. * Represents an XBox controller
  12292. */
  12293. static XBOX: number;
  12294. /**
  12295. * Represents a pose-enabled controller
  12296. */
  12297. static POSE_ENABLED: number;
  12298. /**
  12299. * Specifies whether the left control stick should be Y-inverted
  12300. */
  12301. protected _invertLeftStickY: boolean;
  12302. /**
  12303. * Specifies if the gamepad has been connected
  12304. */
  12305. readonly isConnected: boolean;
  12306. /**
  12307. * Initializes the gamepad
  12308. * @param id The id of the gamepad
  12309. * @param index The index of the gamepad
  12310. * @param browserGamepad The browser gamepad
  12311. * @param leftStickX The x component of the left joystick
  12312. * @param leftStickY The y component of the left joystick
  12313. * @param rightStickX The x component of the right joystick
  12314. * @param rightStickY The y component of the right joystick
  12315. */
  12316. constructor(
  12317. /**
  12318. * The id of the gamepad
  12319. */
  12320. id: string,
  12321. /**
  12322. * The index of the gamepad
  12323. */
  12324. index: number,
  12325. /**
  12326. * The browser gamepad
  12327. */
  12328. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12329. /**
  12330. * Callback triggered when the left joystick has changed
  12331. * @param callback
  12332. */
  12333. onleftstickchanged(callback: (values: StickValues) => void): void;
  12334. /**
  12335. * Callback triggered when the right joystick has changed
  12336. * @param callback
  12337. */
  12338. onrightstickchanged(callback: (values: StickValues) => void): void;
  12339. /**
  12340. * Gets the left joystick
  12341. */
  12342. /**
  12343. * Sets the left joystick values
  12344. */
  12345. leftStick: StickValues;
  12346. /**
  12347. * Gets the right joystick
  12348. */
  12349. /**
  12350. * Sets the right joystick value
  12351. */
  12352. rightStick: StickValues;
  12353. /**
  12354. * Updates the gamepad joystick positions
  12355. */
  12356. update(): void;
  12357. /**
  12358. * Disposes the gamepad
  12359. */
  12360. dispose(): void;
  12361. }
  12362. /**
  12363. * Represents a generic gamepad
  12364. */
  12365. export class GenericPad extends Gamepad {
  12366. private _buttons;
  12367. private _onbuttondown;
  12368. private _onbuttonup;
  12369. /**
  12370. * Observable triggered when a button has been pressed
  12371. */
  12372. onButtonDownObservable: Observable<number>;
  12373. /**
  12374. * Observable triggered when a button has been released
  12375. */
  12376. onButtonUpObservable: Observable<number>;
  12377. /**
  12378. * Callback triggered when a button has been pressed
  12379. * @param callback Called when a button has been pressed
  12380. */
  12381. onbuttondown(callback: (buttonPressed: number) => void): void;
  12382. /**
  12383. * Callback triggered when a button has been released
  12384. * @param callback Called when a button has been released
  12385. */
  12386. onbuttonup(callback: (buttonReleased: number) => void): void;
  12387. /**
  12388. * Initializes the generic gamepad
  12389. * @param id The id of the generic gamepad
  12390. * @param index The index of the generic gamepad
  12391. * @param browserGamepad The browser gamepad
  12392. */
  12393. constructor(id: string, index: number, browserGamepad: any);
  12394. private _setButtonValue;
  12395. /**
  12396. * Updates the generic gamepad
  12397. */
  12398. update(): void;
  12399. /**
  12400. * Disposes the generic gamepad
  12401. */
  12402. dispose(): void;
  12403. }
  12404. }
  12405. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12406. import { Nullable } from "babylonjs/types";
  12407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12408. import { Scene } from "babylonjs/scene";
  12409. module "babylonjs/Engines/engine" {
  12410. interface Engine {
  12411. /**
  12412. * Creates a raw texture
  12413. * @param data defines the data to store in the texture
  12414. * @param width defines the width of the texture
  12415. * @param height defines the height of the texture
  12416. * @param format defines the format of the data
  12417. * @param generateMipMaps defines if the engine should generate the mip levels
  12418. * @param invertY defines if data must be stored with Y axis inverted
  12419. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12420. * @param compression defines the compression used (null by default)
  12421. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12422. * @returns the raw texture inside an InternalTexture
  12423. */
  12424. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12425. /**
  12426. * Update a raw texture
  12427. * @param texture defines the texture to update
  12428. * @param data defines the data to store in the texture
  12429. * @param format defines the format of the data
  12430. * @param invertY defines if data must be stored with Y axis inverted
  12431. */
  12432. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12433. /**
  12434. * Update a raw texture
  12435. * @param texture defines the texture to update
  12436. * @param data defines the data to store in the texture
  12437. * @param format defines the format of the data
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @param compression defines the compression used (null by default)
  12440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12441. */
  12442. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12443. /**
  12444. * Creates a new raw cube texture
  12445. * @param data defines the array of data to use to create each face
  12446. * @param size defines the size of the textures
  12447. * @param format defines the format of the data
  12448. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12449. * @param generateMipMaps defines if the engine should generate the mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compression used (null by default)
  12453. * @returns the cube texture as an InternalTexture
  12454. */
  12455. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12456. /**
  12457. * Update a raw cube texture
  12458. * @param texture defines the texture to udpdate
  12459. * @param data defines the data to store
  12460. * @param format defines the data format
  12461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw cube texture
  12467. * @param texture defines the texture to udpdate
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12471. * @param invertY defines if data must be stored with Y axis inverted
  12472. * @param compression defines the compression used (null by default)
  12473. */
  12474. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12475. /**
  12476. * Update a raw cube texture
  12477. * @param texture defines the texture to udpdate
  12478. * @param data defines the data to store
  12479. * @param format defines the data format
  12480. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12481. * @param invertY defines if data must be stored with Y axis inverted
  12482. * @param compression defines the compression used (null by default)
  12483. * @param level defines which level of the texture to update
  12484. */
  12485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12486. /**
  12487. * Creates a new raw cube texture from a specified url
  12488. * @param url defines the url where the data is located
  12489. * @param scene defines the current scene
  12490. * @param size defines the size of the textures
  12491. * @param format defines the format of the data
  12492. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12493. * @param noMipmap defines if the engine should avoid generating the mip levels
  12494. * @param callback defines a callback used to extract texture data from loaded data
  12495. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12496. * @param onLoad defines a callback called when texture is loaded
  12497. * @param onError defines a callback called if there is an error
  12498. * @returns the cube texture as an InternalTexture
  12499. */
  12500. 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;
  12501. /**
  12502. * Creates a new raw cube texture from a specified url
  12503. * @param url defines the url where the data is located
  12504. * @param scene defines the current scene
  12505. * @param size defines the size of the textures
  12506. * @param format defines the format of the data
  12507. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12508. * @param noMipmap defines if the engine should avoid generating the mip levels
  12509. * @param callback defines a callback used to extract texture data from loaded data
  12510. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12511. * @param onLoad defines a callback called when texture is loaded
  12512. * @param onError defines a callback called if there is an error
  12513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12514. * @param invertY defines if data must be stored with Y axis inverted
  12515. * @returns the cube texture as an InternalTexture
  12516. */
  12517. 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;
  12518. /**
  12519. * Creates a new raw 3D texture
  12520. * @param data defines the data used to create the texture
  12521. * @param width defines the width of the texture
  12522. * @param height defines the height of the texture
  12523. * @param depth defines the depth of the texture
  12524. * @param format defines the format of the texture
  12525. * @param generateMipMaps defines if the engine must generate mip levels
  12526. * @param invertY defines if data must be stored with Y axis inverted
  12527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12528. * @param compression defines the compressed used (can be null)
  12529. * @param textureType defines the compressed used (can be null)
  12530. * @returns a new raw 3D texture (stored in an InternalTexture)
  12531. */
  12532. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12533. /**
  12534. * Update a raw 3D texture
  12535. * @param texture defines the texture to update
  12536. * @param data defines the data to store
  12537. * @param format defines the data format
  12538. * @param invertY defines if data must be stored with Y axis inverted
  12539. */
  12540. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12541. /**
  12542. * Update a raw 3D texture
  12543. * @param texture defines the texture to update
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param invertY defines if data must be stored with Y axis inverted
  12547. * @param compression defines the used compression (can be null)
  12548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12549. */
  12550. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12551. }
  12552. }
  12553. }
  12554. declare module "babylonjs/Materials/Textures/rawTexture" {
  12555. import { Scene } from "babylonjs/scene";
  12556. import { Texture } from "babylonjs/Materials/Textures/texture";
  12557. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12558. /**
  12559. * Raw texture can help creating a texture directly from an array of data.
  12560. * This can be super useful if you either get the data from an uncompressed source or
  12561. * if you wish to create your texture pixel by pixel.
  12562. */
  12563. export class RawTexture extends Texture {
  12564. /**
  12565. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12566. */
  12567. format: number;
  12568. private _engine;
  12569. /**
  12570. * Instantiates a new RawTexture.
  12571. * Raw texture can help creating a texture directly from an array of data.
  12572. * This can be super useful if you either get the data from an uncompressed source or
  12573. * if you wish to create your texture pixel by pixel.
  12574. * @param data define the array of data to use to create the texture
  12575. * @param width define the width of the texture
  12576. * @param height define the height of the texture
  12577. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12578. * @param scene define the scene the texture belongs to
  12579. * @param generateMipMaps define whether mip maps should be generated or not
  12580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12583. */
  12584. constructor(data: ArrayBufferView, width: number, height: number,
  12585. /**
  12586. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12587. */
  12588. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12589. /**
  12590. * Updates the texture underlying data.
  12591. * @param data Define the new data of the texture
  12592. */
  12593. update(data: ArrayBufferView): void;
  12594. /**
  12595. * Creates a luminance texture from some data.
  12596. * @param data Define the texture data
  12597. * @param width Define the width of the texture
  12598. * @param height Define the height of the texture
  12599. * @param scene Define the scene the texture belongs to
  12600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12603. * @returns the luminance texture
  12604. */
  12605. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12606. /**
  12607. * Creates a luminance alpha texture from some data.
  12608. * @param data Define the texture data
  12609. * @param width Define the width of the texture
  12610. * @param height Define the height of the texture
  12611. * @param scene Define the scene the texture belongs to
  12612. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12613. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12614. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12615. * @returns the luminance alpha texture
  12616. */
  12617. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12618. /**
  12619. * Creates an alpha texture from some data.
  12620. * @param data Define the texture data
  12621. * @param width Define the width of the texture
  12622. * @param height Define the height of the texture
  12623. * @param scene Define the scene the texture belongs to
  12624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12627. * @returns the alpha texture
  12628. */
  12629. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12630. /**
  12631. * Creates a RGB texture from some data.
  12632. * @param data Define the texture data
  12633. * @param width Define the width of the texture
  12634. * @param height Define the height of the texture
  12635. * @param scene Define the scene the texture belongs to
  12636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12640. * @returns the RGB alpha texture
  12641. */
  12642. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12643. /**
  12644. * Creates a RGBA texture from some data.
  12645. * @param data Define the texture data
  12646. * @param width Define the width of the texture
  12647. * @param height Define the height of the texture
  12648. * @param scene Define the scene the texture belongs to
  12649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12653. * @returns the RGBA texture
  12654. */
  12655. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12656. /**
  12657. * Creates a R texture from some data.
  12658. * @param data Define the texture data
  12659. * @param width Define the width of the texture
  12660. * @param height Define the height of the texture
  12661. * @param scene Define the scene the texture belongs to
  12662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12666. * @returns the R texture
  12667. */
  12668. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12669. }
  12670. }
  12671. declare module "babylonjs/Maths/math.size" {
  12672. /**
  12673. * Interface for the size containing width and height
  12674. */
  12675. export interface ISize {
  12676. /**
  12677. * Width
  12678. */
  12679. width: number;
  12680. /**
  12681. * Heighht
  12682. */
  12683. height: number;
  12684. }
  12685. /**
  12686. * Size containing widht and height
  12687. */
  12688. export class Size implements ISize {
  12689. /**
  12690. * Width
  12691. */
  12692. width: number;
  12693. /**
  12694. * Height
  12695. */
  12696. height: number;
  12697. /**
  12698. * Creates a Size object from the given width and height (floats).
  12699. * @param width width of the new size
  12700. * @param height height of the new size
  12701. */
  12702. constructor(width: number, height: number);
  12703. /**
  12704. * Returns a string with the Size width and height
  12705. * @returns a string with the Size width and height
  12706. */
  12707. toString(): string;
  12708. /**
  12709. * "Size"
  12710. * @returns the string "Size"
  12711. */
  12712. getClassName(): string;
  12713. /**
  12714. * Returns the Size hash code.
  12715. * @returns a hash code for a unique width and height
  12716. */
  12717. getHashCode(): number;
  12718. /**
  12719. * Updates the current size from the given one.
  12720. * @param src the given size
  12721. */
  12722. copyFrom(src: Size): void;
  12723. /**
  12724. * Updates in place the current Size from the given floats.
  12725. * @param width width of the new size
  12726. * @param height height of the new size
  12727. * @returns the updated Size.
  12728. */
  12729. copyFromFloats(width: number, height: number): Size;
  12730. /**
  12731. * Updates in place the current Size from the given floats.
  12732. * @param width width to set
  12733. * @param height height to set
  12734. * @returns the updated Size.
  12735. */
  12736. set(width: number, height: number): Size;
  12737. /**
  12738. * Multiplies the width and height by numbers
  12739. * @param w factor to multiple the width by
  12740. * @param h factor to multiple the height by
  12741. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12742. */
  12743. multiplyByFloats(w: number, h: number): Size;
  12744. /**
  12745. * Clones the size
  12746. * @returns a new Size copied from the given one.
  12747. */
  12748. clone(): Size;
  12749. /**
  12750. * True if the current Size and the given one width and height are strictly equal.
  12751. * @param other the other size to compare against
  12752. * @returns True if the current Size and the given one width and height are strictly equal.
  12753. */
  12754. equals(other: Size): boolean;
  12755. /**
  12756. * The surface of the Size : width * height (float).
  12757. */
  12758. readonly surface: number;
  12759. /**
  12760. * Create a new size of zero
  12761. * @returns a new Size set to (0.0, 0.0)
  12762. */
  12763. static Zero(): Size;
  12764. /**
  12765. * Sums the width and height of two sizes
  12766. * @param otherSize size to add to this size
  12767. * @returns a new Size set as the addition result of the current Size and the given one.
  12768. */
  12769. add(otherSize: Size): Size;
  12770. /**
  12771. * Subtracts the width and height of two
  12772. * @param otherSize size to subtract to this size
  12773. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12774. */
  12775. subtract(otherSize: Size): Size;
  12776. /**
  12777. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12778. * @param start starting size to lerp between
  12779. * @param end end size to lerp between
  12780. * @param amount amount to lerp between the start and end values
  12781. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12782. */
  12783. static Lerp(start: Size, end: Size, amount: number): Size;
  12784. }
  12785. }
  12786. declare module "babylonjs/Animations/runtimeAnimation" {
  12787. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12788. import { Animatable } from "babylonjs/Animations/animatable";
  12789. import { Scene } from "babylonjs/scene";
  12790. /**
  12791. * Defines a runtime animation
  12792. */
  12793. export class RuntimeAnimation {
  12794. private _events;
  12795. /**
  12796. * The current frame of the runtime animation
  12797. */
  12798. private _currentFrame;
  12799. /**
  12800. * The animation used by the runtime animation
  12801. */
  12802. private _animation;
  12803. /**
  12804. * The target of the runtime animation
  12805. */
  12806. private _target;
  12807. /**
  12808. * The initiating animatable
  12809. */
  12810. private _host;
  12811. /**
  12812. * The original value of the runtime animation
  12813. */
  12814. private _originalValue;
  12815. /**
  12816. * The original blend value of the runtime animation
  12817. */
  12818. private _originalBlendValue;
  12819. /**
  12820. * The offsets cache of the runtime animation
  12821. */
  12822. private _offsetsCache;
  12823. /**
  12824. * The high limits cache of the runtime animation
  12825. */
  12826. private _highLimitsCache;
  12827. /**
  12828. * Specifies if the runtime animation has been stopped
  12829. */
  12830. private _stopped;
  12831. /**
  12832. * The blending factor of the runtime animation
  12833. */
  12834. private _blendingFactor;
  12835. /**
  12836. * The BabylonJS scene
  12837. */
  12838. private _scene;
  12839. /**
  12840. * The current value of the runtime animation
  12841. */
  12842. private _currentValue;
  12843. /** @hidden */
  12844. _animationState: _IAnimationState;
  12845. /**
  12846. * The active target of the runtime animation
  12847. */
  12848. private _activeTargets;
  12849. private _currentActiveTarget;
  12850. private _directTarget;
  12851. /**
  12852. * The target path of the runtime animation
  12853. */
  12854. private _targetPath;
  12855. /**
  12856. * The weight of the runtime animation
  12857. */
  12858. private _weight;
  12859. /**
  12860. * The ratio offset of the runtime animation
  12861. */
  12862. private _ratioOffset;
  12863. /**
  12864. * The previous delay of the runtime animation
  12865. */
  12866. private _previousDelay;
  12867. /**
  12868. * The previous ratio of the runtime animation
  12869. */
  12870. private _previousRatio;
  12871. private _enableBlending;
  12872. private _keys;
  12873. private _minFrame;
  12874. private _maxFrame;
  12875. private _minValue;
  12876. private _maxValue;
  12877. private _targetIsArray;
  12878. /**
  12879. * Gets the current frame of the runtime animation
  12880. */
  12881. readonly currentFrame: number;
  12882. /**
  12883. * Gets the weight of the runtime animation
  12884. */
  12885. readonly weight: number;
  12886. /**
  12887. * Gets the current value of the runtime animation
  12888. */
  12889. readonly currentValue: any;
  12890. /**
  12891. * Gets the target path of the runtime animation
  12892. */
  12893. readonly targetPath: string;
  12894. /**
  12895. * Gets the actual target of the runtime animation
  12896. */
  12897. readonly target: any;
  12898. /** @hidden */
  12899. _onLoop: () => void;
  12900. /**
  12901. * Create a new RuntimeAnimation object
  12902. * @param target defines the target of the animation
  12903. * @param animation defines the source animation object
  12904. * @param scene defines the hosting scene
  12905. * @param host defines the initiating Animatable
  12906. */
  12907. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12908. private _preparePath;
  12909. /**
  12910. * Gets the animation from the runtime animation
  12911. */
  12912. readonly animation: Animation;
  12913. /**
  12914. * Resets the runtime animation to the beginning
  12915. * @param restoreOriginal defines whether to restore the target property to the original value
  12916. */
  12917. reset(restoreOriginal?: boolean): void;
  12918. /**
  12919. * Specifies if the runtime animation is stopped
  12920. * @returns Boolean specifying if the runtime animation is stopped
  12921. */
  12922. isStopped(): boolean;
  12923. /**
  12924. * Disposes of the runtime animation
  12925. */
  12926. dispose(): void;
  12927. /**
  12928. * Apply the interpolated value to the target
  12929. * @param currentValue defines the value computed by the animation
  12930. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12931. */
  12932. setValue(currentValue: any, weight: number): void;
  12933. private _getOriginalValues;
  12934. private _setValue;
  12935. /**
  12936. * Gets the loop pmode of the runtime animation
  12937. * @returns Loop Mode
  12938. */
  12939. private _getCorrectLoopMode;
  12940. /**
  12941. * Move the current animation to a given frame
  12942. * @param frame defines the frame to move to
  12943. */
  12944. goToFrame(frame: number): void;
  12945. /**
  12946. * @hidden Internal use only
  12947. */
  12948. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12949. /**
  12950. * Execute the current animation
  12951. * @param delay defines the delay to add to the current frame
  12952. * @param from defines the lower bound of the animation range
  12953. * @param to defines the upper bound of the animation range
  12954. * @param loop defines if the current animation must loop
  12955. * @param speedRatio defines the current speed ratio
  12956. * @param weight defines the weight of the animation (default is -1 so no weight)
  12957. * @param onLoop optional callback called when animation loops
  12958. * @returns a boolean indicating if the animation is running
  12959. */
  12960. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12961. }
  12962. }
  12963. declare module "babylonjs/Animations/animatable" {
  12964. import { Animation } from "babylonjs/Animations/animation";
  12965. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12966. import { Nullable } from "babylonjs/types";
  12967. import { Observable } from "babylonjs/Misc/observable";
  12968. import { Scene } from "babylonjs/scene";
  12969. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12970. import { Node } from "babylonjs/node";
  12971. /**
  12972. * Class used to store an actual running animation
  12973. */
  12974. export class Animatable {
  12975. /** defines the target object */
  12976. target: any;
  12977. /** defines the starting frame number (default is 0) */
  12978. fromFrame: number;
  12979. /** defines the ending frame number (default is 100) */
  12980. toFrame: number;
  12981. /** defines if the animation must loop (default is false) */
  12982. loopAnimation: boolean;
  12983. /** defines a callback to call when animation ends if it is not looping */
  12984. onAnimationEnd?: (() => void) | null | undefined;
  12985. /** defines a callback to call when animation loops */
  12986. onAnimationLoop?: (() => void) | null | undefined;
  12987. private _localDelayOffset;
  12988. private _pausedDelay;
  12989. private _runtimeAnimations;
  12990. private _paused;
  12991. private _scene;
  12992. private _speedRatio;
  12993. private _weight;
  12994. private _syncRoot;
  12995. /**
  12996. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12997. * This will only apply for non looping animation (default is true)
  12998. */
  12999. disposeOnEnd: boolean;
  13000. /**
  13001. * Gets a boolean indicating if the animation has started
  13002. */
  13003. animationStarted: boolean;
  13004. /**
  13005. * Observer raised when the animation ends
  13006. */
  13007. onAnimationEndObservable: Observable<Animatable>;
  13008. /**
  13009. * Observer raised when the animation loops
  13010. */
  13011. onAnimationLoopObservable: Observable<Animatable>;
  13012. /**
  13013. * Gets the root Animatable used to synchronize and normalize animations
  13014. */
  13015. readonly syncRoot: Nullable<Animatable>;
  13016. /**
  13017. * Gets the current frame of the first RuntimeAnimation
  13018. * Used to synchronize Animatables
  13019. */
  13020. readonly masterFrame: number;
  13021. /**
  13022. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13023. */
  13024. weight: number;
  13025. /**
  13026. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13027. */
  13028. speedRatio: number;
  13029. /**
  13030. * Creates a new Animatable
  13031. * @param scene defines the hosting scene
  13032. * @param target defines the target object
  13033. * @param fromFrame defines the starting frame number (default is 0)
  13034. * @param toFrame defines the ending frame number (default is 100)
  13035. * @param loopAnimation defines if the animation must loop (default is false)
  13036. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13037. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13038. * @param animations defines a group of animation to add to the new Animatable
  13039. * @param onAnimationLoop defines a callback to call when animation loops
  13040. */
  13041. constructor(scene: Scene,
  13042. /** defines the target object */
  13043. target: any,
  13044. /** defines the starting frame number (default is 0) */
  13045. fromFrame?: number,
  13046. /** defines the ending frame number (default is 100) */
  13047. toFrame?: number,
  13048. /** defines if the animation must loop (default is false) */
  13049. loopAnimation?: boolean, speedRatio?: number,
  13050. /** defines a callback to call when animation ends if it is not looping */
  13051. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13052. /** defines a callback to call when animation loops */
  13053. onAnimationLoop?: (() => void) | null | undefined);
  13054. /**
  13055. * Synchronize and normalize current Animatable with a source Animatable
  13056. * This is useful when using animation weights and when animations are not of the same length
  13057. * @param root defines the root Animatable to synchronize with
  13058. * @returns the current Animatable
  13059. */
  13060. syncWith(root: Animatable): Animatable;
  13061. /**
  13062. * Gets the list of runtime animations
  13063. * @returns an array of RuntimeAnimation
  13064. */
  13065. getAnimations(): RuntimeAnimation[];
  13066. /**
  13067. * Adds more animations to the current animatable
  13068. * @param target defines the target of the animations
  13069. * @param animations defines the new animations to add
  13070. */
  13071. appendAnimations(target: any, animations: Animation[]): void;
  13072. /**
  13073. * Gets the source animation for a specific property
  13074. * @param property defines the propertyu to look for
  13075. * @returns null or the source animation for the given property
  13076. */
  13077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13078. /**
  13079. * Gets the runtime animation for a specific property
  13080. * @param property defines the propertyu to look for
  13081. * @returns null or the runtime animation for the given property
  13082. */
  13083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13084. /**
  13085. * Resets the animatable to its original state
  13086. */
  13087. reset(): void;
  13088. /**
  13089. * Allows the animatable to blend with current running animations
  13090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13091. * @param blendingSpeed defines the blending speed to use
  13092. */
  13093. enableBlending(blendingSpeed: number): void;
  13094. /**
  13095. * Disable animation blending
  13096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13097. */
  13098. disableBlending(): void;
  13099. /**
  13100. * Jump directly to a given frame
  13101. * @param frame defines the frame to jump to
  13102. */
  13103. goToFrame(frame: number): void;
  13104. /**
  13105. * Pause the animation
  13106. */
  13107. pause(): void;
  13108. /**
  13109. * Restart the animation
  13110. */
  13111. restart(): void;
  13112. private _raiseOnAnimationEnd;
  13113. /**
  13114. * Stop and delete the current animation
  13115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13116. * @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)
  13117. */
  13118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13119. /**
  13120. * Wait asynchronously for the animation to end
  13121. * @returns a promise which will be fullfilled when the animation ends
  13122. */
  13123. waitAsync(): Promise<Animatable>;
  13124. /** @hidden */
  13125. _animate(delay: number): boolean;
  13126. }
  13127. module "babylonjs/scene" {
  13128. interface Scene {
  13129. /** @hidden */
  13130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13131. /** @hidden */
  13132. _processLateAnimationBindingsForMatrices(holder: {
  13133. totalWeight: number;
  13134. animations: RuntimeAnimation[];
  13135. originalValue: Matrix;
  13136. }): any;
  13137. /** @hidden */
  13138. _processLateAnimationBindingsForQuaternions(holder: {
  13139. totalWeight: number;
  13140. animations: RuntimeAnimation[];
  13141. originalValue: Quaternion;
  13142. }, refQuaternion: Quaternion): Quaternion;
  13143. /** @hidden */
  13144. _processLateAnimationBindings(): void;
  13145. /**
  13146. * Will start the animation sequence of a given target
  13147. * @param target defines the target
  13148. * @param from defines from which frame should animation start
  13149. * @param to defines until which frame should animation run.
  13150. * @param weight defines the weight to apply to the animation (1.0 by default)
  13151. * @param loop defines if the animation loops
  13152. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13153. * @param onAnimationEnd defines the function to be executed when the animation ends
  13154. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13155. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13156. * @param onAnimationLoop defines the callback to call when an animation loops
  13157. * @returns the animatable object created for this animation
  13158. */
  13159. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13160. /**
  13161. * Will start the animation sequence of a given target
  13162. * @param target defines the target
  13163. * @param from defines from which frame should animation start
  13164. * @param to defines until which frame should animation run.
  13165. * @param loop defines if the animation loops
  13166. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13167. * @param onAnimationEnd defines the function to be executed when the animation ends
  13168. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13169. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13170. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13171. * @param onAnimationLoop defines the callback to call when an animation loops
  13172. * @returns the animatable object created for this animation
  13173. */
  13174. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13175. /**
  13176. * Will start the animation sequence of a given target and its hierarchy
  13177. * @param target defines the target
  13178. * @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.
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param loop defines if the animation loops
  13182. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13183. * @param onAnimationEnd defines the function to be executed when the animation ends
  13184. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13185. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13186. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the list of created animatables
  13189. */
  13190. 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[];
  13191. /**
  13192. * Begin a new animation on a given node
  13193. * @param target defines the target where the animation will take place
  13194. * @param animations defines the list of animations to start
  13195. * @param from defines the initial value
  13196. * @param to defines the final value
  13197. * @param loop defines if you want animation to loop (off by default)
  13198. * @param speedRatio defines the speed ratio to apply to all animations
  13199. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13200. * @param onAnimationLoop defines the callback to call when an animation loops
  13201. * @returns the list of created animatables
  13202. */
  13203. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13204. /**
  13205. * Begin a new animation on a given node and its hierarchy
  13206. * @param target defines the root node where the animation will take place
  13207. * @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.
  13208. * @param animations defines the list of animations to start
  13209. * @param from defines the initial value
  13210. * @param to defines the final value
  13211. * @param loop defines if you want animation to loop (off by default)
  13212. * @param speedRatio defines the speed ratio to apply to all animations
  13213. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13214. * @param onAnimationLoop defines the callback to call when an animation loops
  13215. * @returns the list of animatables created for all nodes
  13216. */
  13217. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13218. /**
  13219. * Gets the animatable associated with a specific target
  13220. * @param target defines the target of the animatable
  13221. * @returns the required animatable if found
  13222. */
  13223. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13224. /**
  13225. * Gets all animatables associated with a given target
  13226. * @param target defines the target to look animatables for
  13227. * @returns an array of Animatables
  13228. */
  13229. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13230. /**
  13231. * Stops and removes all animations that have been applied to the scene
  13232. */
  13233. stopAllAnimations(): void;
  13234. }
  13235. }
  13236. module "babylonjs/Bones/bone" {
  13237. interface Bone {
  13238. /**
  13239. * Copy an animation range from another bone
  13240. * @param source defines the source bone
  13241. * @param rangeName defines the range name to copy
  13242. * @param frameOffset defines the frame offset
  13243. * @param rescaleAsRequired defines if rescaling must be applied if required
  13244. * @param skelDimensionsRatio defines the scaling ratio
  13245. * @returns true if operation was successful
  13246. */
  13247. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13248. }
  13249. }
  13250. }
  13251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13252. /**
  13253. * Class used to override all child animations of a given target
  13254. */
  13255. export class AnimationPropertiesOverride {
  13256. /**
  13257. * Gets or sets a value indicating if animation blending must be used
  13258. */
  13259. enableBlending: boolean;
  13260. /**
  13261. * Gets or sets the blending speed to use when enableBlending is true
  13262. */
  13263. blendingSpeed: number;
  13264. /**
  13265. * Gets or sets the default loop mode to use
  13266. */
  13267. loopMode: number;
  13268. }
  13269. }
  13270. declare module "babylonjs/Bones/skeleton" {
  13271. import { Bone } from "babylonjs/Bones/bone";
  13272. import { Observable } from "babylonjs/Misc/observable";
  13273. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13274. import { Scene } from "babylonjs/scene";
  13275. import { Nullable } from "babylonjs/types";
  13276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13277. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13278. import { Animatable } from "babylonjs/Animations/animatable";
  13279. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13280. import { Animation } from "babylonjs/Animations/animation";
  13281. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13282. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13283. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13284. /**
  13285. * Class used to handle skinning animations
  13286. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13287. */
  13288. export class Skeleton implements IAnimatable {
  13289. /** defines the skeleton name */
  13290. name: string;
  13291. /** defines the skeleton Id */
  13292. id: string;
  13293. /**
  13294. * Defines the list of child bones
  13295. */
  13296. bones: Bone[];
  13297. /**
  13298. * Defines an estimate of the dimension of the skeleton at rest
  13299. */
  13300. dimensionsAtRest: Vector3;
  13301. /**
  13302. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13303. */
  13304. needInitialSkinMatrix: boolean;
  13305. /**
  13306. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13307. */
  13308. overrideMesh: Nullable<AbstractMesh>;
  13309. /**
  13310. * Gets the list of animations attached to this skeleton
  13311. */
  13312. animations: Array<Animation>;
  13313. private _scene;
  13314. private _isDirty;
  13315. private _transformMatrices;
  13316. private _transformMatrixTexture;
  13317. private _meshesWithPoseMatrix;
  13318. private _animatables;
  13319. private _identity;
  13320. private _synchronizedWithMesh;
  13321. private _ranges;
  13322. private _lastAbsoluteTransformsUpdateId;
  13323. private _canUseTextureForBones;
  13324. private _uniqueId;
  13325. /** @hidden */
  13326. _numBonesWithLinkedTransformNode: number;
  13327. /** @hidden */
  13328. _hasWaitingData: Nullable<boolean>;
  13329. /**
  13330. * Specifies if the skeleton should be serialized
  13331. */
  13332. doNotSerialize: boolean;
  13333. private _useTextureToStoreBoneMatrices;
  13334. /**
  13335. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13336. * Please note that this option is not available if the hardware does not support it
  13337. */
  13338. useTextureToStoreBoneMatrices: boolean;
  13339. private _animationPropertiesOverride;
  13340. /**
  13341. * Gets or sets the animation properties override
  13342. */
  13343. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13344. /**
  13345. * List of inspectable custom properties (used by the Inspector)
  13346. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13347. */
  13348. inspectableCustomProperties: IInspectable[];
  13349. /**
  13350. * An observable triggered before computing the skeleton's matrices
  13351. */
  13352. onBeforeComputeObservable: Observable<Skeleton>;
  13353. /**
  13354. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13355. */
  13356. readonly isUsingTextureForMatrices: boolean;
  13357. /**
  13358. * Gets the unique ID of this skeleton
  13359. */
  13360. readonly uniqueId: number;
  13361. /**
  13362. * Creates a new skeleton
  13363. * @param name defines the skeleton name
  13364. * @param id defines the skeleton Id
  13365. * @param scene defines the hosting scene
  13366. */
  13367. constructor(
  13368. /** defines the skeleton name */
  13369. name: string,
  13370. /** defines the skeleton Id */
  13371. id: string, scene: Scene);
  13372. /**
  13373. * Gets the current object class name.
  13374. * @return the class name
  13375. */
  13376. getClassName(): string;
  13377. /**
  13378. * Returns an array containing the root bones
  13379. * @returns an array containing the root bones
  13380. */
  13381. getChildren(): Array<Bone>;
  13382. /**
  13383. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13384. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13385. * @returns a Float32Array containing matrices data
  13386. */
  13387. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13388. /**
  13389. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13390. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13391. * @returns a raw texture containing the data
  13392. */
  13393. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13394. /**
  13395. * Gets the current hosting scene
  13396. * @returns a scene object
  13397. */
  13398. getScene(): Scene;
  13399. /**
  13400. * Gets a string representing the current skeleton data
  13401. * @param fullDetails defines a boolean indicating if we want a verbose version
  13402. * @returns a string representing the current skeleton data
  13403. */
  13404. toString(fullDetails?: boolean): string;
  13405. /**
  13406. * Get bone's index searching by name
  13407. * @param name defines bone's name to search for
  13408. * @return the indice of the bone. Returns -1 if not found
  13409. */
  13410. getBoneIndexByName(name: string): number;
  13411. /**
  13412. * Creater a new animation range
  13413. * @param name defines the name of the range
  13414. * @param from defines the start key
  13415. * @param to defines the end key
  13416. */
  13417. createAnimationRange(name: string, from: number, to: number): void;
  13418. /**
  13419. * Delete a specific animation range
  13420. * @param name defines the name of the range
  13421. * @param deleteFrames defines if frames must be removed as well
  13422. */
  13423. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13424. /**
  13425. * Gets a specific animation range
  13426. * @param name defines the name of the range to look for
  13427. * @returns the requested animation range or null if not found
  13428. */
  13429. getAnimationRange(name: string): Nullable<AnimationRange>;
  13430. /**
  13431. * Gets the list of all animation ranges defined on this skeleton
  13432. * @returns an array
  13433. */
  13434. getAnimationRanges(): Nullable<AnimationRange>[];
  13435. /**
  13436. * Copy animation range from a source skeleton.
  13437. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13438. * @param source defines the source skeleton
  13439. * @param name defines the name of the range to copy
  13440. * @param rescaleAsRequired defines if rescaling must be applied if required
  13441. * @returns true if operation was successful
  13442. */
  13443. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13444. /**
  13445. * Forces the skeleton to go to rest pose
  13446. */
  13447. returnToRest(): void;
  13448. private _getHighestAnimationFrame;
  13449. /**
  13450. * Begin a specific animation range
  13451. * @param name defines the name of the range to start
  13452. * @param loop defines if looping must be turned on (false by default)
  13453. * @param speedRatio defines the speed ratio to apply (1 by default)
  13454. * @param onAnimationEnd defines a callback which will be called when animation will end
  13455. * @returns a new animatable
  13456. */
  13457. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13458. /** @hidden */
  13459. _markAsDirty(): void;
  13460. /** @hidden */
  13461. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13462. /** @hidden */
  13463. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13464. private _computeTransformMatrices;
  13465. /**
  13466. * Build all resources required to render a skeleton
  13467. */
  13468. prepare(): void;
  13469. /**
  13470. * Gets the list of animatables currently running for this skeleton
  13471. * @returns an array of animatables
  13472. */
  13473. getAnimatables(): IAnimatable[];
  13474. /**
  13475. * Clone the current skeleton
  13476. * @param name defines the name of the new skeleton
  13477. * @param id defines the id of the new skeleton
  13478. * @returns the new skeleton
  13479. */
  13480. clone(name: string, id: string): Skeleton;
  13481. /**
  13482. * Enable animation blending for this skeleton
  13483. * @param blendingSpeed defines the blending speed to apply
  13484. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13485. */
  13486. enableBlending(blendingSpeed?: number): void;
  13487. /**
  13488. * Releases all resources associated with the current skeleton
  13489. */
  13490. dispose(): void;
  13491. /**
  13492. * Serialize the skeleton in a JSON object
  13493. * @returns a JSON object
  13494. */
  13495. serialize(): any;
  13496. /**
  13497. * Creates a new skeleton from serialized data
  13498. * @param parsedSkeleton defines the serialized data
  13499. * @param scene defines the hosting scene
  13500. * @returns a new skeleton
  13501. */
  13502. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13503. /**
  13504. * Compute all node absolute transforms
  13505. * @param forceUpdate defines if computation must be done even if cache is up to date
  13506. */
  13507. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13508. /**
  13509. * Gets the root pose matrix
  13510. * @returns a matrix
  13511. */
  13512. getPoseMatrix(): Nullable<Matrix>;
  13513. /**
  13514. * Sorts bones per internal index
  13515. */
  13516. sortBones(): void;
  13517. private _sortBones;
  13518. }
  13519. }
  13520. declare module "babylonjs/Bones/bone" {
  13521. import { Skeleton } from "babylonjs/Bones/skeleton";
  13522. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13523. import { Nullable } from "babylonjs/types";
  13524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13526. import { Node } from "babylonjs/node";
  13527. import { Space } from "babylonjs/Maths/math.axis";
  13528. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13529. /**
  13530. * Class used to store bone information
  13531. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13532. */
  13533. export class Bone extends Node {
  13534. /**
  13535. * defines the bone name
  13536. */
  13537. name: string;
  13538. private static _tmpVecs;
  13539. private static _tmpQuat;
  13540. private static _tmpMats;
  13541. /**
  13542. * Gets the list of child bones
  13543. */
  13544. children: Bone[];
  13545. /** Gets the animations associated with this bone */
  13546. animations: import("babylonjs/Animations/animation").Animation[];
  13547. /**
  13548. * Gets or sets bone length
  13549. */
  13550. length: number;
  13551. /**
  13552. * @hidden Internal only
  13553. * Set this value to map this bone to a different index in the transform matrices
  13554. * Set this value to -1 to exclude the bone from the transform matrices
  13555. */
  13556. _index: Nullable<number>;
  13557. private _skeleton;
  13558. private _localMatrix;
  13559. private _restPose;
  13560. private _baseMatrix;
  13561. private _absoluteTransform;
  13562. private _invertedAbsoluteTransform;
  13563. private _parent;
  13564. private _scalingDeterminant;
  13565. private _worldTransform;
  13566. private _localScaling;
  13567. private _localRotation;
  13568. private _localPosition;
  13569. private _needToDecompose;
  13570. private _needToCompose;
  13571. /** @hidden */
  13572. _linkedTransformNode: Nullable<TransformNode>;
  13573. /** @hidden */
  13574. _waitingTransformNodeId: Nullable<string>;
  13575. /** @hidden */
  13576. /** @hidden */
  13577. _matrix: Matrix;
  13578. /**
  13579. * Create a new bone
  13580. * @param name defines the bone name
  13581. * @param skeleton defines the parent skeleton
  13582. * @param parentBone defines the parent (can be null if the bone is the root)
  13583. * @param localMatrix defines the local matrix
  13584. * @param restPose defines the rest pose matrix
  13585. * @param baseMatrix defines the base matrix
  13586. * @param index defines index of the bone in the hiearchy
  13587. */
  13588. constructor(
  13589. /**
  13590. * defines the bone name
  13591. */
  13592. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13593. /**
  13594. * Gets the current object class name.
  13595. * @return the class name
  13596. */
  13597. getClassName(): string;
  13598. /**
  13599. * Gets the parent skeleton
  13600. * @returns a skeleton
  13601. */
  13602. getSkeleton(): Skeleton;
  13603. /**
  13604. * Gets parent bone
  13605. * @returns a bone or null if the bone is the root of the bone hierarchy
  13606. */
  13607. getParent(): Nullable<Bone>;
  13608. /**
  13609. * Returns an array containing the root bones
  13610. * @returns an array containing the root bones
  13611. */
  13612. getChildren(): Array<Bone>;
  13613. /**
  13614. * Sets the parent bone
  13615. * @param parent defines the parent (can be null if the bone is the root)
  13616. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13617. */
  13618. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13619. /**
  13620. * Gets the local matrix
  13621. * @returns a matrix
  13622. */
  13623. getLocalMatrix(): Matrix;
  13624. /**
  13625. * Gets the base matrix (initial matrix which remains unchanged)
  13626. * @returns a matrix
  13627. */
  13628. getBaseMatrix(): Matrix;
  13629. /**
  13630. * Gets the rest pose matrix
  13631. * @returns a matrix
  13632. */
  13633. getRestPose(): Matrix;
  13634. /**
  13635. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13636. */
  13637. getWorldMatrix(): Matrix;
  13638. /**
  13639. * Sets the local matrix to rest pose matrix
  13640. */
  13641. returnToRest(): void;
  13642. /**
  13643. * Gets the inverse of the absolute transform matrix.
  13644. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13645. * @returns a matrix
  13646. */
  13647. getInvertedAbsoluteTransform(): Matrix;
  13648. /**
  13649. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13650. * @returns a matrix
  13651. */
  13652. getAbsoluteTransform(): Matrix;
  13653. /**
  13654. * Links with the given transform node.
  13655. * The local matrix of this bone is copied from the transform node every frame.
  13656. * @param transformNode defines the transform node to link to
  13657. */
  13658. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13659. /** Gets or sets current position (in local space) */
  13660. position: Vector3;
  13661. /** Gets or sets current rotation (in local space) */
  13662. rotation: Vector3;
  13663. /** Gets or sets current rotation quaternion (in local space) */
  13664. rotationQuaternion: Quaternion;
  13665. /** Gets or sets current scaling (in local space) */
  13666. scaling: Vector3;
  13667. /**
  13668. * Gets the animation properties override
  13669. */
  13670. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13671. private _decompose;
  13672. private _compose;
  13673. /**
  13674. * Update the base and local matrices
  13675. * @param matrix defines the new base or local matrix
  13676. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13677. * @param updateLocalMatrix defines if the local matrix should be updated
  13678. */
  13679. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13680. /** @hidden */
  13681. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13682. /**
  13683. * Flag the bone as dirty (Forcing it to update everything)
  13684. */
  13685. markAsDirty(): void;
  13686. /** @hidden */
  13687. _markAsDirtyAndCompose(): void;
  13688. private _markAsDirtyAndDecompose;
  13689. /**
  13690. * Translate the bone in local or world space
  13691. * @param vec The amount to translate the bone
  13692. * @param space The space that the translation is in
  13693. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13694. */
  13695. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13696. /**
  13697. * Set the postion of the bone in local or world space
  13698. * @param position The position to set the bone
  13699. * @param space The space that the position is in
  13700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13701. */
  13702. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13703. /**
  13704. * Set the absolute position of the bone (world space)
  13705. * @param position The position to set the bone
  13706. * @param mesh The mesh that this bone is attached to
  13707. */
  13708. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13709. /**
  13710. * Scale the bone on the x, y and z axes (in local space)
  13711. * @param x The amount to scale the bone on the x axis
  13712. * @param y The amount to scale the bone on the y axis
  13713. * @param z The amount to scale the bone on the z axis
  13714. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13715. */
  13716. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13717. /**
  13718. * Set the bone scaling in local space
  13719. * @param scale defines the scaling vector
  13720. */
  13721. setScale(scale: Vector3): void;
  13722. /**
  13723. * Gets the current scaling in local space
  13724. * @returns the current scaling vector
  13725. */
  13726. getScale(): Vector3;
  13727. /**
  13728. * Gets the current scaling in local space and stores it in a target vector
  13729. * @param result defines the target vector
  13730. */
  13731. getScaleToRef(result: Vector3): void;
  13732. /**
  13733. * Set the yaw, pitch, and roll of the bone in local or world space
  13734. * @param yaw The rotation of the bone on the y axis
  13735. * @param pitch The rotation of the bone on the x axis
  13736. * @param roll The rotation of the bone on the z axis
  13737. * @param space The space that the axes of rotation are in
  13738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13739. */
  13740. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13741. /**
  13742. * Add a rotation to the bone on an axis in local or world space
  13743. * @param axis The axis to rotate the bone on
  13744. * @param amount The amount to rotate the bone
  13745. * @param space The space that the axis is in
  13746. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13747. */
  13748. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13749. /**
  13750. * Set the rotation of the bone to a particular axis angle in local or world space
  13751. * @param axis The axis to rotate the bone on
  13752. * @param angle The angle that the bone should be rotated to
  13753. * @param space The space that the axis is in
  13754. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13755. */
  13756. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13757. /**
  13758. * Set the euler rotation of the bone in local of world space
  13759. * @param rotation The euler rotation that the bone should be set to
  13760. * @param space The space that the rotation is in
  13761. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13762. */
  13763. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13764. /**
  13765. * Set the quaternion rotation of the bone in local of world space
  13766. * @param quat The quaternion rotation that the bone should be set to
  13767. * @param space The space that the rotation is in
  13768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13769. */
  13770. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13771. /**
  13772. * Set the rotation matrix of the bone in local of world space
  13773. * @param rotMat The rotation matrix that the bone should be set to
  13774. * @param space The space that the rotation is in
  13775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13776. */
  13777. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13778. private _rotateWithMatrix;
  13779. private _getNegativeRotationToRef;
  13780. /**
  13781. * Get the position of the bone in local or world space
  13782. * @param space The space that the returned position is in
  13783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13784. * @returns The position of the bone
  13785. */
  13786. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13787. /**
  13788. * Copy the position of the bone to a vector3 in local or world space
  13789. * @param space The space that the returned position is in
  13790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13791. * @param result The vector3 to copy the position to
  13792. */
  13793. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13794. /**
  13795. * Get the absolute position of the bone (world space)
  13796. * @param mesh The mesh that this bone is attached to
  13797. * @returns The absolute position of the bone
  13798. */
  13799. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13800. /**
  13801. * Copy the absolute position of the bone (world space) to the result param
  13802. * @param mesh The mesh that this bone is attached to
  13803. * @param result The vector3 to copy the absolute position to
  13804. */
  13805. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13806. /**
  13807. * Compute the absolute transforms of this bone and its children
  13808. */
  13809. computeAbsoluteTransforms(): void;
  13810. /**
  13811. * Get the world direction from an axis that is in the local space of the bone
  13812. * @param localAxis The local direction that is used to compute the world direction
  13813. * @param mesh The mesh that this bone is attached to
  13814. * @returns The world direction
  13815. */
  13816. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13817. /**
  13818. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13819. * @param localAxis The local direction that is used to compute the world direction
  13820. * @param mesh The mesh that this bone is attached to
  13821. * @param result The vector3 that the world direction will be copied to
  13822. */
  13823. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13824. /**
  13825. * Get the euler rotation of the bone in local or world space
  13826. * @param space The space that the rotation should be in
  13827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13828. * @returns The euler rotation
  13829. */
  13830. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13831. /**
  13832. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13833. * @param space The space that the rotation should be in
  13834. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13835. * @param result The vector3 that the rotation should be copied to
  13836. */
  13837. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13838. /**
  13839. * Get the quaternion rotation of the bone in either local or world space
  13840. * @param space The space that the rotation should be in
  13841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13842. * @returns The quaternion rotation
  13843. */
  13844. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13845. /**
  13846. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13847. * @param space The space that the rotation should be in
  13848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13849. * @param result The quaternion that the rotation should be copied to
  13850. */
  13851. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13852. /**
  13853. * Get the rotation matrix of the bone in local or world space
  13854. * @param space The space that the rotation should be in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. * @returns The rotation matrix
  13857. */
  13858. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13859. /**
  13860. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13861. * @param space The space that the rotation should be in
  13862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13863. * @param result The quaternion that the rotation should be copied to
  13864. */
  13865. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13866. /**
  13867. * Get the world position of a point that is in the local space of the bone
  13868. * @param position The local position
  13869. * @param mesh The mesh that this bone is attached to
  13870. * @returns The world position
  13871. */
  13872. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13873. /**
  13874. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13875. * @param position The local position
  13876. * @param mesh The mesh that this bone is attached to
  13877. * @param result The vector3 that the world position should be copied to
  13878. */
  13879. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13880. /**
  13881. * Get the local position of a point that is in world space
  13882. * @param position The world position
  13883. * @param mesh The mesh that this bone is attached to
  13884. * @returns The local position
  13885. */
  13886. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13887. /**
  13888. * Get the local position of a point that is in world space and copy it to the result param
  13889. * @param position The world position
  13890. * @param mesh The mesh that this bone is attached to
  13891. * @param result The vector3 that the local position should be copied to
  13892. */
  13893. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13894. }
  13895. }
  13896. declare module "babylonjs/Meshes/transformNode" {
  13897. import { DeepImmutable } from "babylonjs/types";
  13898. import { Observable } from "babylonjs/Misc/observable";
  13899. import { Nullable } from "babylonjs/types";
  13900. import { Camera } from "babylonjs/Cameras/camera";
  13901. import { Scene } from "babylonjs/scene";
  13902. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13903. import { Node } from "babylonjs/node";
  13904. import { Bone } from "babylonjs/Bones/bone";
  13905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13906. import { Space } from "babylonjs/Maths/math.axis";
  13907. /**
  13908. * 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.
  13909. * @see https://doc.babylonjs.com/how_to/transformnode
  13910. */
  13911. export class TransformNode extends Node {
  13912. /**
  13913. * Object will not rotate to face the camera
  13914. */
  13915. static BILLBOARDMODE_NONE: number;
  13916. /**
  13917. * Object will rotate to face the camera but only on the x axis
  13918. */
  13919. static BILLBOARDMODE_X: number;
  13920. /**
  13921. * Object will rotate to face the camera but only on the y axis
  13922. */
  13923. static BILLBOARDMODE_Y: number;
  13924. /**
  13925. * Object will rotate to face the camera but only on the z axis
  13926. */
  13927. static BILLBOARDMODE_Z: number;
  13928. /**
  13929. * Object will rotate to face the camera
  13930. */
  13931. static BILLBOARDMODE_ALL: number;
  13932. private _forward;
  13933. private _forwardInverted;
  13934. private _up;
  13935. private _right;
  13936. private _rightInverted;
  13937. private _position;
  13938. private _rotation;
  13939. private _rotationQuaternion;
  13940. protected _scaling: Vector3;
  13941. protected _isDirty: boolean;
  13942. private _transformToBoneReferal;
  13943. private _billboardMode;
  13944. /**
  13945. * Gets or sets the billboard mode. Default is 0.
  13946. *
  13947. * | Value | Type | Description |
  13948. * | --- | --- | --- |
  13949. * | 0 | BILLBOARDMODE_NONE | |
  13950. * | 1 | BILLBOARDMODE_X | |
  13951. * | 2 | BILLBOARDMODE_Y | |
  13952. * | 4 | BILLBOARDMODE_Z | |
  13953. * | 7 | BILLBOARDMODE_ALL | |
  13954. *
  13955. */
  13956. billboardMode: number;
  13957. private _preserveParentRotationForBillboard;
  13958. /**
  13959. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13960. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13961. */
  13962. preserveParentRotationForBillboard: boolean;
  13963. /**
  13964. * 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
  13965. */
  13966. scalingDeterminant: number;
  13967. private _infiniteDistance;
  13968. /**
  13969. * Gets or sets the distance of the object to max, often used by skybox
  13970. */
  13971. infiniteDistance: boolean;
  13972. /**
  13973. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13974. * By default the system will update normals to compensate
  13975. */
  13976. ignoreNonUniformScaling: boolean;
  13977. /**
  13978. * 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
  13979. */
  13980. reIntegrateRotationIntoRotationQuaternion: boolean;
  13981. /** @hidden */
  13982. _poseMatrix: Nullable<Matrix>;
  13983. /** @hidden */
  13984. _localMatrix: Matrix;
  13985. private _usePivotMatrix;
  13986. private _absolutePosition;
  13987. private _pivotMatrix;
  13988. private _pivotMatrixInverse;
  13989. protected _postMultiplyPivotMatrix: boolean;
  13990. protected _isWorldMatrixFrozen: boolean;
  13991. /** @hidden */
  13992. _indexInSceneTransformNodesArray: number;
  13993. /**
  13994. * An event triggered after the world matrix is updated
  13995. */
  13996. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13997. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13998. /**
  13999. * Gets a string identifying the name of the class
  14000. * @returns "TransformNode" string
  14001. */
  14002. getClassName(): string;
  14003. /**
  14004. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14005. */
  14006. position: Vector3;
  14007. /**
  14008. * 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)).
  14009. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14010. */
  14011. rotation: Vector3;
  14012. /**
  14013. * 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)).
  14014. */
  14015. scaling: Vector3;
  14016. /**
  14017. * 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).
  14018. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14019. */
  14020. rotationQuaternion: Nullable<Quaternion>;
  14021. /**
  14022. * The forward direction of that transform in world space.
  14023. */
  14024. readonly forward: Vector3;
  14025. /**
  14026. * The up direction of that transform in world space.
  14027. */
  14028. readonly up: Vector3;
  14029. /**
  14030. * The right direction of that transform in world space.
  14031. */
  14032. readonly right: Vector3;
  14033. /**
  14034. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14035. * @param matrix the matrix to copy the pose from
  14036. * @returns this TransformNode.
  14037. */
  14038. updatePoseMatrix(matrix: Matrix): TransformNode;
  14039. /**
  14040. * Returns the mesh Pose matrix.
  14041. * @returns the pose matrix
  14042. */
  14043. getPoseMatrix(): Matrix;
  14044. /** @hidden */
  14045. _isSynchronized(): boolean;
  14046. /** @hidden */
  14047. _initCache(): void;
  14048. /**
  14049. * Flag the transform node as dirty (Forcing it to update everything)
  14050. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14051. * @returns this transform node
  14052. */
  14053. markAsDirty(property: string): TransformNode;
  14054. /**
  14055. * Returns the current mesh absolute position.
  14056. * Returns a Vector3.
  14057. */
  14058. readonly absolutePosition: Vector3;
  14059. /**
  14060. * Sets a new matrix to apply before all other transformation
  14061. * @param matrix defines the transform matrix
  14062. * @returns the current TransformNode
  14063. */
  14064. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14065. /**
  14066. * Sets a new pivot matrix to the current node
  14067. * @param matrix defines the new pivot matrix to use
  14068. * @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
  14069. * @returns the current TransformNode
  14070. */
  14071. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14072. /**
  14073. * Returns the mesh pivot matrix.
  14074. * Default : Identity.
  14075. * @returns the matrix
  14076. */
  14077. getPivotMatrix(): Matrix;
  14078. /**
  14079. * Prevents the World matrix to be computed any longer.
  14080. * @returns the TransformNode.
  14081. */
  14082. freezeWorldMatrix(): TransformNode;
  14083. /**
  14084. * Allows back the World matrix computation.
  14085. * @returns the TransformNode.
  14086. */
  14087. unfreezeWorldMatrix(): this;
  14088. /**
  14089. * True if the World matrix has been frozen.
  14090. */
  14091. readonly isWorldMatrixFrozen: boolean;
  14092. /**
  14093. * Retuns the mesh absolute position in the World.
  14094. * @returns a Vector3.
  14095. */
  14096. getAbsolutePosition(): Vector3;
  14097. /**
  14098. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14099. * @param absolutePosition the absolute position to set
  14100. * @returns the TransformNode.
  14101. */
  14102. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14103. /**
  14104. * Sets the mesh position in its local space.
  14105. * @param vector3 the position to set in localspace
  14106. * @returns the TransformNode.
  14107. */
  14108. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14109. /**
  14110. * Returns the mesh position in the local space from the current World matrix values.
  14111. * @returns a new Vector3.
  14112. */
  14113. getPositionExpressedInLocalSpace(): Vector3;
  14114. /**
  14115. * Translates the mesh along the passed Vector3 in its local space.
  14116. * @param vector3 the distance to translate in localspace
  14117. * @returns the TransformNode.
  14118. */
  14119. locallyTranslate(vector3: Vector3): TransformNode;
  14120. private static _lookAtVectorCache;
  14121. /**
  14122. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14123. * @param targetPoint the position (must be in same space as current mesh) to look at
  14124. * @param yawCor optional yaw (y-axis) correction in radians
  14125. * @param pitchCor optional pitch (x-axis) correction in radians
  14126. * @param rollCor optional roll (z-axis) correction in radians
  14127. * @param space the choosen space of the target
  14128. * @returns the TransformNode.
  14129. */
  14130. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14131. /**
  14132. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14133. * This Vector3 is expressed in the World space.
  14134. * @param localAxis axis to rotate
  14135. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14136. */
  14137. getDirection(localAxis: Vector3): Vector3;
  14138. /**
  14139. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14140. * localAxis is expressed in the mesh local space.
  14141. * result is computed in the Wordl space from the mesh World matrix.
  14142. * @param localAxis axis to rotate
  14143. * @param result the resulting transformnode
  14144. * @returns this TransformNode.
  14145. */
  14146. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14147. /**
  14148. * Sets this transform node rotation to the given local axis.
  14149. * @param localAxis the axis in local space
  14150. * @param yawCor optional yaw (y-axis) correction in radians
  14151. * @param pitchCor optional pitch (x-axis) correction in radians
  14152. * @param rollCor optional roll (z-axis) correction in radians
  14153. * @returns this TransformNode
  14154. */
  14155. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14156. /**
  14157. * Sets a new pivot point to the current node
  14158. * @param point defines the new pivot point to use
  14159. * @param space defines if the point is in world or local space (local by default)
  14160. * @returns the current TransformNode
  14161. */
  14162. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14163. /**
  14164. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14165. * @returns the pivot point
  14166. */
  14167. getPivotPoint(): Vector3;
  14168. /**
  14169. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14170. * @param result the vector3 to store the result
  14171. * @returns this TransformNode.
  14172. */
  14173. getPivotPointToRef(result: Vector3): TransformNode;
  14174. /**
  14175. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14176. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14177. */
  14178. getAbsolutePivotPoint(): Vector3;
  14179. /**
  14180. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14181. * @param result vector3 to store the result
  14182. * @returns this TransformNode.
  14183. */
  14184. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14185. /**
  14186. * Defines the passed node as the parent of the current node.
  14187. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14188. * @see https://doc.babylonjs.com/how_to/parenting
  14189. * @param node the node ot set as the parent
  14190. * @returns this TransformNode.
  14191. */
  14192. setParent(node: Nullable<Node>): TransformNode;
  14193. private _nonUniformScaling;
  14194. /**
  14195. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14196. */
  14197. readonly nonUniformScaling: boolean;
  14198. /** @hidden */
  14199. _updateNonUniformScalingState(value: boolean): boolean;
  14200. /**
  14201. * Attach the current TransformNode to another TransformNode associated with a bone
  14202. * @param bone Bone affecting the TransformNode
  14203. * @param affectedTransformNode TransformNode associated with the bone
  14204. * @returns this object
  14205. */
  14206. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14207. /**
  14208. * Detach the transform node if its associated with a bone
  14209. * @returns this object
  14210. */
  14211. detachFromBone(): TransformNode;
  14212. private static _rotationAxisCache;
  14213. /**
  14214. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14215. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14216. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14217. * The passed axis is also normalized.
  14218. * @param axis the axis to rotate around
  14219. * @param amount the amount to rotate in radians
  14220. * @param space Space to rotate in (Default: local)
  14221. * @returns the TransformNode.
  14222. */
  14223. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14224. /**
  14225. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14226. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14227. * The passed axis is also normalized. .
  14228. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14229. * @param point the point to rotate around
  14230. * @param axis the axis to rotate around
  14231. * @param amount the amount to rotate in radians
  14232. * @returns the TransformNode
  14233. */
  14234. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14235. /**
  14236. * Translates the mesh along the axis vector for the passed distance in the given space.
  14237. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14238. * @param axis the axis to translate in
  14239. * @param distance the distance to translate
  14240. * @param space Space to rotate in (Default: local)
  14241. * @returns the TransformNode.
  14242. */
  14243. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14244. /**
  14245. * Adds a rotation step to the mesh current rotation.
  14246. * x, y, z are Euler angles expressed in radians.
  14247. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14248. * This means this rotation is made in the mesh local space only.
  14249. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14250. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14251. * ```javascript
  14252. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14253. * ```
  14254. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14255. * 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.
  14256. * @param x Rotation to add
  14257. * @param y Rotation to add
  14258. * @param z Rotation to add
  14259. * @returns the TransformNode.
  14260. */
  14261. addRotation(x: number, y: number, z: number): TransformNode;
  14262. /**
  14263. * @hidden
  14264. */
  14265. protected _getEffectiveParent(): Nullable<Node>;
  14266. /**
  14267. * Computes the world matrix of the node
  14268. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14269. * @returns the world matrix
  14270. */
  14271. computeWorldMatrix(force?: boolean): Matrix;
  14272. protected _afterComputeWorldMatrix(): void;
  14273. /**
  14274. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14275. * @param func callback function to add
  14276. *
  14277. * @returns the TransformNode.
  14278. */
  14279. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14280. /**
  14281. * Removes a registered callback function.
  14282. * @param func callback function to remove
  14283. * @returns the TransformNode.
  14284. */
  14285. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14286. /**
  14287. * Gets the position of the current mesh in camera space
  14288. * @param camera defines the camera to use
  14289. * @returns a position
  14290. */
  14291. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14292. /**
  14293. * Returns the distance from the mesh to the active camera
  14294. * @param camera defines the camera to use
  14295. * @returns the distance
  14296. */
  14297. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14298. /**
  14299. * Clone the current transform node
  14300. * @param name Name of the new clone
  14301. * @param newParent New parent for the clone
  14302. * @param doNotCloneChildren Do not clone children hierarchy
  14303. * @returns the new transform node
  14304. */
  14305. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14306. /**
  14307. * Serializes the objects information.
  14308. * @param currentSerializationObject defines the object to serialize in
  14309. * @returns the serialized object
  14310. */
  14311. serialize(currentSerializationObject?: any): any;
  14312. /**
  14313. * Returns a new TransformNode object parsed from the source provided.
  14314. * @param parsedTransformNode is the source.
  14315. * @param scene the scne the object belongs to
  14316. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14317. * @returns a new TransformNode object parsed from the source provided.
  14318. */
  14319. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14320. /**
  14321. * Get all child-transformNodes of this node
  14322. * @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
  14323. * @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
  14324. * @returns an array of TransformNode
  14325. */
  14326. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14327. /**
  14328. * Releases resources associated with this transform node.
  14329. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14330. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14331. */
  14332. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14333. /**
  14334. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14335. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14336. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14337. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14338. * @returns the current mesh
  14339. */
  14340. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14341. }
  14342. }
  14343. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14344. import { Observable } from "babylonjs/Misc/observable";
  14345. import { Nullable } from "babylonjs/types";
  14346. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14347. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14349. import { Ray } from "babylonjs/Culling/ray";
  14350. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14351. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14352. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14353. /**
  14354. * Defines the types of pose enabled controllers that are supported
  14355. */
  14356. export enum PoseEnabledControllerType {
  14357. /**
  14358. * HTC Vive
  14359. */
  14360. VIVE = 0,
  14361. /**
  14362. * Oculus Rift
  14363. */
  14364. OCULUS = 1,
  14365. /**
  14366. * Windows mixed reality
  14367. */
  14368. WINDOWS = 2,
  14369. /**
  14370. * Samsung gear VR
  14371. */
  14372. GEAR_VR = 3,
  14373. /**
  14374. * Google Daydream
  14375. */
  14376. DAYDREAM = 4,
  14377. /**
  14378. * Generic
  14379. */
  14380. GENERIC = 5
  14381. }
  14382. /**
  14383. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14384. */
  14385. export interface MutableGamepadButton {
  14386. /**
  14387. * Value of the button/trigger
  14388. */
  14389. value: number;
  14390. /**
  14391. * If the button/trigger is currently touched
  14392. */
  14393. touched: boolean;
  14394. /**
  14395. * If the button/trigger is currently pressed
  14396. */
  14397. pressed: boolean;
  14398. }
  14399. /**
  14400. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14401. * @hidden
  14402. */
  14403. export interface ExtendedGamepadButton extends GamepadButton {
  14404. /**
  14405. * If the button/trigger is currently pressed
  14406. */
  14407. readonly pressed: boolean;
  14408. /**
  14409. * If the button/trigger is currently touched
  14410. */
  14411. readonly touched: boolean;
  14412. /**
  14413. * Value of the button/trigger
  14414. */
  14415. readonly value: number;
  14416. }
  14417. /** @hidden */
  14418. export interface _GamePadFactory {
  14419. /**
  14420. * Returns wether or not the current gamepad can be created for this type of controller.
  14421. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14422. * @returns true if it can be created, otherwise false
  14423. */
  14424. canCreate(gamepadInfo: any): boolean;
  14425. /**
  14426. * Creates a new instance of the Gamepad.
  14427. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14428. * @returns the new gamepad instance
  14429. */
  14430. create(gamepadInfo: any): Gamepad;
  14431. }
  14432. /**
  14433. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14434. */
  14435. export class PoseEnabledControllerHelper {
  14436. /** @hidden */
  14437. static _ControllerFactories: _GamePadFactory[];
  14438. /** @hidden */
  14439. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14440. /**
  14441. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14442. * @param vrGamepad the gamepad to initialized
  14443. * @returns a vr controller of the type the gamepad identified as
  14444. */
  14445. static InitiateController(vrGamepad: any): Gamepad;
  14446. }
  14447. /**
  14448. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14449. */
  14450. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14451. /**
  14452. * If the controller is used in a webXR session
  14453. */
  14454. isXR: boolean;
  14455. private _deviceRoomPosition;
  14456. private _deviceRoomRotationQuaternion;
  14457. /**
  14458. * The device position in babylon space
  14459. */
  14460. devicePosition: Vector3;
  14461. /**
  14462. * The device rotation in babylon space
  14463. */
  14464. deviceRotationQuaternion: Quaternion;
  14465. /**
  14466. * The scale factor of the device in babylon space
  14467. */
  14468. deviceScaleFactor: number;
  14469. /**
  14470. * (Likely devicePosition should be used instead) The device position in its room space
  14471. */
  14472. position: Vector3;
  14473. /**
  14474. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14475. */
  14476. rotationQuaternion: Quaternion;
  14477. /**
  14478. * The type of controller (Eg. Windows mixed reality)
  14479. */
  14480. controllerType: PoseEnabledControllerType;
  14481. protected _calculatedPosition: Vector3;
  14482. private _calculatedRotation;
  14483. /**
  14484. * The raw pose from the device
  14485. */
  14486. rawPose: DevicePose;
  14487. private _trackPosition;
  14488. private _maxRotationDistFromHeadset;
  14489. private _draggedRoomRotation;
  14490. /**
  14491. * @hidden
  14492. */
  14493. _disableTrackPosition(fixedPosition: Vector3): void;
  14494. /**
  14495. * Internal, the mesh attached to the controller
  14496. * @hidden
  14497. */
  14498. _mesh: Nullable<AbstractMesh>;
  14499. private _poseControlledCamera;
  14500. private _leftHandSystemQuaternion;
  14501. /**
  14502. * Internal, matrix used to convert room space to babylon space
  14503. * @hidden
  14504. */
  14505. _deviceToWorld: Matrix;
  14506. /**
  14507. * Node to be used when casting a ray from the controller
  14508. * @hidden
  14509. */
  14510. _pointingPoseNode: Nullable<TransformNode>;
  14511. /**
  14512. * Name of the child mesh that can be used to cast a ray from the controller
  14513. */
  14514. static readonly POINTING_POSE: string;
  14515. /**
  14516. * Creates a new PoseEnabledController from a gamepad
  14517. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14518. */
  14519. constructor(browserGamepad: any);
  14520. private _workingMatrix;
  14521. /**
  14522. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14523. */
  14524. update(): void;
  14525. /**
  14526. * Updates only the pose device and mesh without doing any button event checking
  14527. */
  14528. protected _updatePoseAndMesh(): void;
  14529. /**
  14530. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14531. * @param poseData raw pose fromthe device
  14532. */
  14533. updateFromDevice(poseData: DevicePose): void;
  14534. /**
  14535. * @hidden
  14536. */
  14537. _meshAttachedObservable: Observable<AbstractMesh>;
  14538. /**
  14539. * Attaches a mesh to the controller
  14540. * @param mesh the mesh to be attached
  14541. */
  14542. attachToMesh(mesh: AbstractMesh): void;
  14543. /**
  14544. * Attaches the controllers mesh to a camera
  14545. * @param camera the camera the mesh should be attached to
  14546. */
  14547. attachToPoseControlledCamera(camera: TargetCamera): void;
  14548. /**
  14549. * Disposes of the controller
  14550. */
  14551. dispose(): void;
  14552. /**
  14553. * The mesh that is attached to the controller
  14554. */
  14555. readonly mesh: Nullable<AbstractMesh>;
  14556. /**
  14557. * Gets the ray of the controller in the direction the controller is pointing
  14558. * @param length the length the resulting ray should be
  14559. * @returns a ray in the direction the controller is pointing
  14560. */
  14561. getForwardRay(length?: number): Ray;
  14562. }
  14563. }
  14564. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14565. import { Observable } from "babylonjs/Misc/observable";
  14566. import { Scene } from "babylonjs/scene";
  14567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14568. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14569. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14570. /**
  14571. * Defines the WebVRController object that represents controllers tracked in 3D space
  14572. */
  14573. export abstract class WebVRController extends PoseEnabledController {
  14574. /**
  14575. * Internal, the default controller model for the controller
  14576. */
  14577. protected _defaultModel: AbstractMesh;
  14578. /**
  14579. * Fired when the trigger state has changed
  14580. */
  14581. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14582. /**
  14583. * Fired when the main button state has changed
  14584. */
  14585. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14586. /**
  14587. * Fired when the secondary button state has changed
  14588. */
  14589. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14590. /**
  14591. * Fired when the pad state has changed
  14592. */
  14593. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14594. /**
  14595. * Fired when controllers stick values have changed
  14596. */
  14597. onPadValuesChangedObservable: Observable<StickValues>;
  14598. /**
  14599. * Array of button availible on the controller
  14600. */
  14601. protected _buttons: Array<MutableGamepadButton>;
  14602. private _onButtonStateChange;
  14603. /**
  14604. * Fired when a controller button's state has changed
  14605. * @param callback the callback containing the button that was modified
  14606. */
  14607. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14608. /**
  14609. * X and Y axis corresponding to the controllers joystick
  14610. */
  14611. pad: StickValues;
  14612. /**
  14613. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14614. */
  14615. hand: string;
  14616. /**
  14617. * The default controller model for the controller
  14618. */
  14619. readonly defaultModel: AbstractMesh;
  14620. /**
  14621. * Creates a new WebVRController from a gamepad
  14622. * @param vrGamepad the gamepad that the WebVRController should be created from
  14623. */
  14624. constructor(vrGamepad: any);
  14625. /**
  14626. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14627. */
  14628. update(): void;
  14629. /**
  14630. * Function to be called when a button is modified
  14631. */
  14632. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14633. /**
  14634. * Loads a mesh and attaches it to the controller
  14635. * @param scene the scene the mesh should be added to
  14636. * @param meshLoaded callback for when the mesh has been loaded
  14637. */
  14638. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14639. private _setButtonValue;
  14640. private _changes;
  14641. private _checkChanges;
  14642. /**
  14643. * Disposes of th webVRCOntroller
  14644. */
  14645. dispose(): void;
  14646. }
  14647. }
  14648. declare module "babylonjs/Lights/hemisphericLight" {
  14649. import { Nullable } from "babylonjs/types";
  14650. import { Scene } from "babylonjs/scene";
  14651. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14652. import { Color3 } from "babylonjs/Maths/math.color";
  14653. import { Effect } from "babylonjs/Materials/effect";
  14654. import { Light } from "babylonjs/Lights/light";
  14655. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14656. /**
  14657. * The HemisphericLight simulates the ambient environment light,
  14658. * so the passed direction is the light reflection direction, not the incoming direction.
  14659. */
  14660. export class HemisphericLight extends Light {
  14661. /**
  14662. * The groundColor is the light in the opposite direction to the one specified during creation.
  14663. * 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.
  14664. */
  14665. groundColor: Color3;
  14666. /**
  14667. * The light reflection direction, not the incoming direction.
  14668. */
  14669. direction: Vector3;
  14670. /**
  14671. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14672. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14673. * The HemisphericLight can't cast shadows.
  14674. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14675. * @param name The friendly name of the light
  14676. * @param direction The direction of the light reflection
  14677. * @param scene The scene the light belongs to
  14678. */
  14679. constructor(name: string, direction: Vector3, scene: Scene);
  14680. protected _buildUniformLayout(): void;
  14681. /**
  14682. * Returns the string "HemisphericLight".
  14683. * @return The class name
  14684. */
  14685. getClassName(): string;
  14686. /**
  14687. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14688. * Returns the updated direction.
  14689. * @param target The target the direction should point to
  14690. * @return The computed direction
  14691. */
  14692. setDirectionToTarget(target: Vector3): Vector3;
  14693. /**
  14694. * Returns the shadow generator associated to the light.
  14695. * @returns Always null for hemispheric lights because it does not support shadows.
  14696. */
  14697. getShadowGenerator(): Nullable<IShadowGenerator>;
  14698. /**
  14699. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14700. * @param effect The effect to update
  14701. * @param lightIndex The index of the light in the effect to update
  14702. * @returns The hemispheric light
  14703. */
  14704. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14705. /**
  14706. * Computes the world matrix of the node
  14707. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14708. * @param useWasUpdatedFlag defines a reserved property
  14709. * @returns the world matrix
  14710. */
  14711. computeWorldMatrix(): Matrix;
  14712. /**
  14713. * Returns the integer 3.
  14714. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14715. */
  14716. getTypeID(): number;
  14717. /**
  14718. * Prepares the list of defines specific to the light type.
  14719. * @param defines the list of defines
  14720. * @param lightIndex defines the index of the light for the effect
  14721. */
  14722. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14723. }
  14724. }
  14725. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14726. /** @hidden */
  14727. export var vrMultiviewToSingleviewPixelShader: {
  14728. name: string;
  14729. shader: string;
  14730. };
  14731. }
  14732. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14733. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14734. import { Scene } from "babylonjs/scene";
  14735. /**
  14736. * Renders to multiple views with a single draw call
  14737. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14738. */
  14739. export class MultiviewRenderTarget extends RenderTargetTexture {
  14740. /**
  14741. * Creates a multiview render target
  14742. * @param scene scene used with the render target
  14743. * @param size the size of the render target (used for each view)
  14744. */
  14745. constructor(scene: Scene, size?: number | {
  14746. width: number;
  14747. height: number;
  14748. } | {
  14749. ratio: number;
  14750. });
  14751. /**
  14752. * @hidden
  14753. * @param faceIndex the face index, if its a cube texture
  14754. */
  14755. _bindFrameBuffer(faceIndex?: number): void;
  14756. /**
  14757. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14758. * @returns the view count
  14759. */
  14760. getViewCount(): number;
  14761. }
  14762. }
  14763. declare module "babylonjs/Maths/math.frustum" {
  14764. import { Matrix } from "babylonjs/Maths/math.vector";
  14765. import { DeepImmutable } from "babylonjs/types";
  14766. import { Plane } from "babylonjs/Maths/math.plane";
  14767. /**
  14768. * Reprasents a camera frustum
  14769. */
  14770. export class Frustum {
  14771. /**
  14772. * Gets the planes representing the frustum
  14773. * @param transform matrix to be applied to the returned planes
  14774. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14775. */
  14776. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14777. /**
  14778. * Gets the near frustum plane transformed by the transform matrix
  14779. * @param transform transformation matrix to be applied to the resulting frustum plane
  14780. * @param frustumPlane the resuling frustum plane
  14781. */
  14782. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14783. /**
  14784. * Gets the far frustum plane transformed by the transform matrix
  14785. * @param transform transformation matrix to be applied to the resulting frustum plane
  14786. * @param frustumPlane the resuling frustum plane
  14787. */
  14788. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14789. /**
  14790. * Gets the left frustum plane transformed by the transform matrix
  14791. * @param transform transformation matrix to be applied to the resulting frustum plane
  14792. * @param frustumPlane the resuling frustum plane
  14793. */
  14794. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14795. /**
  14796. * Gets the right frustum plane transformed by the transform matrix
  14797. * @param transform transformation matrix to be applied to the resulting frustum plane
  14798. * @param frustumPlane the resuling frustum plane
  14799. */
  14800. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14801. /**
  14802. * Gets the top frustum plane transformed by the transform matrix
  14803. * @param transform transformation matrix to be applied to the resulting frustum plane
  14804. * @param frustumPlane the resuling frustum plane
  14805. */
  14806. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14807. /**
  14808. * Gets the bottom frustum plane transformed by the transform matrix
  14809. * @param transform transformation matrix to be applied to the resulting frustum plane
  14810. * @param frustumPlane the resuling frustum plane
  14811. */
  14812. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14813. /**
  14814. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14815. * @param transform transformation matrix to be applied to the resulting frustum planes
  14816. * @param frustumPlanes the resuling frustum planes
  14817. */
  14818. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14819. }
  14820. }
  14821. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14822. import { Camera } from "babylonjs/Cameras/camera";
  14823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14824. import { Nullable } from "babylonjs/types";
  14825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14826. import { Matrix } from "babylonjs/Maths/math.vector";
  14827. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14828. module "babylonjs/Engines/engine" {
  14829. interface Engine {
  14830. /**
  14831. * Creates a new multiview render target
  14832. * @param width defines the width of the texture
  14833. * @param height defines the height of the texture
  14834. * @returns the created multiview texture
  14835. */
  14836. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14837. /**
  14838. * Binds a multiview framebuffer to be drawn to
  14839. * @param multiviewTexture texture to bind
  14840. */
  14841. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14842. }
  14843. }
  14844. module "babylonjs/Cameras/camera" {
  14845. interface Camera {
  14846. /**
  14847. * @hidden
  14848. * 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)
  14849. */
  14850. _useMultiviewToSingleView: boolean;
  14851. /**
  14852. * @hidden
  14853. * 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)
  14854. */
  14855. _multiviewTexture: Nullable<RenderTargetTexture>;
  14856. /**
  14857. * @hidden
  14858. * ensures the multiview texture of the camera exists and has the specified width/height
  14859. * @param width height to set on the multiview texture
  14860. * @param height width to set on the multiview texture
  14861. */
  14862. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14863. }
  14864. }
  14865. module "babylonjs/scene" {
  14866. interface Scene {
  14867. /** @hidden */
  14868. _transformMatrixR: Matrix;
  14869. /** @hidden */
  14870. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14871. /** @hidden */
  14872. _createMultiviewUbo(): void;
  14873. /** @hidden */
  14874. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14875. /** @hidden */
  14876. _renderMultiviewToSingleView(camera: Camera): void;
  14877. }
  14878. }
  14879. }
  14880. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14881. import { Camera } from "babylonjs/Cameras/camera";
  14882. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14883. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14884. import "babylonjs/Engines/Extensions/engine.multiview";
  14885. /**
  14886. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14887. * This will not be used for webXR as it supports displaying texture arrays directly
  14888. */
  14889. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14890. /**
  14891. * Initializes a VRMultiviewToSingleview
  14892. * @param name name of the post process
  14893. * @param camera camera to be applied to
  14894. * @param scaleFactor scaling factor to the size of the output texture
  14895. */
  14896. constructor(name: string, camera: Camera, scaleFactor: number);
  14897. }
  14898. }
  14899. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14900. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14901. import { Nullable } from "babylonjs/types";
  14902. import { Size } from "babylonjs/Maths/math.size";
  14903. import { Observable } from "babylonjs/Misc/observable";
  14904. module "babylonjs/Engines/engine" {
  14905. interface Engine {
  14906. /** @hidden */
  14907. _vrDisplay: any;
  14908. /** @hidden */
  14909. _vrSupported: boolean;
  14910. /** @hidden */
  14911. _oldSize: Size;
  14912. /** @hidden */
  14913. _oldHardwareScaleFactor: number;
  14914. /** @hidden */
  14915. _vrExclusivePointerMode: boolean;
  14916. /** @hidden */
  14917. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14918. /** @hidden */
  14919. _onVRDisplayPointerRestricted: () => void;
  14920. /** @hidden */
  14921. _onVRDisplayPointerUnrestricted: () => void;
  14922. /** @hidden */
  14923. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14924. /** @hidden */
  14925. _onVrDisplayDisconnect: Nullable<() => void>;
  14926. /** @hidden */
  14927. _onVrDisplayPresentChange: Nullable<() => void>;
  14928. /**
  14929. * Observable signaled when VR display mode changes
  14930. */
  14931. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14932. /**
  14933. * Observable signaled when VR request present is complete
  14934. */
  14935. onVRRequestPresentComplete: Observable<boolean>;
  14936. /**
  14937. * Observable signaled when VR request present starts
  14938. */
  14939. onVRRequestPresentStart: Observable<Engine>;
  14940. /**
  14941. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14942. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14943. */
  14944. isInVRExclusivePointerMode: boolean;
  14945. /**
  14946. * Gets a boolean indicating if a webVR device was detected
  14947. * @returns true if a webVR device was detected
  14948. */
  14949. isVRDevicePresent(): boolean;
  14950. /**
  14951. * Gets the current webVR device
  14952. * @returns the current webVR device (or null)
  14953. */
  14954. getVRDevice(): any;
  14955. /**
  14956. * Initializes a webVR display and starts listening to display change events
  14957. * The onVRDisplayChangedObservable will be notified upon these changes
  14958. * @returns A promise containing a VRDisplay and if vr is supported
  14959. */
  14960. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14961. /** @hidden */
  14962. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14963. /**
  14964. * Call this function to switch to webVR mode
  14965. * Will do nothing if webVR is not supported or if there is no webVR device
  14966. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14967. */
  14968. enableVR(): void;
  14969. /** @hidden */
  14970. _onVRFullScreenTriggered(): void;
  14971. }
  14972. }
  14973. }
  14974. declare module "babylonjs/Cameras/VR/webVRCamera" {
  14975. import { Nullable } from "babylonjs/types";
  14976. import { Observable } from "babylonjs/Misc/observable";
  14977. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  14978. import { Scene } from "babylonjs/scene";
  14979. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14980. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  14981. import { Node } from "babylonjs/node";
  14982. import { Ray } from "babylonjs/Culling/ray";
  14983. import "babylonjs/Cameras/RigModes/webVRRigMode";
  14984. import "babylonjs/Engines/Extensions/engine.webVR";
  14985. /**
  14986. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14987. * IMPORTANT!! The data is right-hand data.
  14988. * @export
  14989. * @interface DevicePose
  14990. */
  14991. export interface DevicePose {
  14992. /**
  14993. * The position of the device, values in array are [x,y,z].
  14994. */
  14995. readonly position: Nullable<Float32Array>;
  14996. /**
  14997. * The linearVelocity of the device, values in array are [x,y,z].
  14998. */
  14999. readonly linearVelocity: Nullable<Float32Array>;
  15000. /**
  15001. * The linearAcceleration of the device, values in array are [x,y,z].
  15002. */
  15003. readonly linearAcceleration: Nullable<Float32Array>;
  15004. /**
  15005. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15006. */
  15007. readonly orientation: Nullable<Float32Array>;
  15008. /**
  15009. * The angularVelocity of the device, values in array are [x,y,z].
  15010. */
  15011. readonly angularVelocity: Nullable<Float32Array>;
  15012. /**
  15013. * The angularAcceleration of the device, values in array are [x,y,z].
  15014. */
  15015. readonly angularAcceleration: Nullable<Float32Array>;
  15016. }
  15017. /**
  15018. * Interface representing a pose controlled object in Babylon.
  15019. * A pose controlled object has both regular pose values as well as pose values
  15020. * from an external device such as a VR head mounted display
  15021. */
  15022. export interface PoseControlled {
  15023. /**
  15024. * The position of the object in babylon space.
  15025. */
  15026. position: Vector3;
  15027. /**
  15028. * The rotation quaternion of the object in babylon space.
  15029. */
  15030. rotationQuaternion: Quaternion;
  15031. /**
  15032. * The position of the device in babylon space.
  15033. */
  15034. devicePosition?: Vector3;
  15035. /**
  15036. * The rotation quaternion of the device in babylon space.
  15037. */
  15038. deviceRotationQuaternion: Quaternion;
  15039. /**
  15040. * The raw pose coming from the device.
  15041. */
  15042. rawPose: Nullable<DevicePose>;
  15043. /**
  15044. * The scale of the device to be used when translating from device space to babylon space.
  15045. */
  15046. deviceScaleFactor: number;
  15047. /**
  15048. * Updates the poseControlled values based on the input device pose.
  15049. * @param poseData the pose data to update the object with
  15050. */
  15051. updateFromDevice(poseData: DevicePose): void;
  15052. }
  15053. /**
  15054. * Set of options to customize the webVRCamera
  15055. */
  15056. export interface WebVROptions {
  15057. /**
  15058. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15059. */
  15060. trackPosition?: boolean;
  15061. /**
  15062. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15063. */
  15064. positionScale?: number;
  15065. /**
  15066. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15067. */
  15068. displayName?: string;
  15069. /**
  15070. * Should the native controller meshes be initialized. (default: true)
  15071. */
  15072. controllerMeshes?: boolean;
  15073. /**
  15074. * Creating a default HemiLight only on controllers. (default: true)
  15075. */
  15076. defaultLightingOnControllers?: boolean;
  15077. /**
  15078. * If you don't want to use the default VR button of the helper. (default: false)
  15079. */
  15080. useCustomVRButton?: boolean;
  15081. /**
  15082. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15083. */
  15084. customVRButton?: HTMLButtonElement;
  15085. /**
  15086. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15087. */
  15088. rayLength?: number;
  15089. /**
  15090. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15091. */
  15092. defaultHeight?: number;
  15093. /**
  15094. * If multiview should be used if availible (default: false)
  15095. */
  15096. useMultiview?: boolean;
  15097. }
  15098. /**
  15099. * This represents a WebVR camera.
  15100. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15101. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15102. */
  15103. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15104. private webVROptions;
  15105. /**
  15106. * @hidden
  15107. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15108. */
  15109. _vrDevice: any;
  15110. /**
  15111. * The rawPose of the vrDevice.
  15112. */
  15113. rawPose: Nullable<DevicePose>;
  15114. private _onVREnabled;
  15115. private _specsVersion;
  15116. private _attached;
  15117. private _frameData;
  15118. protected _descendants: Array<Node>;
  15119. private _deviceRoomPosition;
  15120. /** @hidden */
  15121. _deviceRoomRotationQuaternion: Quaternion;
  15122. private _standingMatrix;
  15123. /**
  15124. * Represents device position in babylon space.
  15125. */
  15126. devicePosition: Vector3;
  15127. /**
  15128. * Represents device rotation in babylon space.
  15129. */
  15130. deviceRotationQuaternion: Quaternion;
  15131. /**
  15132. * The scale of the device to be used when translating from device space to babylon space.
  15133. */
  15134. deviceScaleFactor: number;
  15135. private _deviceToWorld;
  15136. private _worldToDevice;
  15137. /**
  15138. * References to the webVR controllers for the vrDevice.
  15139. */
  15140. controllers: Array<WebVRController>;
  15141. /**
  15142. * Emits an event when a controller is attached.
  15143. */
  15144. onControllersAttachedObservable: Observable<WebVRController[]>;
  15145. /**
  15146. * Emits an event when a controller's mesh has been loaded;
  15147. */
  15148. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15149. /**
  15150. * Emits an event when the HMD's pose has been updated.
  15151. */
  15152. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15153. private _poseSet;
  15154. /**
  15155. * If the rig cameras be used as parent instead of this camera.
  15156. */
  15157. rigParenting: boolean;
  15158. private _lightOnControllers;
  15159. private _defaultHeight?;
  15160. /**
  15161. * Instantiates a WebVRFreeCamera.
  15162. * @param name The name of the WebVRFreeCamera
  15163. * @param position The starting anchor position for the camera
  15164. * @param scene The scene the camera belongs to
  15165. * @param webVROptions a set of customizable options for the webVRCamera
  15166. */
  15167. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15168. /**
  15169. * Gets the device distance from the ground in meters.
  15170. * @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.
  15171. */
  15172. deviceDistanceToRoomGround(): number;
  15173. /**
  15174. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15175. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15176. */
  15177. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15178. /**
  15179. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15180. * @returns A promise with a boolean set to if the standing matrix is supported.
  15181. */
  15182. useStandingMatrixAsync(): Promise<boolean>;
  15183. /**
  15184. * Disposes the camera
  15185. */
  15186. dispose(): void;
  15187. /**
  15188. * Gets a vrController by name.
  15189. * @param name The name of the controller to retreive
  15190. * @returns the controller matching the name specified or null if not found
  15191. */
  15192. getControllerByName(name: string): Nullable<WebVRController>;
  15193. private _leftController;
  15194. /**
  15195. * The controller corresponding to the users left hand.
  15196. */
  15197. readonly leftController: Nullable<WebVRController>;
  15198. private _rightController;
  15199. /**
  15200. * The controller corresponding to the users right hand.
  15201. */
  15202. readonly rightController: Nullable<WebVRController>;
  15203. /**
  15204. * Casts a ray forward from the vrCamera's gaze.
  15205. * @param length Length of the ray (default: 100)
  15206. * @returns the ray corresponding to the gaze
  15207. */
  15208. getForwardRay(length?: number): Ray;
  15209. /**
  15210. * @hidden
  15211. * Updates the camera based on device's frame data
  15212. */
  15213. _checkInputs(): void;
  15214. /**
  15215. * Updates the poseControlled values based on the input device pose.
  15216. * @param poseData Pose coming from the device
  15217. */
  15218. updateFromDevice(poseData: DevicePose): void;
  15219. private _htmlElementAttached;
  15220. private _detachIfAttached;
  15221. /**
  15222. * WebVR's attach control will start broadcasting frames to the device.
  15223. * Note that in certain browsers (chrome for example) this function must be called
  15224. * within a user-interaction callback. Example:
  15225. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15226. *
  15227. * @param element html element to attach the vrDevice to
  15228. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15229. */
  15230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15231. /**
  15232. * Detaches the camera from the html element and disables VR
  15233. *
  15234. * @param element html element to detach from
  15235. */
  15236. detachControl(element: HTMLElement): void;
  15237. /**
  15238. * @returns the name of this class
  15239. */
  15240. getClassName(): string;
  15241. /**
  15242. * Calls resetPose on the vrDisplay
  15243. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15244. */
  15245. resetToCurrentRotation(): void;
  15246. /**
  15247. * @hidden
  15248. * Updates the rig cameras (left and right eye)
  15249. */
  15250. _updateRigCameras(): void;
  15251. private _workingVector;
  15252. private _oneVector;
  15253. private _workingMatrix;
  15254. private updateCacheCalled;
  15255. private _correctPositionIfNotTrackPosition;
  15256. /**
  15257. * @hidden
  15258. * Updates the cached values of the camera
  15259. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15260. */
  15261. _updateCache(ignoreParentClass?: boolean): void;
  15262. /**
  15263. * @hidden
  15264. * Get current device position in babylon world
  15265. */
  15266. _computeDevicePosition(): void;
  15267. /**
  15268. * Updates the current device position and rotation in the babylon world
  15269. */
  15270. update(): void;
  15271. /**
  15272. * @hidden
  15273. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15274. * @returns an identity matrix
  15275. */
  15276. _getViewMatrix(): Matrix;
  15277. private _tmpMatrix;
  15278. /**
  15279. * This function is called by the two RIG cameras.
  15280. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15281. * @hidden
  15282. */
  15283. _getWebVRViewMatrix(): Matrix;
  15284. /** @hidden */
  15285. _getWebVRProjectionMatrix(): Matrix;
  15286. private _onGamepadConnectedObserver;
  15287. private _onGamepadDisconnectedObserver;
  15288. private _updateCacheWhenTrackingDisabledObserver;
  15289. /**
  15290. * Initializes the controllers and their meshes
  15291. */
  15292. initControllers(): void;
  15293. }
  15294. }
  15295. declare module "babylonjs/PostProcesses/postProcess" {
  15296. import { Nullable } from "babylonjs/types";
  15297. import { SmartArray } from "babylonjs/Misc/smartArray";
  15298. import { Observable } from "babylonjs/Misc/observable";
  15299. import { Vector2 } from "babylonjs/Maths/math.vector";
  15300. import { Camera } from "babylonjs/Cameras/camera";
  15301. import { Effect } from "babylonjs/Materials/effect";
  15302. import "babylonjs/Shaders/postprocess.vertex";
  15303. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15304. import { Engine } from "babylonjs/Engines/engine";
  15305. import { Color4 } from "babylonjs/Maths/math.color";
  15306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15307. /**
  15308. * Size options for a post process
  15309. */
  15310. export type PostProcessOptions = {
  15311. width: number;
  15312. height: number;
  15313. };
  15314. /**
  15315. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15316. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15317. */
  15318. export class PostProcess {
  15319. /** Name of the PostProcess. */
  15320. name: string;
  15321. /**
  15322. * Gets or sets the unique id of the post process
  15323. */
  15324. uniqueId: number;
  15325. /**
  15326. * Width of the texture to apply the post process on
  15327. */
  15328. width: number;
  15329. /**
  15330. * Height of the texture to apply the post process on
  15331. */
  15332. height: number;
  15333. /**
  15334. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15335. * @hidden
  15336. */
  15337. _outputTexture: Nullable<InternalTexture>;
  15338. /**
  15339. * Sampling mode used by the shader
  15340. * See https://doc.babylonjs.com/classes/3.1/texture
  15341. */
  15342. renderTargetSamplingMode: number;
  15343. /**
  15344. * Clear color to use when screen clearing
  15345. */
  15346. clearColor: Color4;
  15347. /**
  15348. * If the buffer needs to be cleared before applying the post process. (default: true)
  15349. * Should be set to false if shader will overwrite all previous pixels.
  15350. */
  15351. autoClear: boolean;
  15352. /**
  15353. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15354. */
  15355. alphaMode: number;
  15356. /**
  15357. * Sets the setAlphaBlendConstants of the babylon engine
  15358. */
  15359. alphaConstants: Color4;
  15360. /**
  15361. * Animations to be used for the post processing
  15362. */
  15363. animations: import("babylonjs/Animations/animation").Animation[];
  15364. /**
  15365. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15366. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15367. */
  15368. enablePixelPerfectMode: boolean;
  15369. /**
  15370. * Force the postprocess to be applied without taking in account viewport
  15371. */
  15372. forceFullscreenViewport: boolean;
  15373. /**
  15374. * List of inspectable custom properties (used by the Inspector)
  15375. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15376. */
  15377. inspectableCustomProperties: IInspectable[];
  15378. /**
  15379. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15380. *
  15381. * | Value | Type | Description |
  15382. * | ----- | ----------------------------------- | ----------- |
  15383. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15384. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15385. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15386. *
  15387. */
  15388. scaleMode: number;
  15389. /**
  15390. * Force textures to be a power of two (default: false)
  15391. */
  15392. alwaysForcePOT: boolean;
  15393. private _samples;
  15394. /**
  15395. * Number of sample textures (default: 1)
  15396. */
  15397. samples: number;
  15398. /**
  15399. * Modify the scale of the post process to be the same as the viewport (default: false)
  15400. */
  15401. adaptScaleToCurrentViewport: boolean;
  15402. private _camera;
  15403. private _scene;
  15404. private _engine;
  15405. private _options;
  15406. private _reusable;
  15407. private _textureType;
  15408. /**
  15409. * Smart array of input and output textures for the post process.
  15410. * @hidden
  15411. */
  15412. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15413. /**
  15414. * The index in _textures that corresponds to the output texture.
  15415. * @hidden
  15416. */
  15417. _currentRenderTextureInd: number;
  15418. private _effect;
  15419. private _samplers;
  15420. private _fragmentUrl;
  15421. private _vertexUrl;
  15422. private _parameters;
  15423. private _scaleRatio;
  15424. protected _indexParameters: any;
  15425. private _shareOutputWithPostProcess;
  15426. private _texelSize;
  15427. private _forcedOutputTexture;
  15428. /**
  15429. * Returns the fragment url or shader name used in the post process.
  15430. * @returns the fragment url or name in the shader store.
  15431. */
  15432. getEffectName(): string;
  15433. /**
  15434. * An event triggered when the postprocess is activated.
  15435. */
  15436. onActivateObservable: Observable<Camera>;
  15437. private _onActivateObserver;
  15438. /**
  15439. * A function that is added to the onActivateObservable
  15440. */
  15441. onActivate: Nullable<(camera: Camera) => void>;
  15442. /**
  15443. * An event triggered when the postprocess changes its size.
  15444. */
  15445. onSizeChangedObservable: Observable<PostProcess>;
  15446. private _onSizeChangedObserver;
  15447. /**
  15448. * A function that is added to the onSizeChangedObservable
  15449. */
  15450. onSizeChanged: (postProcess: PostProcess) => void;
  15451. /**
  15452. * An event triggered when the postprocess applies its effect.
  15453. */
  15454. onApplyObservable: Observable<Effect>;
  15455. private _onApplyObserver;
  15456. /**
  15457. * A function that is added to the onApplyObservable
  15458. */
  15459. onApply: (effect: Effect) => void;
  15460. /**
  15461. * An event triggered before rendering the postprocess
  15462. */
  15463. onBeforeRenderObservable: Observable<Effect>;
  15464. private _onBeforeRenderObserver;
  15465. /**
  15466. * A function that is added to the onBeforeRenderObservable
  15467. */
  15468. onBeforeRender: (effect: Effect) => void;
  15469. /**
  15470. * An event triggered after rendering the postprocess
  15471. */
  15472. onAfterRenderObservable: Observable<Effect>;
  15473. private _onAfterRenderObserver;
  15474. /**
  15475. * A function that is added to the onAfterRenderObservable
  15476. */
  15477. onAfterRender: (efect: Effect) => void;
  15478. /**
  15479. * 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
  15480. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15481. */
  15482. inputTexture: InternalTexture;
  15483. /**
  15484. * Gets the camera which post process is applied to.
  15485. * @returns The camera the post process is applied to.
  15486. */
  15487. getCamera(): Camera;
  15488. /**
  15489. * Gets the texel size of the postprocess.
  15490. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15491. */
  15492. readonly texelSize: Vector2;
  15493. /**
  15494. * Creates a new instance PostProcess
  15495. * @param name The name of the PostProcess.
  15496. * @param fragmentUrl The url of the fragment shader to be used.
  15497. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15498. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15499. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15500. * @param camera The camera to apply the render pass to.
  15501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15502. * @param engine The engine which the post process will be applied. (default: current engine)
  15503. * @param reusable If the post process can be reused on the same frame. (default: false)
  15504. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15505. * @param textureType Type of textures used when performing the post process. (default: 0)
  15506. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15507. * @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
  15508. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15509. */
  15510. constructor(
  15511. /** Name of the PostProcess. */
  15512. 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);
  15513. /**
  15514. * Gets a string idenfifying the name of the class
  15515. * @returns "PostProcess" string
  15516. */
  15517. getClassName(): string;
  15518. /**
  15519. * Gets the engine which this post process belongs to.
  15520. * @returns The engine the post process was enabled with.
  15521. */
  15522. getEngine(): Engine;
  15523. /**
  15524. * The effect that is created when initializing the post process.
  15525. * @returns The created effect corresponding the the postprocess.
  15526. */
  15527. getEffect(): Effect;
  15528. /**
  15529. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15530. * @param postProcess The post process to share the output with.
  15531. * @returns This post process.
  15532. */
  15533. shareOutputWith(postProcess: PostProcess): PostProcess;
  15534. /**
  15535. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15536. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15537. */
  15538. useOwnOutput(): void;
  15539. /**
  15540. * Updates the effect with the current post process compile time values and recompiles the shader.
  15541. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15542. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15543. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15544. * @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
  15545. * @param onCompiled Called when the shader has been compiled.
  15546. * @param onError Called if there is an error when compiling a shader.
  15547. */
  15548. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15549. /**
  15550. * The post process is reusable if it can be used multiple times within one frame.
  15551. * @returns If the post process is reusable
  15552. */
  15553. isReusable(): boolean;
  15554. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15555. markTextureDirty(): void;
  15556. /**
  15557. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15558. * 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.
  15559. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15560. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15561. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15562. * @returns The target texture that was bound to be written to.
  15563. */
  15564. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15565. /**
  15566. * If the post process is supported.
  15567. */
  15568. readonly isSupported: boolean;
  15569. /**
  15570. * The aspect ratio of the output texture.
  15571. */
  15572. readonly aspectRatio: number;
  15573. /**
  15574. * Get a value indicating if the post-process is ready to be used
  15575. * @returns true if the post-process is ready (shader is compiled)
  15576. */
  15577. isReady(): boolean;
  15578. /**
  15579. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15580. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15581. */
  15582. apply(): Nullable<Effect>;
  15583. private _disposeTextures;
  15584. /**
  15585. * Disposes the post process.
  15586. * @param camera The camera to dispose the post process on.
  15587. */
  15588. dispose(camera?: Camera): void;
  15589. }
  15590. }
  15591. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15592. /** @hidden */
  15593. export var kernelBlurVaryingDeclaration: {
  15594. name: string;
  15595. shader: string;
  15596. };
  15597. }
  15598. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15599. /** @hidden */
  15600. export var kernelBlurFragment: {
  15601. name: string;
  15602. shader: string;
  15603. };
  15604. }
  15605. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15606. /** @hidden */
  15607. export var kernelBlurFragment2: {
  15608. name: string;
  15609. shader: string;
  15610. };
  15611. }
  15612. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15613. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15614. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15615. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15616. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15617. /** @hidden */
  15618. export var kernelBlurPixelShader: {
  15619. name: string;
  15620. shader: string;
  15621. };
  15622. }
  15623. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15624. /** @hidden */
  15625. export var kernelBlurVertex: {
  15626. name: string;
  15627. shader: string;
  15628. };
  15629. }
  15630. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15631. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15632. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15633. /** @hidden */
  15634. export var kernelBlurVertexShader: {
  15635. name: string;
  15636. shader: string;
  15637. };
  15638. }
  15639. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15640. import { Vector2 } from "babylonjs/Maths/math.vector";
  15641. import { Nullable } from "babylonjs/types";
  15642. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15643. import { Camera } from "babylonjs/Cameras/camera";
  15644. import { Effect } from "babylonjs/Materials/effect";
  15645. import { Engine } from "babylonjs/Engines/engine";
  15646. import "babylonjs/Shaders/kernelBlur.fragment";
  15647. import "babylonjs/Shaders/kernelBlur.vertex";
  15648. /**
  15649. * The Blur Post Process which blurs an image based on a kernel and direction.
  15650. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15651. */
  15652. export class BlurPostProcess extends PostProcess {
  15653. /** The direction in which to blur the image. */
  15654. direction: Vector2;
  15655. private blockCompilation;
  15656. protected _kernel: number;
  15657. protected _idealKernel: number;
  15658. protected _packedFloat: boolean;
  15659. private _staticDefines;
  15660. /**
  15661. * Sets the length in pixels of the blur sample region
  15662. */
  15663. /**
  15664. * Gets the length in pixels of the blur sample region
  15665. */
  15666. kernel: number;
  15667. /**
  15668. * Sets wether or not the blur needs to unpack/repack floats
  15669. */
  15670. /**
  15671. * Gets wether or not the blur is unpacking/repacking floats
  15672. */
  15673. packedFloat: boolean;
  15674. /**
  15675. * Creates a new instance BlurPostProcess
  15676. * @param name The name of the effect.
  15677. * @param direction The direction in which to blur the image.
  15678. * @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.
  15679. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15680. * @param camera The camera to apply the render pass to.
  15681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15682. * @param engine The engine which the post process will be applied. (default: current engine)
  15683. * @param reusable If the post process can be reused on the same frame. (default: false)
  15684. * @param textureType Type of textures used when performing the post process. (default: 0)
  15685. * @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)
  15686. */
  15687. constructor(name: string,
  15688. /** The direction in which to blur the image. */
  15689. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15690. /**
  15691. * Updates the effect with the current post process compile time values and recompiles the shader.
  15692. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15693. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15694. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15695. * @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
  15696. * @param onCompiled Called when the shader has been compiled.
  15697. * @param onError Called if there is an error when compiling a shader.
  15698. */
  15699. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15700. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15701. /**
  15702. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15703. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15704. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15705. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15706. * The gaps between physical kernels are compensated for in the weighting of the samples
  15707. * @param idealKernel Ideal blur kernel.
  15708. * @return Nearest best kernel.
  15709. */
  15710. protected _nearestBestKernel(idealKernel: number): number;
  15711. /**
  15712. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15713. * @param x The point on the Gaussian distribution to sample.
  15714. * @return the value of the Gaussian function at x.
  15715. */
  15716. protected _gaussianWeight(x: number): number;
  15717. /**
  15718. * Generates a string that can be used as a floating point number in GLSL.
  15719. * @param x Value to print.
  15720. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15721. * @return GLSL float string.
  15722. */
  15723. protected _glslFloat(x: number, decimalFigures?: number): string;
  15724. }
  15725. }
  15726. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15727. import { Scene } from "babylonjs/scene";
  15728. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15729. import { Plane } from "babylonjs/Maths/math.plane";
  15730. /**
  15731. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15732. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15733. * You can then easily use it as a reflectionTexture on a flat surface.
  15734. * In case the surface is not a plane, please consider relying on reflection probes.
  15735. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15736. */
  15737. export class MirrorTexture extends RenderTargetTexture {
  15738. private scene;
  15739. /**
  15740. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15741. * 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.
  15742. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15743. */
  15744. mirrorPlane: Plane;
  15745. /**
  15746. * Define the blur ratio used to blur the reflection if needed.
  15747. */
  15748. blurRatio: number;
  15749. /**
  15750. * Define the adaptive blur kernel used to blur the reflection if needed.
  15751. * This will autocompute the closest best match for the `blurKernel`
  15752. */
  15753. adaptiveBlurKernel: number;
  15754. /**
  15755. * Define the blur kernel used to blur the reflection if needed.
  15756. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15757. */
  15758. blurKernel: number;
  15759. /**
  15760. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15761. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15762. */
  15763. blurKernelX: number;
  15764. /**
  15765. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15766. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15767. */
  15768. blurKernelY: number;
  15769. private _autoComputeBlurKernel;
  15770. protected _onRatioRescale(): void;
  15771. private _updateGammaSpace;
  15772. private _imageProcessingConfigChangeObserver;
  15773. private _transformMatrix;
  15774. private _mirrorMatrix;
  15775. private _savedViewMatrix;
  15776. private _blurX;
  15777. private _blurY;
  15778. private _adaptiveBlurKernel;
  15779. private _blurKernelX;
  15780. private _blurKernelY;
  15781. private _blurRatio;
  15782. /**
  15783. * Instantiates a Mirror Texture.
  15784. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15785. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15786. * You can then easily use it as a reflectionTexture on a flat surface.
  15787. * In case the surface is not a plane, please consider relying on reflection probes.
  15788. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15789. * @param name
  15790. * @param size
  15791. * @param scene
  15792. * @param generateMipMaps
  15793. * @param type
  15794. * @param samplingMode
  15795. * @param generateDepthBuffer
  15796. */
  15797. constructor(name: string, size: number | {
  15798. width: number;
  15799. height: number;
  15800. } | {
  15801. ratio: number;
  15802. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15803. private _preparePostProcesses;
  15804. /**
  15805. * Clone the mirror texture.
  15806. * @returns the cloned texture
  15807. */
  15808. clone(): MirrorTexture;
  15809. /**
  15810. * Serialize the texture to a JSON representation you could use in Parse later on
  15811. * @returns the serialized JSON representation
  15812. */
  15813. serialize(): any;
  15814. /**
  15815. * Dispose the texture and release its associated resources.
  15816. */
  15817. dispose(): void;
  15818. }
  15819. }
  15820. declare module "babylonjs/Materials/Textures/texture" {
  15821. import { Observable } from "babylonjs/Misc/observable";
  15822. import { Nullable } from "babylonjs/types";
  15823. import { Scene } from "babylonjs/scene";
  15824. import { Matrix } from "babylonjs/Maths/math.vector";
  15825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15826. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15827. import { Engine } from "babylonjs/Engines/engine";
  15828. /**
  15829. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15830. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15831. */
  15832. export class Texture extends BaseTexture {
  15833. /** @hidden */
  15834. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15835. /** @hidden */
  15836. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15837. /** @hidden */
  15838. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15839. /** nearest is mag = nearest and min = nearest and mip = linear */
  15840. static readonly NEAREST_SAMPLINGMODE: number;
  15841. /** nearest is mag = nearest and min = nearest and mip = linear */
  15842. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15843. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15844. static readonly BILINEAR_SAMPLINGMODE: number;
  15845. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15846. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15847. /** Trilinear is mag = linear and min = linear and mip = linear */
  15848. static readonly TRILINEAR_SAMPLINGMODE: number;
  15849. /** Trilinear is mag = linear and min = linear and mip = linear */
  15850. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15851. /** mag = nearest and min = nearest and mip = nearest */
  15852. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15853. /** mag = nearest and min = linear and mip = nearest */
  15854. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15855. /** mag = nearest and min = linear and mip = linear */
  15856. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15857. /** mag = nearest and min = linear and mip = none */
  15858. static readonly NEAREST_LINEAR: number;
  15859. /** mag = nearest and min = nearest and mip = none */
  15860. static readonly NEAREST_NEAREST: number;
  15861. /** mag = linear and min = nearest and mip = nearest */
  15862. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15863. /** mag = linear and min = nearest and mip = linear */
  15864. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15865. /** mag = linear and min = linear and mip = none */
  15866. static readonly LINEAR_LINEAR: number;
  15867. /** mag = linear and min = nearest and mip = none */
  15868. static readonly LINEAR_NEAREST: number;
  15869. /** Explicit coordinates mode */
  15870. static readonly EXPLICIT_MODE: number;
  15871. /** Spherical coordinates mode */
  15872. static readonly SPHERICAL_MODE: number;
  15873. /** Planar coordinates mode */
  15874. static readonly PLANAR_MODE: number;
  15875. /** Cubic coordinates mode */
  15876. static readonly CUBIC_MODE: number;
  15877. /** Projection coordinates mode */
  15878. static readonly PROJECTION_MODE: number;
  15879. /** Inverse Cubic coordinates mode */
  15880. static readonly SKYBOX_MODE: number;
  15881. /** Inverse Cubic coordinates mode */
  15882. static readonly INVCUBIC_MODE: number;
  15883. /** Equirectangular coordinates mode */
  15884. static readonly EQUIRECTANGULAR_MODE: number;
  15885. /** Equirectangular Fixed coordinates mode */
  15886. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15887. /** Equirectangular Fixed Mirrored coordinates mode */
  15888. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15889. /** Texture is not repeating outside of 0..1 UVs */
  15890. static readonly CLAMP_ADDRESSMODE: number;
  15891. /** Texture is repeating outside of 0..1 UVs */
  15892. static readonly WRAP_ADDRESSMODE: number;
  15893. /** Texture is repeating and mirrored */
  15894. static readonly MIRROR_ADDRESSMODE: number;
  15895. /**
  15896. * 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
  15897. */
  15898. static UseSerializedUrlIfAny: boolean;
  15899. /**
  15900. * Define the url of the texture.
  15901. */
  15902. url: Nullable<string>;
  15903. /**
  15904. * Define an offset on the texture to offset the u coordinates of the UVs
  15905. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15906. */
  15907. uOffset: number;
  15908. /**
  15909. * Define an offset on the texture to offset the v coordinates of the UVs
  15910. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15911. */
  15912. vOffset: number;
  15913. /**
  15914. * Define an offset on the texture to scale the u coordinates of the UVs
  15915. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15916. */
  15917. uScale: number;
  15918. /**
  15919. * Define an offset on the texture to scale the v coordinates of the UVs
  15920. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15921. */
  15922. vScale: number;
  15923. /**
  15924. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15925. * @see http://doc.babylonjs.com/how_to/more_materials
  15926. */
  15927. uAng: number;
  15928. /**
  15929. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15930. * @see http://doc.babylonjs.com/how_to/more_materials
  15931. */
  15932. vAng: number;
  15933. /**
  15934. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15935. * @see http://doc.babylonjs.com/how_to/more_materials
  15936. */
  15937. wAng: number;
  15938. /**
  15939. * Defines the center of rotation (U)
  15940. */
  15941. uRotationCenter: number;
  15942. /**
  15943. * Defines the center of rotation (V)
  15944. */
  15945. vRotationCenter: number;
  15946. /**
  15947. * Defines the center of rotation (W)
  15948. */
  15949. wRotationCenter: number;
  15950. /**
  15951. * Are mip maps generated for this texture or not.
  15952. */
  15953. readonly noMipmap: boolean;
  15954. /**
  15955. * List of inspectable custom properties (used by the Inspector)
  15956. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15957. */
  15958. inspectableCustomProperties: Nullable<IInspectable[]>;
  15959. private _noMipmap;
  15960. /** @hidden */
  15961. _invertY: boolean;
  15962. private _rowGenerationMatrix;
  15963. private _cachedTextureMatrix;
  15964. private _projectionModeMatrix;
  15965. private _t0;
  15966. private _t1;
  15967. private _t2;
  15968. private _cachedUOffset;
  15969. private _cachedVOffset;
  15970. private _cachedUScale;
  15971. private _cachedVScale;
  15972. private _cachedUAng;
  15973. private _cachedVAng;
  15974. private _cachedWAng;
  15975. private _cachedProjectionMatrixId;
  15976. private _cachedCoordinatesMode;
  15977. /** @hidden */
  15978. protected _initialSamplingMode: number;
  15979. /** @hidden */
  15980. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15981. private _deleteBuffer;
  15982. protected _format: Nullable<number>;
  15983. private _delayedOnLoad;
  15984. private _delayedOnError;
  15985. /**
  15986. * Observable triggered once the texture has been loaded.
  15987. */
  15988. onLoadObservable: Observable<Texture>;
  15989. protected _isBlocking: boolean;
  15990. /**
  15991. * Is the texture preventing material to render while loading.
  15992. * If false, a default texture will be used instead of the loading one during the preparation step.
  15993. */
  15994. isBlocking: boolean;
  15995. /**
  15996. * Get the current sampling mode associated with the texture.
  15997. */
  15998. readonly samplingMode: number;
  15999. /**
  16000. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16001. */
  16002. readonly invertY: boolean;
  16003. /**
  16004. * Instantiates a new texture.
  16005. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16006. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16007. * @param url define the url of the picture to load as a texture
  16008. * @param scene define the scene or engine the texture will belong to
  16009. * @param noMipmap define if the texture will require mip maps or not
  16010. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16011. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16012. * @param onLoad define a callback triggered when the texture has been loaded
  16013. * @param onError define a callback triggered when an error occurred during the loading session
  16014. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16015. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16016. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16017. */
  16018. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16019. /**
  16020. * Update the url (and optional buffer) of this texture if url was null during construction.
  16021. * @param url the url of the texture
  16022. * @param buffer the buffer of the texture (defaults to null)
  16023. * @param onLoad callback called when the texture is loaded (defaults to null)
  16024. */
  16025. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16026. /**
  16027. * Finish the loading sequence of a texture flagged as delayed load.
  16028. * @hidden
  16029. */
  16030. delayLoad(): void;
  16031. private _prepareRowForTextureGeneration;
  16032. /**
  16033. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16034. * @returns the transform matrix of the texture.
  16035. */
  16036. getTextureMatrix(): Matrix;
  16037. /**
  16038. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16039. * @returns The reflection texture transform
  16040. */
  16041. getReflectionTextureMatrix(): Matrix;
  16042. /**
  16043. * Clones the texture.
  16044. * @returns the cloned texture
  16045. */
  16046. clone(): Texture;
  16047. /**
  16048. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16049. * @returns The JSON representation of the texture
  16050. */
  16051. serialize(): any;
  16052. /**
  16053. * Get the current class name of the texture useful for serialization or dynamic coding.
  16054. * @returns "Texture"
  16055. */
  16056. getClassName(): string;
  16057. /**
  16058. * Dispose the texture and release its associated resources.
  16059. */
  16060. dispose(): void;
  16061. /**
  16062. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16063. * @param parsedTexture Define the JSON representation of the texture
  16064. * @param scene Define the scene the parsed texture should be instantiated in
  16065. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16066. * @returns The parsed texture if successful
  16067. */
  16068. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16069. /**
  16070. * Creates a texture from its base 64 representation.
  16071. * @param data Define the base64 payload without the data: prefix
  16072. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16073. * @param scene Define the scene the texture should belong to
  16074. * @param noMipmap Forces the texture to not create mip map information if true
  16075. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16076. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16077. * @param onLoad define a callback triggered when the texture has been loaded
  16078. * @param onError define a callback triggered when an error occurred during the loading session
  16079. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16080. * @returns the created texture
  16081. */
  16082. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16083. /**
  16084. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16085. * @param data Define the base64 payload without the data: prefix
  16086. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16087. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16088. * @param scene Define the scene the texture should belong to
  16089. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16090. * @param noMipmap Forces the texture to not create mip map information if true
  16091. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16092. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16093. * @param onLoad define a callback triggered when the texture has been loaded
  16094. * @param onError define a callback triggered when an error occurred during the loading session
  16095. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16096. * @returns the created texture
  16097. */
  16098. 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;
  16099. }
  16100. }
  16101. declare module "babylonjs/PostProcesses/postProcessManager" {
  16102. import { Nullable } from "babylonjs/types";
  16103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16104. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16105. import { Scene } from "babylonjs/scene";
  16106. /**
  16107. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16108. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16109. */
  16110. export class PostProcessManager {
  16111. private _scene;
  16112. private _indexBuffer;
  16113. private _vertexBuffers;
  16114. /**
  16115. * Creates a new instance PostProcess
  16116. * @param scene The scene that the post process is associated with.
  16117. */
  16118. constructor(scene: Scene);
  16119. private _prepareBuffers;
  16120. private _buildIndexBuffer;
  16121. /**
  16122. * Rebuilds the vertex buffers of the manager.
  16123. * @hidden
  16124. */
  16125. _rebuild(): void;
  16126. /**
  16127. * Prepares a frame to be run through a post process.
  16128. * @param sourceTexture The input texture to the post procesess. (default: null)
  16129. * @param postProcesses An array of post processes to be run. (default: null)
  16130. * @returns True if the post processes were able to be run.
  16131. * @hidden
  16132. */
  16133. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16134. /**
  16135. * Manually render a set of post processes to a texture.
  16136. * @param postProcesses An array of post processes to be run.
  16137. * @param targetTexture The target texture to render to.
  16138. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16139. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16140. * @param lodLevel defines which lod of the texture to render to
  16141. */
  16142. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16143. /**
  16144. * Finalize the result of the output of the postprocesses.
  16145. * @param doNotPresent If true the result will not be displayed to the screen.
  16146. * @param targetTexture The target texture to render to.
  16147. * @param faceIndex The index of the face to bind the target texture to.
  16148. * @param postProcesses The array of post processes to render.
  16149. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16150. * @hidden
  16151. */
  16152. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16153. /**
  16154. * Disposes of the post process manager.
  16155. */
  16156. dispose(): void;
  16157. }
  16158. }
  16159. declare module "babylonjs/Misc/gradients" {
  16160. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16161. /** Interface used by value gradients (color, factor, ...) */
  16162. export interface IValueGradient {
  16163. /**
  16164. * Gets or sets the gradient value (between 0 and 1)
  16165. */
  16166. gradient: number;
  16167. }
  16168. /** Class used to store color4 gradient */
  16169. export class ColorGradient implements IValueGradient {
  16170. /**
  16171. * Gets or sets the gradient value (between 0 and 1)
  16172. */
  16173. gradient: number;
  16174. /**
  16175. * Gets or sets first associated color
  16176. */
  16177. color1: Color4;
  16178. /**
  16179. * Gets or sets second associated color
  16180. */
  16181. color2?: Color4;
  16182. /**
  16183. * Will get a color picked randomly between color1 and color2.
  16184. * If color2 is undefined then color1 will be used
  16185. * @param result defines the target Color4 to store the result in
  16186. */
  16187. getColorToRef(result: Color4): void;
  16188. }
  16189. /** Class used to store color 3 gradient */
  16190. export class Color3Gradient implements IValueGradient {
  16191. /**
  16192. * Gets or sets the gradient value (between 0 and 1)
  16193. */
  16194. gradient: number;
  16195. /**
  16196. * Gets or sets the associated color
  16197. */
  16198. color: Color3;
  16199. }
  16200. /** Class used to store factor gradient */
  16201. export class FactorGradient implements IValueGradient {
  16202. /**
  16203. * Gets or sets the gradient value (between 0 and 1)
  16204. */
  16205. gradient: number;
  16206. /**
  16207. * Gets or sets first associated factor
  16208. */
  16209. factor1: number;
  16210. /**
  16211. * Gets or sets second associated factor
  16212. */
  16213. factor2?: number;
  16214. /**
  16215. * Will get a number picked randomly between factor1 and factor2.
  16216. * If factor2 is undefined then factor1 will be used
  16217. * @returns the picked number
  16218. */
  16219. getFactor(): number;
  16220. }
  16221. /**
  16222. * Helper used to simplify some generic gradient tasks
  16223. */
  16224. export class GradientHelper {
  16225. /**
  16226. * Gets the current gradient from an array of IValueGradient
  16227. * @param ratio defines the current ratio to get
  16228. * @param gradients defines the array of IValueGradient
  16229. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16230. */
  16231. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16232. }
  16233. }
  16234. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16235. import { Scene } from "babylonjs/scene";
  16236. import { ISceneComponent } from "babylonjs/sceneComponent";
  16237. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16238. module "babylonjs/abstractScene" {
  16239. interface AbstractScene {
  16240. /**
  16241. * The list of procedural textures added to the scene
  16242. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16243. */
  16244. proceduralTextures: Array<ProceduralTexture>;
  16245. }
  16246. }
  16247. /**
  16248. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16249. * in a given scene.
  16250. */
  16251. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16252. /**
  16253. * The component name helpfull to identify the component in the list of scene components.
  16254. */
  16255. readonly name: string;
  16256. /**
  16257. * The scene the component belongs to.
  16258. */
  16259. scene: Scene;
  16260. /**
  16261. * Creates a new instance of the component for the given scene
  16262. * @param scene Defines the scene to register the component in
  16263. */
  16264. constructor(scene: Scene);
  16265. /**
  16266. * Registers the component in a given scene
  16267. */
  16268. register(): void;
  16269. /**
  16270. * Rebuilds the elements related to this component in case of
  16271. * context lost for instance.
  16272. */
  16273. rebuild(): void;
  16274. /**
  16275. * Disposes the component and the associated ressources.
  16276. */
  16277. dispose(): void;
  16278. private _beforeClear;
  16279. }
  16280. }
  16281. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16282. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16283. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16284. module "babylonjs/Engines/engine" {
  16285. interface Engine {
  16286. /**
  16287. * Creates a new render target cube texture
  16288. * @param size defines the size of the texture
  16289. * @param options defines the options used to create the texture
  16290. * @returns a new render target cube texture stored in an InternalTexture
  16291. */
  16292. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16293. }
  16294. }
  16295. }
  16296. declare module "babylonjs/Shaders/procedural.vertex" {
  16297. /** @hidden */
  16298. export var proceduralVertexShader: {
  16299. name: string;
  16300. shader: string;
  16301. };
  16302. }
  16303. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16304. import { Observable } from "babylonjs/Misc/observable";
  16305. import { Nullable } from "babylonjs/types";
  16306. import { Scene } from "babylonjs/scene";
  16307. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16308. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16309. import { Effect } from "babylonjs/Materials/effect";
  16310. import { Texture } from "babylonjs/Materials/Textures/texture";
  16311. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16312. import "babylonjs/Shaders/procedural.vertex";
  16313. /**
  16314. * 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.
  16315. * This is the base class of any Procedural texture and contains most of the shareable code.
  16316. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16317. */
  16318. export class ProceduralTexture extends Texture {
  16319. isCube: boolean;
  16320. /**
  16321. * Define if the texture is enabled or not (disabled texture will not render)
  16322. */
  16323. isEnabled: boolean;
  16324. /**
  16325. * Define if the texture must be cleared before rendering (default is true)
  16326. */
  16327. autoClear: boolean;
  16328. /**
  16329. * Callback called when the texture is generated
  16330. */
  16331. onGenerated: () => void;
  16332. /**
  16333. * Event raised when the texture is generated
  16334. */
  16335. onGeneratedObservable: Observable<ProceduralTexture>;
  16336. /** @hidden */
  16337. _generateMipMaps: boolean;
  16338. /** @hidden **/
  16339. _effect: Effect;
  16340. /** @hidden */
  16341. _textures: {
  16342. [key: string]: Texture;
  16343. };
  16344. private _size;
  16345. private _currentRefreshId;
  16346. private _refreshRate;
  16347. private _vertexBuffers;
  16348. private _indexBuffer;
  16349. private _uniforms;
  16350. private _samplers;
  16351. private _fragment;
  16352. private _floats;
  16353. private _ints;
  16354. private _floatsArrays;
  16355. private _colors3;
  16356. private _colors4;
  16357. private _vectors2;
  16358. private _vectors3;
  16359. private _matrices;
  16360. private _fallbackTexture;
  16361. private _fallbackTextureUsed;
  16362. private _engine;
  16363. private _cachedDefines;
  16364. private _contentUpdateId;
  16365. private _contentData;
  16366. /**
  16367. * Instantiates a new procedural texture.
  16368. * 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.
  16369. * This is the base class of any Procedural texture and contains most of the shareable code.
  16370. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16371. * @param name Define the name of the texture
  16372. * @param size Define the size of the texture to create
  16373. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16374. * @param scene Define the scene the texture belongs to
  16375. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16376. * @param generateMipMaps Define if the texture should creates mip maps or not
  16377. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16378. */
  16379. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16380. /**
  16381. * The effect that is created when initializing the post process.
  16382. * @returns The created effect corresponding the the postprocess.
  16383. */
  16384. getEffect(): Effect;
  16385. /**
  16386. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16387. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16388. */
  16389. getContent(): Nullable<ArrayBufferView>;
  16390. private _createIndexBuffer;
  16391. /** @hidden */
  16392. _rebuild(): void;
  16393. /**
  16394. * Resets the texture in order to recreate its associated resources.
  16395. * This can be called in case of context loss
  16396. */
  16397. reset(): void;
  16398. protected _getDefines(): string;
  16399. /**
  16400. * Is the texture ready to be used ? (rendered at least once)
  16401. * @returns true if ready, otherwise, false.
  16402. */
  16403. isReady(): boolean;
  16404. /**
  16405. * Resets the refresh counter of the texture and start bak from scratch.
  16406. * Could be useful to regenerate the texture if it is setup to render only once.
  16407. */
  16408. resetRefreshCounter(): void;
  16409. /**
  16410. * Set the fragment shader to use in order to render the texture.
  16411. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16412. */
  16413. setFragment(fragment: any): void;
  16414. /**
  16415. * Define the refresh rate of the texture or the rendering frequency.
  16416. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16417. */
  16418. refreshRate: number;
  16419. /** @hidden */
  16420. _shouldRender(): boolean;
  16421. /**
  16422. * Get the size the texture is rendering at.
  16423. * @returns the size (texture is always squared)
  16424. */
  16425. getRenderSize(): number;
  16426. /**
  16427. * Resize the texture to new value.
  16428. * @param size Define the new size the texture should have
  16429. * @param generateMipMaps Define whether the new texture should create mip maps
  16430. */
  16431. resize(size: number, generateMipMaps: boolean): void;
  16432. private _checkUniform;
  16433. /**
  16434. * Set a texture in the shader program used to render.
  16435. * @param name Define the name of the uniform samplers as defined in the shader
  16436. * @param texture Define the texture to bind to this sampler
  16437. * @return the texture itself allowing "fluent" like uniform updates
  16438. */
  16439. setTexture(name: string, texture: Texture): ProceduralTexture;
  16440. /**
  16441. * Set a float in the shader.
  16442. * @param name Define the name of the uniform as defined in the shader
  16443. * @param value Define the value to give to the uniform
  16444. * @return the texture itself allowing "fluent" like uniform updates
  16445. */
  16446. setFloat(name: string, value: number): ProceduralTexture;
  16447. /**
  16448. * Set a int in the shader.
  16449. * @param name Define the name of the uniform as defined in the shader
  16450. * @param value Define the value to give to the uniform
  16451. * @return the texture itself allowing "fluent" like uniform updates
  16452. */
  16453. setInt(name: string, value: number): ProceduralTexture;
  16454. /**
  16455. * Set an array of floats in the shader.
  16456. * @param name Define the name of the uniform as defined in the shader
  16457. * @param value Define the value to give to the uniform
  16458. * @return the texture itself allowing "fluent" like uniform updates
  16459. */
  16460. setFloats(name: string, value: number[]): ProceduralTexture;
  16461. /**
  16462. * Set a vec3 in the shader from a Color3.
  16463. * @param name Define the name of the uniform as defined in the shader
  16464. * @param value Define the value to give to the uniform
  16465. * @return the texture itself allowing "fluent" like uniform updates
  16466. */
  16467. setColor3(name: string, value: Color3): ProceduralTexture;
  16468. /**
  16469. * Set a vec4 in the shader from a Color4.
  16470. * @param name Define the name of the uniform as defined in the shader
  16471. * @param value Define the value to give to the uniform
  16472. * @return the texture itself allowing "fluent" like uniform updates
  16473. */
  16474. setColor4(name: string, value: Color4): ProceduralTexture;
  16475. /**
  16476. * Set a vec2 in the shader from a Vector2.
  16477. * @param name Define the name of the uniform as defined in the shader
  16478. * @param value Define the value to give to the uniform
  16479. * @return the texture itself allowing "fluent" like uniform updates
  16480. */
  16481. setVector2(name: string, value: Vector2): ProceduralTexture;
  16482. /**
  16483. * Set a vec3 in the shader from a Vector3.
  16484. * @param name Define the name of the uniform as defined in the shader
  16485. * @param value Define the value to give to the uniform
  16486. * @return the texture itself allowing "fluent" like uniform updates
  16487. */
  16488. setVector3(name: string, value: Vector3): ProceduralTexture;
  16489. /**
  16490. * Set a mat4 in the shader from a MAtrix.
  16491. * @param name Define the name of the uniform as defined in the shader
  16492. * @param value Define the value to give to the uniform
  16493. * @return the texture itself allowing "fluent" like uniform updates
  16494. */
  16495. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16496. /**
  16497. * Render the texture to its associated render target.
  16498. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16499. */
  16500. render(useCameraPostProcess?: boolean): void;
  16501. /**
  16502. * Clone the texture.
  16503. * @returns the cloned texture
  16504. */
  16505. clone(): ProceduralTexture;
  16506. /**
  16507. * Dispose the texture and release its asoociated resources.
  16508. */
  16509. dispose(): void;
  16510. }
  16511. }
  16512. declare module "babylonjs/Particles/baseParticleSystem" {
  16513. import { Nullable } from "babylonjs/types";
  16514. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16516. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16517. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16518. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16519. import { Scene } from "babylonjs/scene";
  16520. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16521. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16522. import { Texture } from "babylonjs/Materials/Textures/texture";
  16523. import { Color4 } from "babylonjs/Maths/math.color";
  16524. import { Animation } from "babylonjs/Animations/animation";
  16525. /**
  16526. * This represents the base class for particle system in Babylon.
  16527. * 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.
  16528. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16529. * @example https://doc.babylonjs.com/babylon101/particles
  16530. */
  16531. export class BaseParticleSystem {
  16532. /**
  16533. * Source color is added to the destination color without alpha affecting the result
  16534. */
  16535. static BLENDMODE_ONEONE: number;
  16536. /**
  16537. * Blend current color and particle color using particle’s alpha
  16538. */
  16539. static BLENDMODE_STANDARD: number;
  16540. /**
  16541. * Add current color and particle color multiplied by particle’s alpha
  16542. */
  16543. static BLENDMODE_ADD: number;
  16544. /**
  16545. * Multiply current color with particle color
  16546. */
  16547. static BLENDMODE_MULTIPLY: number;
  16548. /**
  16549. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16550. */
  16551. static BLENDMODE_MULTIPLYADD: number;
  16552. /**
  16553. * List of animations used by the particle system.
  16554. */
  16555. animations: Animation[];
  16556. /**
  16557. * The id of the Particle system.
  16558. */
  16559. id: string;
  16560. /**
  16561. * The friendly name of the Particle system.
  16562. */
  16563. name: string;
  16564. /**
  16565. * The rendering group used by the Particle system to chose when to render.
  16566. */
  16567. renderingGroupId: number;
  16568. /**
  16569. * The emitter represents the Mesh or position we are attaching the particle system to.
  16570. */
  16571. emitter: Nullable<AbstractMesh | Vector3>;
  16572. /**
  16573. * The maximum number of particles to emit per frame
  16574. */
  16575. emitRate: number;
  16576. /**
  16577. * If you want to launch only a few particles at once, that can be done, as well.
  16578. */
  16579. manualEmitCount: number;
  16580. /**
  16581. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16582. */
  16583. updateSpeed: number;
  16584. /**
  16585. * The amount of time the particle system is running (depends of the overall update speed).
  16586. */
  16587. targetStopDuration: number;
  16588. /**
  16589. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16590. */
  16591. disposeOnStop: boolean;
  16592. /**
  16593. * Minimum power of emitting particles.
  16594. */
  16595. minEmitPower: number;
  16596. /**
  16597. * Maximum power of emitting particles.
  16598. */
  16599. maxEmitPower: number;
  16600. /**
  16601. * Minimum life time of emitting particles.
  16602. */
  16603. minLifeTime: number;
  16604. /**
  16605. * Maximum life time of emitting particles.
  16606. */
  16607. maxLifeTime: number;
  16608. /**
  16609. * Minimum Size of emitting particles.
  16610. */
  16611. minSize: number;
  16612. /**
  16613. * Maximum Size of emitting particles.
  16614. */
  16615. maxSize: number;
  16616. /**
  16617. * Minimum scale of emitting particles on X axis.
  16618. */
  16619. minScaleX: number;
  16620. /**
  16621. * Maximum scale of emitting particles on X axis.
  16622. */
  16623. maxScaleX: number;
  16624. /**
  16625. * Minimum scale of emitting particles on Y axis.
  16626. */
  16627. minScaleY: number;
  16628. /**
  16629. * Maximum scale of emitting particles on Y axis.
  16630. */
  16631. maxScaleY: number;
  16632. /**
  16633. * Gets or sets the minimal initial rotation in radians.
  16634. */
  16635. minInitialRotation: number;
  16636. /**
  16637. * Gets or sets the maximal initial rotation in radians.
  16638. */
  16639. maxInitialRotation: number;
  16640. /**
  16641. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16642. */
  16643. minAngularSpeed: number;
  16644. /**
  16645. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16646. */
  16647. maxAngularSpeed: number;
  16648. /**
  16649. * The texture used to render each particle. (this can be a spritesheet)
  16650. */
  16651. particleTexture: Nullable<Texture>;
  16652. /**
  16653. * The layer mask we are rendering the particles through.
  16654. */
  16655. layerMask: number;
  16656. /**
  16657. * This can help using your own shader to render the particle system.
  16658. * The according effect will be created
  16659. */
  16660. customShader: any;
  16661. /**
  16662. * By default particle system starts as soon as they are created. This prevents the
  16663. * automatic start to happen and let you decide when to start emitting particles.
  16664. */
  16665. preventAutoStart: boolean;
  16666. private _noiseTexture;
  16667. /**
  16668. * Gets or sets a texture used to add random noise to particle positions
  16669. */
  16670. noiseTexture: Nullable<ProceduralTexture>;
  16671. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16672. noiseStrength: Vector3;
  16673. /**
  16674. * Callback triggered when the particle animation is ending.
  16675. */
  16676. onAnimationEnd: Nullable<() => void>;
  16677. /**
  16678. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16679. */
  16680. blendMode: number;
  16681. /**
  16682. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16683. * to override the particles.
  16684. */
  16685. forceDepthWrite: boolean;
  16686. /** 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 */
  16687. preWarmCycles: number;
  16688. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16689. preWarmStepOffset: number;
  16690. /**
  16691. * 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)
  16692. */
  16693. spriteCellChangeSpeed: number;
  16694. /**
  16695. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16696. */
  16697. startSpriteCellID: number;
  16698. /**
  16699. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16700. */
  16701. endSpriteCellID: number;
  16702. /**
  16703. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16704. */
  16705. spriteCellWidth: number;
  16706. /**
  16707. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16708. */
  16709. spriteCellHeight: number;
  16710. /**
  16711. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16712. */
  16713. spriteRandomStartCell: boolean;
  16714. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16715. translationPivot: Vector2;
  16716. /** @hidden */
  16717. protected _isAnimationSheetEnabled: boolean;
  16718. /**
  16719. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16720. */
  16721. beginAnimationOnStart: boolean;
  16722. /**
  16723. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16724. */
  16725. beginAnimationFrom: number;
  16726. /**
  16727. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16728. */
  16729. beginAnimationTo: number;
  16730. /**
  16731. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16732. */
  16733. beginAnimationLoop: boolean;
  16734. /**
  16735. * Gets or sets a world offset applied to all particles
  16736. */
  16737. worldOffset: Vector3;
  16738. /**
  16739. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16740. */
  16741. isAnimationSheetEnabled: boolean;
  16742. /**
  16743. * Get hosting scene
  16744. * @returns the scene
  16745. */
  16746. getScene(): Scene;
  16747. /**
  16748. * You can use gravity if you want to give an orientation to your particles.
  16749. */
  16750. gravity: Vector3;
  16751. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16752. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16753. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16754. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16755. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16756. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16757. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16758. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16759. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16760. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16761. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16762. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16763. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16764. /**
  16765. * Defines the delay in milliseconds before starting the system (0 by default)
  16766. */
  16767. startDelay: number;
  16768. /**
  16769. * Gets the current list of drag gradients.
  16770. * You must use addDragGradient and removeDragGradient to udpate this list
  16771. * @returns the list of drag gradients
  16772. */
  16773. getDragGradients(): Nullable<Array<FactorGradient>>;
  16774. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16775. limitVelocityDamping: number;
  16776. /**
  16777. * Gets the current list of limit velocity gradients.
  16778. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16779. * @returns the list of limit velocity gradients
  16780. */
  16781. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16782. /**
  16783. * Gets the current list of color gradients.
  16784. * You must use addColorGradient and removeColorGradient to udpate this list
  16785. * @returns the list of color gradients
  16786. */
  16787. getColorGradients(): Nullable<Array<ColorGradient>>;
  16788. /**
  16789. * Gets the current list of size gradients.
  16790. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16791. * @returns the list of size gradients
  16792. */
  16793. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16794. /**
  16795. * Gets the current list of color remap gradients.
  16796. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16797. * @returns the list of color remap gradients
  16798. */
  16799. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16800. /**
  16801. * Gets the current list of alpha remap gradients.
  16802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16803. * @returns the list of alpha remap gradients
  16804. */
  16805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16806. /**
  16807. * Gets the current list of life time gradients.
  16808. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16809. * @returns the list of life time gradients
  16810. */
  16811. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16812. /**
  16813. * Gets the current list of angular speed gradients.
  16814. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16815. * @returns the list of angular speed gradients
  16816. */
  16817. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16818. /**
  16819. * Gets the current list of velocity gradients.
  16820. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16821. * @returns the list of velocity gradients
  16822. */
  16823. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16824. /**
  16825. * Gets the current list of start size gradients.
  16826. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16827. * @returns the list of start size gradients
  16828. */
  16829. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16830. /**
  16831. * Gets the current list of emit rate gradients.
  16832. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16833. * @returns the list of emit rate gradients
  16834. */
  16835. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16836. /**
  16837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16838. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16839. */
  16840. direction1: Vector3;
  16841. /**
  16842. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16843. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16844. */
  16845. direction2: Vector3;
  16846. /**
  16847. * 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.
  16848. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16849. */
  16850. minEmitBox: Vector3;
  16851. /**
  16852. * 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.
  16853. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16854. */
  16855. maxEmitBox: Vector3;
  16856. /**
  16857. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16858. */
  16859. color1: Color4;
  16860. /**
  16861. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16862. */
  16863. color2: Color4;
  16864. /**
  16865. * Color the particle will have at the end of its lifetime
  16866. */
  16867. colorDead: Color4;
  16868. /**
  16869. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16870. */
  16871. textureMask: Color4;
  16872. /**
  16873. * The particle emitter type defines the emitter used by the particle system.
  16874. * It can be for example box, sphere, or cone...
  16875. */
  16876. particleEmitterType: IParticleEmitterType;
  16877. /** @hidden */
  16878. _isSubEmitter: boolean;
  16879. /**
  16880. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16881. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16882. */
  16883. billboardMode: number;
  16884. protected _isBillboardBased: boolean;
  16885. /**
  16886. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16887. */
  16888. isBillboardBased: boolean;
  16889. /**
  16890. * The scene the particle system belongs to.
  16891. */
  16892. protected _scene: Scene;
  16893. /**
  16894. * Local cache of defines for image processing.
  16895. */
  16896. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16897. /**
  16898. * Default configuration related to image processing available in the standard Material.
  16899. */
  16900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16901. /**
  16902. * Gets the image processing configuration used either in this material.
  16903. */
  16904. /**
  16905. * Sets the Default image processing configuration used either in the this material.
  16906. *
  16907. * If sets to null, the scene one is in use.
  16908. */
  16909. imageProcessingConfiguration: ImageProcessingConfiguration;
  16910. /**
  16911. * Attaches a new image processing configuration to the Standard Material.
  16912. * @param configuration
  16913. */
  16914. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16915. /** @hidden */
  16916. protected _reset(): void;
  16917. /** @hidden */
  16918. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16919. /**
  16920. * Instantiates a particle system.
  16921. * 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.
  16922. * @param name The name of the particle system
  16923. */
  16924. constructor(name: string);
  16925. /**
  16926. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16927. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16928. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16929. * @returns the emitter
  16930. */
  16931. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16932. /**
  16933. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16934. * @param radius The radius of the hemisphere to emit from
  16935. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16936. * @returns the emitter
  16937. */
  16938. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16939. /**
  16940. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16941. * @param radius The radius of the sphere to emit from
  16942. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16943. * @returns the emitter
  16944. */
  16945. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16946. /**
  16947. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16948. * @param radius The radius of the sphere to emit from
  16949. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16950. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16951. * @returns the emitter
  16952. */
  16953. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16954. /**
  16955. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16956. * @param radius The radius of the emission cylinder
  16957. * @param height The height of the emission cylinder
  16958. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16959. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16960. * @returns the emitter
  16961. */
  16962. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16963. /**
  16964. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16965. * @param radius The radius of the cylinder to emit from
  16966. * @param height The height of the emission cylinder
  16967. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16968. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16969. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16970. * @returns the emitter
  16971. */
  16972. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16973. /**
  16974. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16975. * @param radius The radius of the cone to emit from
  16976. * @param angle The base angle of the cone
  16977. * @returns the emitter
  16978. */
  16979. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16980. /**
  16981. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16982. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16983. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16984. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16985. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16986. * @returns the emitter
  16987. */
  16988. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16989. }
  16990. }
  16991. declare module "babylonjs/Particles/subEmitter" {
  16992. import { Scene } from "babylonjs/scene";
  16993. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  16994. /**
  16995. * Type of sub emitter
  16996. */
  16997. export enum SubEmitterType {
  16998. /**
  16999. * Attached to the particle over it's lifetime
  17000. */
  17001. ATTACHED = 0,
  17002. /**
  17003. * Created when the particle dies
  17004. */
  17005. END = 1
  17006. }
  17007. /**
  17008. * Sub emitter class used to emit particles from an existing particle
  17009. */
  17010. export class SubEmitter {
  17011. /**
  17012. * the particle system to be used by the sub emitter
  17013. */
  17014. particleSystem: ParticleSystem;
  17015. /**
  17016. * Type of the submitter (Default: END)
  17017. */
  17018. type: SubEmitterType;
  17019. /**
  17020. * 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)
  17021. * Note: This only is supported when using an emitter of type Mesh
  17022. */
  17023. inheritDirection: boolean;
  17024. /**
  17025. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17026. */
  17027. inheritedVelocityAmount: number;
  17028. /**
  17029. * Creates a sub emitter
  17030. * @param particleSystem the particle system to be used by the sub emitter
  17031. */
  17032. constructor(
  17033. /**
  17034. * the particle system to be used by the sub emitter
  17035. */
  17036. particleSystem: ParticleSystem);
  17037. /**
  17038. * Clones the sub emitter
  17039. * @returns the cloned sub emitter
  17040. */
  17041. clone(): SubEmitter;
  17042. /**
  17043. * Serialize current object to a JSON object
  17044. * @returns the serialized object
  17045. */
  17046. serialize(): any;
  17047. /** @hidden */
  17048. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17049. /**
  17050. * Creates a new SubEmitter from a serialized JSON version
  17051. * @param serializationObject defines the JSON object to read from
  17052. * @param scene defines the hosting scene
  17053. * @param rootUrl defines the rootUrl for data loading
  17054. * @returns a new SubEmitter
  17055. */
  17056. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17057. /** Release associated resources */
  17058. dispose(): void;
  17059. }
  17060. }
  17061. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17062. /** @hidden */
  17063. export var clipPlaneFragmentDeclaration: {
  17064. name: string;
  17065. shader: string;
  17066. };
  17067. }
  17068. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17069. /** @hidden */
  17070. export var imageProcessingDeclaration: {
  17071. name: string;
  17072. shader: string;
  17073. };
  17074. }
  17075. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17076. /** @hidden */
  17077. export var imageProcessingFunctions: {
  17078. name: string;
  17079. shader: string;
  17080. };
  17081. }
  17082. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17083. /** @hidden */
  17084. export var clipPlaneFragment: {
  17085. name: string;
  17086. shader: string;
  17087. };
  17088. }
  17089. declare module "babylonjs/Shaders/particles.fragment" {
  17090. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17091. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17092. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17093. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17094. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17095. /** @hidden */
  17096. export var particlesPixelShader: {
  17097. name: string;
  17098. shader: string;
  17099. };
  17100. }
  17101. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17102. /** @hidden */
  17103. export var clipPlaneVertexDeclaration: {
  17104. name: string;
  17105. shader: string;
  17106. };
  17107. }
  17108. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17109. /** @hidden */
  17110. export var clipPlaneVertex: {
  17111. name: string;
  17112. shader: string;
  17113. };
  17114. }
  17115. declare module "babylonjs/Shaders/particles.vertex" {
  17116. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17117. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17118. /** @hidden */
  17119. export var particlesVertexShader: {
  17120. name: string;
  17121. shader: string;
  17122. };
  17123. }
  17124. declare module "babylonjs/Particles/particleSystem" {
  17125. import { Nullable } from "babylonjs/types";
  17126. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17127. import { Observable } from "babylonjs/Misc/observable";
  17128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17129. import { Effect } from "babylonjs/Materials/effect";
  17130. import { Scene, IDisposable } from "babylonjs/scene";
  17131. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17132. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17133. import { Particle } from "babylonjs/Particles/particle";
  17134. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17135. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17136. import "babylonjs/Shaders/particles.fragment";
  17137. import "babylonjs/Shaders/particles.vertex";
  17138. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17139. /**
  17140. * This represents a particle system in Babylon.
  17141. * 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.
  17142. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17143. * @example https://doc.babylonjs.com/babylon101/particles
  17144. */
  17145. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17146. /**
  17147. * Billboard mode will only apply to Y axis
  17148. */
  17149. static readonly BILLBOARDMODE_Y: number;
  17150. /**
  17151. * Billboard mode will apply to all axes
  17152. */
  17153. static readonly BILLBOARDMODE_ALL: number;
  17154. /**
  17155. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17156. */
  17157. static readonly BILLBOARDMODE_STRETCHED: number;
  17158. /**
  17159. * This function can be defined to provide custom update for active particles.
  17160. * This function will be called instead of regular update (age, position, color, etc.).
  17161. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17162. */
  17163. updateFunction: (particles: Particle[]) => void;
  17164. private _emitterWorldMatrix;
  17165. /**
  17166. * This function can be defined to specify initial direction for every new particle.
  17167. * It by default use the emitterType defined function
  17168. */
  17169. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17170. /**
  17171. * This function can be defined to specify initial position for every new particle.
  17172. * It by default use the emitterType defined function
  17173. */
  17174. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17175. /**
  17176. * @hidden
  17177. */
  17178. _inheritedVelocityOffset: Vector3;
  17179. /**
  17180. * An event triggered when the system is disposed
  17181. */
  17182. onDisposeObservable: Observable<ParticleSystem>;
  17183. private _onDisposeObserver;
  17184. /**
  17185. * Sets a callback that will be triggered when the system is disposed
  17186. */
  17187. onDispose: () => void;
  17188. private _particles;
  17189. private _epsilon;
  17190. private _capacity;
  17191. private _stockParticles;
  17192. private _newPartsExcess;
  17193. private _vertexData;
  17194. private _vertexBuffer;
  17195. private _vertexBuffers;
  17196. private _spriteBuffer;
  17197. private _indexBuffer;
  17198. private _effect;
  17199. private _customEffect;
  17200. private _cachedDefines;
  17201. private _scaledColorStep;
  17202. private _colorDiff;
  17203. private _scaledDirection;
  17204. private _scaledGravity;
  17205. private _currentRenderId;
  17206. private _alive;
  17207. private _useInstancing;
  17208. private _started;
  17209. private _stopped;
  17210. private _actualFrame;
  17211. private _scaledUpdateSpeed;
  17212. private _vertexBufferSize;
  17213. /** @hidden */
  17214. _currentEmitRateGradient: Nullable<FactorGradient>;
  17215. /** @hidden */
  17216. _currentEmitRate1: number;
  17217. /** @hidden */
  17218. _currentEmitRate2: number;
  17219. /** @hidden */
  17220. _currentStartSizeGradient: Nullable<FactorGradient>;
  17221. /** @hidden */
  17222. _currentStartSize1: number;
  17223. /** @hidden */
  17224. _currentStartSize2: number;
  17225. private readonly _rawTextureWidth;
  17226. private _rampGradientsTexture;
  17227. private _useRampGradients;
  17228. /** Gets or sets a boolean indicating that ramp gradients must be used
  17229. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17230. */
  17231. useRampGradients: boolean;
  17232. /**
  17233. * 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.
  17234. * 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: [])
  17235. */
  17236. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17237. private _subEmitters;
  17238. /**
  17239. * @hidden
  17240. * If the particle systems emitter should be disposed when the particle system is disposed
  17241. */
  17242. _disposeEmitterOnDispose: boolean;
  17243. /**
  17244. * The current active Sub-systems, this property is used by the root particle system only.
  17245. */
  17246. activeSubSystems: Array<ParticleSystem>;
  17247. private _rootParticleSystem;
  17248. /**
  17249. * Gets the current list of active particles
  17250. */
  17251. readonly particles: Particle[];
  17252. /**
  17253. * Returns the string "ParticleSystem"
  17254. * @returns a string containing the class name
  17255. */
  17256. getClassName(): string;
  17257. /**
  17258. * Instantiates a particle system.
  17259. * 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.
  17260. * @param name The name of the particle system
  17261. * @param capacity The max number of particles alive at the same time
  17262. * @param scene The scene the particle system belongs to
  17263. * @param customEffect a custom effect used to change the way particles are rendered by default
  17264. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17265. * @param epsilon Offset used to render the particles
  17266. */
  17267. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17268. private _addFactorGradient;
  17269. private _removeFactorGradient;
  17270. /**
  17271. * Adds a new life time gradient
  17272. * @param gradient defines the gradient to use (between 0 and 1)
  17273. * @param factor defines the life time factor to affect to the specified gradient
  17274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17275. * @returns the current particle system
  17276. */
  17277. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17278. /**
  17279. * Remove a specific life time gradient
  17280. * @param gradient defines the gradient to remove
  17281. * @returns the current particle system
  17282. */
  17283. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17284. /**
  17285. * Adds a new size gradient
  17286. * @param gradient defines the gradient to use (between 0 and 1)
  17287. * @param factor defines the size factor to affect to the specified gradient
  17288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17289. * @returns the current particle system
  17290. */
  17291. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17292. /**
  17293. * Remove a specific size gradient
  17294. * @param gradient defines the gradient to remove
  17295. * @returns the current particle system
  17296. */
  17297. removeSizeGradient(gradient: number): IParticleSystem;
  17298. /**
  17299. * Adds a new color remap gradient
  17300. * @param gradient defines the gradient to use (between 0 and 1)
  17301. * @param min defines the color remap minimal range
  17302. * @param max defines the color remap maximal range
  17303. * @returns the current particle system
  17304. */
  17305. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17306. /**
  17307. * Remove a specific color remap gradient
  17308. * @param gradient defines the gradient to remove
  17309. * @returns the current particle system
  17310. */
  17311. removeColorRemapGradient(gradient: number): IParticleSystem;
  17312. /**
  17313. * Adds a new alpha remap gradient
  17314. * @param gradient defines the gradient to use (between 0 and 1)
  17315. * @param min defines the alpha remap minimal range
  17316. * @param max defines the alpha remap maximal range
  17317. * @returns the current particle system
  17318. */
  17319. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17320. /**
  17321. * Remove a specific alpha remap gradient
  17322. * @param gradient defines the gradient to remove
  17323. * @returns the current particle system
  17324. */
  17325. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17326. /**
  17327. * Adds a new angular speed gradient
  17328. * @param gradient defines the gradient to use (between 0 and 1)
  17329. * @param factor defines the angular speed to affect to the specified gradient
  17330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17331. * @returns the current particle system
  17332. */
  17333. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17334. /**
  17335. * Remove a specific angular speed gradient
  17336. * @param gradient defines the gradient to remove
  17337. * @returns the current particle system
  17338. */
  17339. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17340. /**
  17341. * Adds a new velocity gradient
  17342. * @param gradient defines the gradient to use (between 0 and 1)
  17343. * @param factor defines the velocity to affect to the specified gradient
  17344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17345. * @returns the current particle system
  17346. */
  17347. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17348. /**
  17349. * Remove a specific velocity gradient
  17350. * @param gradient defines the gradient to remove
  17351. * @returns the current particle system
  17352. */
  17353. removeVelocityGradient(gradient: number): IParticleSystem;
  17354. /**
  17355. * Adds a new limit velocity gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param factor defines the limit velocity value to affect to the specified gradient
  17358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17359. * @returns the current particle system
  17360. */
  17361. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17362. /**
  17363. * Remove a specific limit velocity gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Adds a new drag gradient
  17370. * @param gradient defines the gradient to use (between 0 and 1)
  17371. * @param factor defines the drag value to affect to the specified gradient
  17372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17373. * @returns the current particle system
  17374. */
  17375. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17376. /**
  17377. * Remove a specific drag gradient
  17378. * @param gradient defines the gradient to remove
  17379. * @returns the current particle system
  17380. */
  17381. removeDragGradient(gradient: number): IParticleSystem;
  17382. /**
  17383. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17384. * @param gradient defines the gradient to use (between 0 and 1)
  17385. * @param factor defines the emit rate value to affect to the specified gradient
  17386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17387. * @returns the current particle system
  17388. */
  17389. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17390. /**
  17391. * Remove a specific emit rate gradient
  17392. * @param gradient defines the gradient to remove
  17393. * @returns the current particle system
  17394. */
  17395. removeEmitRateGradient(gradient: number): IParticleSystem;
  17396. /**
  17397. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17398. * @param gradient defines the gradient to use (between 0 and 1)
  17399. * @param factor defines the start size value to affect to the specified gradient
  17400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17401. * @returns the current particle system
  17402. */
  17403. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17404. /**
  17405. * Remove a specific start size gradient
  17406. * @param gradient defines the gradient to remove
  17407. * @returns the current particle system
  17408. */
  17409. removeStartSizeGradient(gradient: number): IParticleSystem;
  17410. private _createRampGradientTexture;
  17411. /**
  17412. * Gets the current list of ramp gradients.
  17413. * You must use addRampGradient and removeRampGradient to udpate this list
  17414. * @returns the list of ramp gradients
  17415. */
  17416. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17417. /**
  17418. * Adds a new ramp gradient used to remap particle colors
  17419. * @param gradient defines the gradient to use (between 0 and 1)
  17420. * @param color defines the color to affect to the specified gradient
  17421. * @returns the current particle system
  17422. */
  17423. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17424. /**
  17425. * Remove a specific ramp gradient
  17426. * @param gradient defines the gradient to remove
  17427. * @returns the current particle system
  17428. */
  17429. removeRampGradient(gradient: number): ParticleSystem;
  17430. /**
  17431. * Adds a new color gradient
  17432. * @param gradient defines the gradient to use (between 0 and 1)
  17433. * @param color1 defines the color to affect to the specified gradient
  17434. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17435. * @returns this particle system
  17436. */
  17437. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17438. /**
  17439. * Remove a specific color gradient
  17440. * @param gradient defines the gradient to remove
  17441. * @returns this particle system
  17442. */
  17443. removeColorGradient(gradient: number): IParticleSystem;
  17444. private _fetchR;
  17445. protected _reset(): void;
  17446. private _resetEffect;
  17447. private _createVertexBuffers;
  17448. private _createIndexBuffer;
  17449. /**
  17450. * Gets the maximum number of particles active at the same time.
  17451. * @returns The max number of active particles.
  17452. */
  17453. getCapacity(): number;
  17454. /**
  17455. * Gets whether there are still active particles in the system.
  17456. * @returns True if it is alive, otherwise false.
  17457. */
  17458. isAlive(): boolean;
  17459. /**
  17460. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17461. * @returns True if it has been started, otherwise false.
  17462. */
  17463. isStarted(): boolean;
  17464. private _prepareSubEmitterInternalArray;
  17465. /**
  17466. * Starts the particle system and begins to emit
  17467. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17468. */
  17469. start(delay?: number): void;
  17470. /**
  17471. * Stops the particle system.
  17472. * @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.
  17473. */
  17474. stop(stopSubEmitters?: boolean): void;
  17475. /**
  17476. * Remove all active particles
  17477. */
  17478. reset(): void;
  17479. /**
  17480. * @hidden (for internal use only)
  17481. */
  17482. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17483. /**
  17484. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17485. * Its lifetime will start back at 0.
  17486. */
  17487. recycleParticle: (particle: Particle) => void;
  17488. private _stopSubEmitters;
  17489. private _createParticle;
  17490. private _removeFromRoot;
  17491. private _emitFromParticle;
  17492. private _update;
  17493. /** @hidden */
  17494. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17495. /** @hidden */
  17496. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17497. /** @hidden */
  17498. private _getEffect;
  17499. /**
  17500. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17501. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17502. */
  17503. animate(preWarmOnly?: boolean): void;
  17504. private _appendParticleVertices;
  17505. /**
  17506. * Rebuilds the particle system.
  17507. */
  17508. rebuild(): void;
  17509. /**
  17510. * Is this system ready to be used/rendered
  17511. * @return true if the system is ready
  17512. */
  17513. isReady(): boolean;
  17514. private _render;
  17515. /**
  17516. * Renders the particle system in its current state.
  17517. * @returns the current number of particles
  17518. */
  17519. render(): number;
  17520. /**
  17521. * Disposes the particle system and free the associated resources
  17522. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17523. */
  17524. dispose(disposeTexture?: boolean): void;
  17525. /**
  17526. * Clones the particle system.
  17527. * @param name The name of the cloned object
  17528. * @param newEmitter The new emitter to use
  17529. * @returns the cloned particle system
  17530. */
  17531. clone(name: string, newEmitter: any): ParticleSystem;
  17532. /**
  17533. * Serializes the particle system to a JSON object.
  17534. * @returns the JSON object
  17535. */
  17536. serialize(): any;
  17537. /** @hidden */
  17538. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17539. /** @hidden */
  17540. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17541. /**
  17542. * Parses a JSON object to create a particle system.
  17543. * @param parsedParticleSystem The JSON object to parse
  17544. * @param scene The scene to create the particle system in
  17545. * @param rootUrl The root url to use to load external dependencies like texture
  17546. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17547. * @returns the Parsed particle system
  17548. */
  17549. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17550. }
  17551. }
  17552. declare module "babylonjs/Particles/particle" {
  17553. import { Nullable } from "babylonjs/types";
  17554. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17555. import { Color4 } from "babylonjs/Maths/math.color";
  17556. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17557. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17558. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17559. /**
  17560. * A particle represents one of the element emitted by a particle system.
  17561. * This is mainly define by its coordinates, direction, velocity and age.
  17562. */
  17563. export class Particle {
  17564. /**
  17565. * The particle system the particle belongs to.
  17566. */
  17567. particleSystem: ParticleSystem;
  17568. private static _Count;
  17569. /**
  17570. * Unique ID of the particle
  17571. */
  17572. id: number;
  17573. /**
  17574. * The world position of the particle in the scene.
  17575. */
  17576. position: Vector3;
  17577. /**
  17578. * The world direction of the particle in the scene.
  17579. */
  17580. direction: Vector3;
  17581. /**
  17582. * The color of the particle.
  17583. */
  17584. color: Color4;
  17585. /**
  17586. * The color change of the particle per step.
  17587. */
  17588. colorStep: Color4;
  17589. /**
  17590. * Defines how long will the life of the particle be.
  17591. */
  17592. lifeTime: number;
  17593. /**
  17594. * The current age of the particle.
  17595. */
  17596. age: number;
  17597. /**
  17598. * The current size of the particle.
  17599. */
  17600. size: number;
  17601. /**
  17602. * The current scale of the particle.
  17603. */
  17604. scale: Vector2;
  17605. /**
  17606. * The current angle of the particle.
  17607. */
  17608. angle: number;
  17609. /**
  17610. * Defines how fast is the angle changing.
  17611. */
  17612. angularSpeed: number;
  17613. /**
  17614. * Defines the cell index used by the particle to be rendered from a sprite.
  17615. */
  17616. cellIndex: number;
  17617. /**
  17618. * The information required to support color remapping
  17619. */
  17620. remapData: Vector4;
  17621. /** @hidden */
  17622. _randomCellOffset?: number;
  17623. /** @hidden */
  17624. _initialDirection: Nullable<Vector3>;
  17625. /** @hidden */
  17626. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17627. /** @hidden */
  17628. _initialStartSpriteCellID: number;
  17629. /** @hidden */
  17630. _initialEndSpriteCellID: number;
  17631. /** @hidden */
  17632. _currentColorGradient: Nullable<ColorGradient>;
  17633. /** @hidden */
  17634. _currentColor1: Color4;
  17635. /** @hidden */
  17636. _currentColor2: Color4;
  17637. /** @hidden */
  17638. _currentSizeGradient: Nullable<FactorGradient>;
  17639. /** @hidden */
  17640. _currentSize1: number;
  17641. /** @hidden */
  17642. _currentSize2: number;
  17643. /** @hidden */
  17644. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17645. /** @hidden */
  17646. _currentAngularSpeed1: number;
  17647. /** @hidden */
  17648. _currentAngularSpeed2: number;
  17649. /** @hidden */
  17650. _currentVelocityGradient: Nullable<FactorGradient>;
  17651. /** @hidden */
  17652. _currentVelocity1: number;
  17653. /** @hidden */
  17654. _currentVelocity2: number;
  17655. /** @hidden */
  17656. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17657. /** @hidden */
  17658. _currentLimitVelocity1: number;
  17659. /** @hidden */
  17660. _currentLimitVelocity2: number;
  17661. /** @hidden */
  17662. _currentDragGradient: Nullable<FactorGradient>;
  17663. /** @hidden */
  17664. _currentDrag1: number;
  17665. /** @hidden */
  17666. _currentDrag2: number;
  17667. /** @hidden */
  17668. _randomNoiseCoordinates1: Vector3;
  17669. /** @hidden */
  17670. _randomNoiseCoordinates2: Vector3;
  17671. /**
  17672. * Creates a new instance Particle
  17673. * @param particleSystem the particle system the particle belongs to
  17674. */
  17675. constructor(
  17676. /**
  17677. * The particle system the particle belongs to.
  17678. */
  17679. particleSystem: ParticleSystem);
  17680. private updateCellInfoFromSystem;
  17681. /**
  17682. * Defines how the sprite cell index is updated for the particle
  17683. */
  17684. updateCellIndex(): void;
  17685. /** @hidden */
  17686. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17687. /** @hidden */
  17688. _inheritParticleInfoToSubEmitters(): void;
  17689. /** @hidden */
  17690. _reset(): void;
  17691. /**
  17692. * Copy the properties of particle to another one.
  17693. * @param other the particle to copy the information to.
  17694. */
  17695. copyTo(other: Particle): void;
  17696. }
  17697. }
  17698. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17699. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17700. import { Effect } from "babylonjs/Materials/effect";
  17701. import { Particle } from "babylonjs/Particles/particle";
  17702. /**
  17703. * Particle emitter represents a volume emitting particles.
  17704. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17705. */
  17706. export interface IParticleEmitterType {
  17707. /**
  17708. * Called by the particle System when the direction is computed for the created particle.
  17709. * @param worldMatrix is the world matrix of the particle system
  17710. * @param directionToUpdate is the direction vector to update with the result
  17711. * @param particle is the particle we are computed the direction for
  17712. */
  17713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17714. /**
  17715. * Called by the particle System when the position is computed for the created particle.
  17716. * @param worldMatrix is the world matrix of the particle system
  17717. * @param positionToUpdate is the position vector to update with the result
  17718. * @param particle is the particle we are computed the position for
  17719. */
  17720. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17721. /**
  17722. * Clones the current emitter and returns a copy of it
  17723. * @returns the new emitter
  17724. */
  17725. clone(): IParticleEmitterType;
  17726. /**
  17727. * Called by the GPUParticleSystem to setup the update shader
  17728. * @param effect defines the update shader
  17729. */
  17730. applyToShader(effect: Effect): void;
  17731. /**
  17732. * Returns a string to use to update the GPU particles update shader
  17733. * @returns the effect defines string
  17734. */
  17735. getEffectDefines(): string;
  17736. /**
  17737. * Returns a string representing the class name
  17738. * @returns a string containing the class name
  17739. */
  17740. getClassName(): string;
  17741. /**
  17742. * Serializes the particle system to a JSON object.
  17743. * @returns the JSON object
  17744. */
  17745. serialize(): any;
  17746. /**
  17747. * Parse properties from a JSON object
  17748. * @param serializationObject defines the JSON object
  17749. */
  17750. parse(serializationObject: any): void;
  17751. }
  17752. }
  17753. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17754. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17755. import { Effect } from "babylonjs/Materials/effect";
  17756. import { Particle } from "babylonjs/Particles/particle";
  17757. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17758. /**
  17759. * Particle emitter emitting particles from the inside of a box.
  17760. * It emits the particles randomly between 2 given directions.
  17761. */
  17762. export class BoxParticleEmitter implements IParticleEmitterType {
  17763. /**
  17764. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17765. */
  17766. direction1: Vector3;
  17767. /**
  17768. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17769. */
  17770. direction2: Vector3;
  17771. /**
  17772. * 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.
  17773. */
  17774. minEmitBox: Vector3;
  17775. /**
  17776. * 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.
  17777. */
  17778. maxEmitBox: Vector3;
  17779. /**
  17780. * Creates a new instance BoxParticleEmitter
  17781. */
  17782. constructor();
  17783. /**
  17784. * Called by the particle System when the direction is computed for the created particle.
  17785. * @param worldMatrix is the world matrix of the particle system
  17786. * @param directionToUpdate is the direction vector to update with the result
  17787. * @param particle is the particle we are computed the direction for
  17788. */
  17789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17790. /**
  17791. * Called by the particle System when the position is computed for the created particle.
  17792. * @param worldMatrix is the world matrix of the particle system
  17793. * @param positionToUpdate is the position vector to update with the result
  17794. * @param particle is the particle we are computed the position for
  17795. */
  17796. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17797. /**
  17798. * Clones the current emitter and returns a copy of it
  17799. * @returns the new emitter
  17800. */
  17801. clone(): BoxParticleEmitter;
  17802. /**
  17803. * Called by the GPUParticleSystem to setup the update shader
  17804. * @param effect defines the update shader
  17805. */
  17806. applyToShader(effect: Effect): void;
  17807. /**
  17808. * Returns a string to use to update the GPU particles update shader
  17809. * @returns a string containng the defines string
  17810. */
  17811. getEffectDefines(): string;
  17812. /**
  17813. * Returns the string "BoxParticleEmitter"
  17814. * @returns a string containing the class name
  17815. */
  17816. getClassName(): string;
  17817. /**
  17818. * Serializes the particle system to a JSON object.
  17819. * @returns the JSON object
  17820. */
  17821. serialize(): any;
  17822. /**
  17823. * Parse properties from a JSON object
  17824. * @param serializationObject defines the JSON object
  17825. */
  17826. parse(serializationObject: any): void;
  17827. }
  17828. }
  17829. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17830. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17831. import { Effect } from "babylonjs/Materials/effect";
  17832. import { Particle } from "babylonjs/Particles/particle";
  17833. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17834. /**
  17835. * Particle emitter emitting particles from the inside of a cone.
  17836. * It emits the particles alongside the cone volume from the base to the particle.
  17837. * The emission direction might be randomized.
  17838. */
  17839. export class ConeParticleEmitter implements IParticleEmitterType {
  17840. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17841. directionRandomizer: number;
  17842. private _radius;
  17843. private _angle;
  17844. private _height;
  17845. /**
  17846. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17847. */
  17848. radiusRange: number;
  17849. /**
  17850. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17851. */
  17852. heightRange: number;
  17853. /**
  17854. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17855. */
  17856. emitFromSpawnPointOnly: boolean;
  17857. /**
  17858. * Gets or sets the radius of the emission cone
  17859. */
  17860. radius: number;
  17861. /**
  17862. * Gets or sets the angle of the emission cone
  17863. */
  17864. angle: number;
  17865. private _buildHeight;
  17866. /**
  17867. * Creates a new instance ConeParticleEmitter
  17868. * @param radius the radius of the emission cone (1 by default)
  17869. * @param angle the cone base angle (PI by default)
  17870. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17871. */
  17872. constructor(radius?: number, angle?: number,
  17873. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17874. directionRandomizer?: number);
  17875. /**
  17876. * Called by the particle System when the direction is computed for the created particle.
  17877. * @param worldMatrix is the world matrix of the particle system
  17878. * @param directionToUpdate is the direction vector to update with the result
  17879. * @param particle is the particle we are computed the direction for
  17880. */
  17881. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17882. /**
  17883. * Called by the particle System when the position is computed for the created particle.
  17884. * @param worldMatrix is the world matrix of the particle system
  17885. * @param positionToUpdate is the position vector to update with the result
  17886. * @param particle is the particle we are computed the position for
  17887. */
  17888. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17889. /**
  17890. * Clones the current emitter and returns a copy of it
  17891. * @returns the new emitter
  17892. */
  17893. clone(): ConeParticleEmitter;
  17894. /**
  17895. * Called by the GPUParticleSystem to setup the update shader
  17896. * @param effect defines the update shader
  17897. */
  17898. applyToShader(effect: Effect): void;
  17899. /**
  17900. * Returns a string to use to update the GPU particles update shader
  17901. * @returns a string containng the defines string
  17902. */
  17903. getEffectDefines(): string;
  17904. /**
  17905. * Returns the string "ConeParticleEmitter"
  17906. * @returns a string containing the class name
  17907. */
  17908. getClassName(): string;
  17909. /**
  17910. * Serializes the particle system to a JSON object.
  17911. * @returns the JSON object
  17912. */
  17913. serialize(): any;
  17914. /**
  17915. * Parse properties from a JSON object
  17916. * @param serializationObject defines the JSON object
  17917. */
  17918. parse(serializationObject: any): void;
  17919. }
  17920. }
  17921. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17922. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17923. import { Effect } from "babylonjs/Materials/effect";
  17924. import { Particle } from "babylonjs/Particles/particle";
  17925. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17926. /**
  17927. * Particle emitter emitting particles from the inside of a cylinder.
  17928. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17929. */
  17930. export class CylinderParticleEmitter implements IParticleEmitterType {
  17931. /**
  17932. * The radius of the emission cylinder.
  17933. */
  17934. radius: number;
  17935. /**
  17936. * The height of the emission cylinder.
  17937. */
  17938. height: number;
  17939. /**
  17940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17941. */
  17942. radiusRange: number;
  17943. /**
  17944. * How much to randomize the particle direction [0-1].
  17945. */
  17946. directionRandomizer: number;
  17947. /**
  17948. * Creates a new instance CylinderParticleEmitter
  17949. * @param radius the radius of the emission cylinder (1 by default)
  17950. * @param height the height of the emission cylinder (1 by default)
  17951. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17952. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17953. */
  17954. constructor(
  17955. /**
  17956. * The radius of the emission cylinder.
  17957. */
  17958. radius?: number,
  17959. /**
  17960. * The height of the emission cylinder.
  17961. */
  17962. height?: number,
  17963. /**
  17964. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17965. */
  17966. radiusRange?: number,
  17967. /**
  17968. * How much to randomize the particle direction [0-1].
  17969. */
  17970. directionRandomizer?: number);
  17971. /**
  17972. * Called by the particle System when the direction is computed for the created particle.
  17973. * @param worldMatrix is the world matrix of the particle system
  17974. * @param directionToUpdate is the direction vector to update with the result
  17975. * @param particle is the particle we are computed the direction for
  17976. */
  17977. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17978. /**
  17979. * Called by the particle System when the position is computed for the created particle.
  17980. * @param worldMatrix is the world matrix of the particle system
  17981. * @param positionToUpdate is the position vector to update with the result
  17982. * @param particle is the particle we are computed the position for
  17983. */
  17984. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17985. /**
  17986. * Clones the current emitter and returns a copy of it
  17987. * @returns the new emitter
  17988. */
  17989. clone(): CylinderParticleEmitter;
  17990. /**
  17991. * Called by the GPUParticleSystem to setup the update shader
  17992. * @param effect defines the update shader
  17993. */
  17994. applyToShader(effect: Effect): void;
  17995. /**
  17996. * Returns a string to use to update the GPU particles update shader
  17997. * @returns a string containng the defines string
  17998. */
  17999. getEffectDefines(): string;
  18000. /**
  18001. * Returns the string "CylinderParticleEmitter"
  18002. * @returns a string containing the class name
  18003. */
  18004. getClassName(): string;
  18005. /**
  18006. * Serializes the particle system to a JSON object.
  18007. * @returns the JSON object
  18008. */
  18009. serialize(): any;
  18010. /**
  18011. * Parse properties from a JSON object
  18012. * @param serializationObject defines the JSON object
  18013. */
  18014. parse(serializationObject: any): void;
  18015. }
  18016. /**
  18017. * Particle emitter emitting particles from the inside of a cylinder.
  18018. * It emits the particles randomly between two vectors.
  18019. */
  18020. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18021. /**
  18022. * The min limit of the emission direction.
  18023. */
  18024. direction1: Vector3;
  18025. /**
  18026. * The max limit of the emission direction.
  18027. */
  18028. direction2: Vector3;
  18029. /**
  18030. * Creates a new instance CylinderDirectedParticleEmitter
  18031. * @param radius the radius of the emission cylinder (1 by default)
  18032. * @param height the height of the emission cylinder (1 by default)
  18033. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18034. * @param direction1 the min limit of the emission direction (up vector by default)
  18035. * @param direction2 the max limit of the emission direction (up vector by default)
  18036. */
  18037. constructor(radius?: number, height?: number, radiusRange?: number,
  18038. /**
  18039. * The min limit of the emission direction.
  18040. */
  18041. direction1?: Vector3,
  18042. /**
  18043. * The max limit of the emission direction.
  18044. */
  18045. direction2?: Vector3);
  18046. /**
  18047. * Called by the particle System when the direction is computed for the created particle.
  18048. * @param worldMatrix is the world matrix of the particle system
  18049. * @param directionToUpdate is the direction vector to update with the result
  18050. * @param particle is the particle we are computed the direction for
  18051. */
  18052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18053. /**
  18054. * Clones the current emitter and returns a copy of it
  18055. * @returns the new emitter
  18056. */
  18057. clone(): CylinderDirectedParticleEmitter;
  18058. /**
  18059. * Called by the GPUParticleSystem to setup the update shader
  18060. * @param effect defines the update shader
  18061. */
  18062. applyToShader(effect: Effect): void;
  18063. /**
  18064. * Returns a string to use to update the GPU particles update shader
  18065. * @returns a string containng the defines string
  18066. */
  18067. getEffectDefines(): string;
  18068. /**
  18069. * Returns the string "CylinderDirectedParticleEmitter"
  18070. * @returns a string containing the class name
  18071. */
  18072. getClassName(): string;
  18073. /**
  18074. * Serializes the particle system to a JSON object.
  18075. * @returns the JSON object
  18076. */
  18077. serialize(): any;
  18078. /**
  18079. * Parse properties from a JSON object
  18080. * @param serializationObject defines the JSON object
  18081. */
  18082. parse(serializationObject: any): void;
  18083. }
  18084. }
  18085. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18086. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18087. import { Effect } from "babylonjs/Materials/effect";
  18088. import { Particle } from "babylonjs/Particles/particle";
  18089. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18090. /**
  18091. * Particle emitter emitting particles from the inside of a hemisphere.
  18092. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18093. */
  18094. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18095. /**
  18096. * The radius of the emission hemisphere.
  18097. */
  18098. radius: number;
  18099. /**
  18100. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18101. */
  18102. radiusRange: number;
  18103. /**
  18104. * How much to randomize the particle direction [0-1].
  18105. */
  18106. directionRandomizer: number;
  18107. /**
  18108. * Creates a new instance HemisphericParticleEmitter
  18109. * @param radius the radius of the emission hemisphere (1 by default)
  18110. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18111. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18112. */
  18113. constructor(
  18114. /**
  18115. * The radius of the emission hemisphere.
  18116. */
  18117. radius?: number,
  18118. /**
  18119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18120. */
  18121. radiusRange?: number,
  18122. /**
  18123. * How much to randomize the particle direction [0-1].
  18124. */
  18125. directionRandomizer?: number);
  18126. /**
  18127. * Called by the particle System when the direction is computed for the created particle.
  18128. * @param worldMatrix is the world matrix of the particle system
  18129. * @param directionToUpdate is the direction vector to update with the result
  18130. * @param particle is the particle we are computed the direction for
  18131. */
  18132. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18133. /**
  18134. * Called by the particle System when the position is computed for the created particle.
  18135. * @param worldMatrix is the world matrix of the particle system
  18136. * @param positionToUpdate is the position vector to update with the result
  18137. * @param particle is the particle we are computed the position for
  18138. */
  18139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18140. /**
  18141. * Clones the current emitter and returns a copy of it
  18142. * @returns the new emitter
  18143. */
  18144. clone(): HemisphericParticleEmitter;
  18145. /**
  18146. * Called by the GPUParticleSystem to setup the update shader
  18147. * @param effect defines the update shader
  18148. */
  18149. applyToShader(effect: Effect): void;
  18150. /**
  18151. * Returns a string to use to update the GPU particles update shader
  18152. * @returns a string containng the defines string
  18153. */
  18154. getEffectDefines(): string;
  18155. /**
  18156. * Returns the string "HemisphericParticleEmitter"
  18157. * @returns a string containing the class name
  18158. */
  18159. getClassName(): string;
  18160. /**
  18161. * Serializes the particle system to a JSON object.
  18162. * @returns the JSON object
  18163. */
  18164. serialize(): any;
  18165. /**
  18166. * Parse properties from a JSON object
  18167. * @param serializationObject defines the JSON object
  18168. */
  18169. parse(serializationObject: any): void;
  18170. }
  18171. }
  18172. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18173. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18174. import { Effect } from "babylonjs/Materials/effect";
  18175. import { Particle } from "babylonjs/Particles/particle";
  18176. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18177. /**
  18178. * Particle emitter emitting particles from a point.
  18179. * It emits the particles randomly between 2 given directions.
  18180. */
  18181. export class PointParticleEmitter implements IParticleEmitterType {
  18182. /**
  18183. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18184. */
  18185. direction1: Vector3;
  18186. /**
  18187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18188. */
  18189. direction2: Vector3;
  18190. /**
  18191. * Creates a new instance PointParticleEmitter
  18192. */
  18193. constructor();
  18194. /**
  18195. * Called by the particle System when the direction is computed for the created particle.
  18196. * @param worldMatrix is the world matrix of the particle system
  18197. * @param directionToUpdate is the direction vector to update with the result
  18198. * @param particle is the particle we are computed the direction for
  18199. */
  18200. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18201. /**
  18202. * Called by the particle System when the position is computed for the created particle.
  18203. * @param worldMatrix is the world matrix of the particle system
  18204. * @param positionToUpdate is the position vector to update with the result
  18205. * @param particle is the particle we are computed the position for
  18206. */
  18207. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18208. /**
  18209. * Clones the current emitter and returns a copy of it
  18210. * @returns the new emitter
  18211. */
  18212. clone(): PointParticleEmitter;
  18213. /**
  18214. * Called by the GPUParticleSystem to setup the update shader
  18215. * @param effect defines the update shader
  18216. */
  18217. applyToShader(effect: Effect): void;
  18218. /**
  18219. * Returns a string to use to update the GPU particles update shader
  18220. * @returns a string containng the defines string
  18221. */
  18222. getEffectDefines(): string;
  18223. /**
  18224. * Returns the string "PointParticleEmitter"
  18225. * @returns a string containing the class name
  18226. */
  18227. getClassName(): string;
  18228. /**
  18229. * Serializes the particle system to a JSON object.
  18230. * @returns the JSON object
  18231. */
  18232. serialize(): any;
  18233. /**
  18234. * Parse properties from a JSON object
  18235. * @param serializationObject defines the JSON object
  18236. */
  18237. parse(serializationObject: any): void;
  18238. }
  18239. }
  18240. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18241. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18242. import { Effect } from "babylonjs/Materials/effect";
  18243. import { Particle } from "babylonjs/Particles/particle";
  18244. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18245. /**
  18246. * Particle emitter emitting particles from the inside of a sphere.
  18247. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18248. */
  18249. export class SphereParticleEmitter implements IParticleEmitterType {
  18250. /**
  18251. * The radius of the emission sphere.
  18252. */
  18253. radius: number;
  18254. /**
  18255. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18256. */
  18257. radiusRange: number;
  18258. /**
  18259. * How much to randomize the particle direction [0-1].
  18260. */
  18261. directionRandomizer: number;
  18262. /**
  18263. * Creates a new instance SphereParticleEmitter
  18264. * @param radius the radius of the emission sphere (1 by default)
  18265. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18266. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18267. */
  18268. constructor(
  18269. /**
  18270. * The radius of the emission sphere.
  18271. */
  18272. radius?: number,
  18273. /**
  18274. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18275. */
  18276. radiusRange?: number,
  18277. /**
  18278. * How much to randomize the particle direction [0-1].
  18279. */
  18280. directionRandomizer?: number);
  18281. /**
  18282. * Called by the particle System when the direction is computed for the created particle.
  18283. * @param worldMatrix is the world matrix of the particle system
  18284. * @param directionToUpdate is the direction vector to update with the result
  18285. * @param particle is the particle we are computed the direction for
  18286. */
  18287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18288. /**
  18289. * Called by the particle System when the position is computed for the created particle.
  18290. * @param worldMatrix is the world matrix of the particle system
  18291. * @param positionToUpdate is the position vector to update with the result
  18292. * @param particle is the particle we are computed the position for
  18293. */
  18294. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18295. /**
  18296. * Clones the current emitter and returns a copy of it
  18297. * @returns the new emitter
  18298. */
  18299. clone(): SphereParticleEmitter;
  18300. /**
  18301. * Called by the GPUParticleSystem to setup the update shader
  18302. * @param effect defines the update shader
  18303. */
  18304. applyToShader(effect: Effect): void;
  18305. /**
  18306. * Returns a string to use to update the GPU particles update shader
  18307. * @returns a string containng the defines string
  18308. */
  18309. getEffectDefines(): string;
  18310. /**
  18311. * Returns the string "SphereParticleEmitter"
  18312. * @returns a string containing the class name
  18313. */
  18314. getClassName(): string;
  18315. /**
  18316. * Serializes the particle system to a JSON object.
  18317. * @returns the JSON object
  18318. */
  18319. serialize(): any;
  18320. /**
  18321. * Parse properties from a JSON object
  18322. * @param serializationObject defines the JSON object
  18323. */
  18324. parse(serializationObject: any): void;
  18325. }
  18326. /**
  18327. * Particle emitter emitting particles from the inside of a sphere.
  18328. * It emits the particles randomly between two vectors.
  18329. */
  18330. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18331. /**
  18332. * The min limit of the emission direction.
  18333. */
  18334. direction1: Vector3;
  18335. /**
  18336. * The max limit of the emission direction.
  18337. */
  18338. direction2: Vector3;
  18339. /**
  18340. * Creates a new instance SphereDirectedParticleEmitter
  18341. * @param radius the radius of the emission sphere (1 by default)
  18342. * @param direction1 the min limit of the emission direction (up vector by default)
  18343. * @param direction2 the max limit of the emission direction (up vector by default)
  18344. */
  18345. constructor(radius?: number,
  18346. /**
  18347. * The min limit of the emission direction.
  18348. */
  18349. direction1?: Vector3,
  18350. /**
  18351. * The max limit of the emission direction.
  18352. */
  18353. direction2?: Vector3);
  18354. /**
  18355. * Called by the particle System when the direction is computed for the created particle.
  18356. * @param worldMatrix is the world matrix of the particle system
  18357. * @param directionToUpdate is the direction vector to update with the result
  18358. * @param particle is the particle we are computed the direction for
  18359. */
  18360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18361. /**
  18362. * Clones the current emitter and returns a copy of it
  18363. * @returns the new emitter
  18364. */
  18365. clone(): SphereDirectedParticleEmitter;
  18366. /**
  18367. * Called by the GPUParticleSystem to setup the update shader
  18368. * @param effect defines the update shader
  18369. */
  18370. applyToShader(effect: Effect): void;
  18371. /**
  18372. * Returns a string to use to update the GPU particles update shader
  18373. * @returns a string containng the defines string
  18374. */
  18375. getEffectDefines(): string;
  18376. /**
  18377. * Returns the string "SphereDirectedParticleEmitter"
  18378. * @returns a string containing the class name
  18379. */
  18380. getClassName(): string;
  18381. /**
  18382. * Serializes the particle system to a JSON object.
  18383. * @returns the JSON object
  18384. */
  18385. serialize(): any;
  18386. /**
  18387. * Parse properties from a JSON object
  18388. * @param serializationObject defines the JSON object
  18389. */
  18390. parse(serializationObject: any): void;
  18391. }
  18392. }
  18393. declare module "babylonjs/Particles/EmitterTypes/index" {
  18394. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18395. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18396. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18397. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18398. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18399. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18400. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18401. }
  18402. declare module "babylonjs/Particles/IParticleSystem" {
  18403. import { Nullable } from "babylonjs/types";
  18404. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18405. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18408. import { Texture } from "babylonjs/Materials/Textures/texture";
  18409. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18410. import { Scene } from "babylonjs/scene";
  18411. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18412. import { Animation } from "babylonjs/Animations/animation";
  18413. /**
  18414. * Interface representing a particle system in Babylon.js.
  18415. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18416. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18417. */
  18418. export interface IParticleSystem {
  18419. /**
  18420. * List of animations used by the particle system.
  18421. */
  18422. animations: Animation[];
  18423. /**
  18424. * The id of the Particle system.
  18425. */
  18426. id: string;
  18427. /**
  18428. * The name of the Particle system.
  18429. */
  18430. name: string;
  18431. /**
  18432. * The emitter represents the Mesh or position we are attaching the particle system to.
  18433. */
  18434. emitter: Nullable<AbstractMesh | Vector3>;
  18435. /**
  18436. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18437. */
  18438. isBillboardBased: boolean;
  18439. /**
  18440. * The rendering group used by the Particle system to chose when to render.
  18441. */
  18442. renderingGroupId: number;
  18443. /**
  18444. * The layer mask we are rendering the particles through.
  18445. */
  18446. layerMask: number;
  18447. /**
  18448. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18449. */
  18450. updateSpeed: number;
  18451. /**
  18452. * The amount of time the particle system is running (depends of the overall update speed).
  18453. */
  18454. targetStopDuration: number;
  18455. /**
  18456. * The texture used to render each particle. (this can be a spritesheet)
  18457. */
  18458. particleTexture: Nullable<Texture>;
  18459. /**
  18460. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18461. */
  18462. blendMode: number;
  18463. /**
  18464. * Minimum life time of emitting particles.
  18465. */
  18466. minLifeTime: number;
  18467. /**
  18468. * Maximum life time of emitting particles.
  18469. */
  18470. maxLifeTime: number;
  18471. /**
  18472. * Minimum Size of emitting particles.
  18473. */
  18474. minSize: number;
  18475. /**
  18476. * Maximum Size of emitting particles.
  18477. */
  18478. maxSize: number;
  18479. /**
  18480. * Minimum scale of emitting particles on X axis.
  18481. */
  18482. minScaleX: number;
  18483. /**
  18484. * Maximum scale of emitting particles on X axis.
  18485. */
  18486. maxScaleX: number;
  18487. /**
  18488. * Minimum scale of emitting particles on Y axis.
  18489. */
  18490. minScaleY: number;
  18491. /**
  18492. * Maximum scale of emitting particles on Y axis.
  18493. */
  18494. maxScaleY: number;
  18495. /**
  18496. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18497. */
  18498. color1: Color4;
  18499. /**
  18500. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18501. */
  18502. color2: Color4;
  18503. /**
  18504. * Color the particle will have at the end of its lifetime.
  18505. */
  18506. colorDead: Color4;
  18507. /**
  18508. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18509. */
  18510. emitRate: number;
  18511. /**
  18512. * You can use gravity if you want to give an orientation to your particles.
  18513. */
  18514. gravity: Vector3;
  18515. /**
  18516. * Minimum power of emitting particles.
  18517. */
  18518. minEmitPower: number;
  18519. /**
  18520. * Maximum power of emitting particles.
  18521. */
  18522. maxEmitPower: number;
  18523. /**
  18524. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18525. */
  18526. minAngularSpeed: number;
  18527. /**
  18528. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18529. */
  18530. maxAngularSpeed: number;
  18531. /**
  18532. * Gets or sets the minimal initial rotation in radians.
  18533. */
  18534. minInitialRotation: number;
  18535. /**
  18536. * Gets or sets the maximal initial rotation in radians.
  18537. */
  18538. maxInitialRotation: number;
  18539. /**
  18540. * The particle emitter type defines the emitter used by the particle system.
  18541. * It can be for example box, sphere, or cone...
  18542. */
  18543. particleEmitterType: Nullable<IParticleEmitterType>;
  18544. /**
  18545. * Defines the delay in milliseconds before starting the system (0 by default)
  18546. */
  18547. startDelay: number;
  18548. /**
  18549. * 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
  18550. */
  18551. preWarmCycles: number;
  18552. /**
  18553. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18554. */
  18555. preWarmStepOffset: number;
  18556. /**
  18557. * 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)
  18558. */
  18559. spriteCellChangeSpeed: number;
  18560. /**
  18561. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18562. */
  18563. startSpriteCellID: number;
  18564. /**
  18565. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18566. */
  18567. endSpriteCellID: number;
  18568. /**
  18569. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18570. */
  18571. spriteCellWidth: number;
  18572. /**
  18573. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18574. */
  18575. spriteCellHeight: number;
  18576. /**
  18577. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18578. */
  18579. spriteRandomStartCell: boolean;
  18580. /**
  18581. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18582. */
  18583. isAnimationSheetEnabled: boolean;
  18584. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18585. translationPivot: Vector2;
  18586. /**
  18587. * Gets or sets a texture used to add random noise to particle positions
  18588. */
  18589. noiseTexture: Nullable<BaseTexture>;
  18590. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18591. noiseStrength: Vector3;
  18592. /**
  18593. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18594. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18595. */
  18596. billboardMode: number;
  18597. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18598. limitVelocityDamping: number;
  18599. /**
  18600. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18601. */
  18602. beginAnimationOnStart: boolean;
  18603. /**
  18604. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18605. */
  18606. beginAnimationFrom: number;
  18607. /**
  18608. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18609. */
  18610. beginAnimationTo: number;
  18611. /**
  18612. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18613. */
  18614. beginAnimationLoop: boolean;
  18615. /**
  18616. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18617. */
  18618. disposeOnStop: boolean;
  18619. /**
  18620. * Gets the maximum number of particles active at the same time.
  18621. * @returns The max number of active particles.
  18622. */
  18623. getCapacity(): number;
  18624. /**
  18625. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18626. * @returns True if it has been started, otherwise false.
  18627. */
  18628. isStarted(): boolean;
  18629. /**
  18630. * Animates the particle system for this frame.
  18631. */
  18632. animate(): void;
  18633. /**
  18634. * Renders the particle system in its current state.
  18635. * @returns the current number of particles
  18636. */
  18637. render(): number;
  18638. /**
  18639. * Dispose the particle system and frees its associated resources.
  18640. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18641. */
  18642. dispose(disposeTexture?: boolean): void;
  18643. /**
  18644. * Clones the particle system.
  18645. * @param name The name of the cloned object
  18646. * @param newEmitter The new emitter to use
  18647. * @returns the cloned particle system
  18648. */
  18649. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18650. /**
  18651. * Serializes the particle system to a JSON object.
  18652. * @returns the JSON object
  18653. */
  18654. serialize(): any;
  18655. /**
  18656. * Rebuild the particle system
  18657. */
  18658. rebuild(): void;
  18659. /**
  18660. * Starts the particle system and begins to emit
  18661. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18662. */
  18663. start(delay?: number): void;
  18664. /**
  18665. * Stops the particle system.
  18666. */
  18667. stop(): void;
  18668. /**
  18669. * Remove all active particles
  18670. */
  18671. reset(): void;
  18672. /**
  18673. * Is this system ready to be used/rendered
  18674. * @return true if the system is ready
  18675. */
  18676. isReady(): boolean;
  18677. /**
  18678. * Adds a new color gradient
  18679. * @param gradient defines the gradient to use (between 0 and 1)
  18680. * @param color1 defines the color to affect to the specified gradient
  18681. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18682. * @returns the current particle system
  18683. */
  18684. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18685. /**
  18686. * Remove a specific color gradient
  18687. * @param gradient defines the gradient to remove
  18688. * @returns the current particle system
  18689. */
  18690. removeColorGradient(gradient: number): IParticleSystem;
  18691. /**
  18692. * Adds a new size gradient
  18693. * @param gradient defines the gradient to use (between 0 and 1)
  18694. * @param factor defines the size factor to affect to the specified gradient
  18695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18696. * @returns the current particle system
  18697. */
  18698. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18699. /**
  18700. * Remove a specific size gradient
  18701. * @param gradient defines the gradient to remove
  18702. * @returns the current particle system
  18703. */
  18704. removeSizeGradient(gradient: number): IParticleSystem;
  18705. /**
  18706. * Gets the current list of color gradients.
  18707. * You must use addColorGradient and removeColorGradient to udpate this list
  18708. * @returns the list of color gradients
  18709. */
  18710. getColorGradients(): Nullable<Array<ColorGradient>>;
  18711. /**
  18712. * Gets the current list of size gradients.
  18713. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18714. * @returns the list of size gradients
  18715. */
  18716. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18717. /**
  18718. * Gets the current list of angular speed gradients.
  18719. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18720. * @returns the list of angular speed gradients
  18721. */
  18722. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18723. /**
  18724. * Adds a new angular speed gradient
  18725. * @param gradient defines the gradient to use (between 0 and 1)
  18726. * @param factor defines the angular speed to affect to the specified gradient
  18727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18728. * @returns the current particle system
  18729. */
  18730. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18731. /**
  18732. * Remove a specific angular speed gradient
  18733. * @param gradient defines the gradient to remove
  18734. * @returns the current particle system
  18735. */
  18736. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18737. /**
  18738. * Gets the current list of velocity gradients.
  18739. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18740. * @returns the list of velocity gradients
  18741. */
  18742. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18743. /**
  18744. * Adds a new velocity gradient
  18745. * @param gradient defines the gradient to use (between 0 and 1)
  18746. * @param factor defines the velocity to affect to the specified gradient
  18747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18748. * @returns the current particle system
  18749. */
  18750. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18751. /**
  18752. * Remove a specific velocity gradient
  18753. * @param gradient defines the gradient to remove
  18754. * @returns the current particle system
  18755. */
  18756. removeVelocityGradient(gradient: number): IParticleSystem;
  18757. /**
  18758. * Gets the current list of limit velocity gradients.
  18759. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18760. * @returns the list of limit velocity gradients
  18761. */
  18762. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18763. /**
  18764. * Adds a new limit velocity gradient
  18765. * @param gradient defines the gradient to use (between 0 and 1)
  18766. * @param factor defines the limit velocity to affect to the specified gradient
  18767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18768. * @returns the current particle system
  18769. */
  18770. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18771. /**
  18772. * Remove a specific limit velocity gradient
  18773. * @param gradient defines the gradient to remove
  18774. * @returns the current particle system
  18775. */
  18776. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18777. /**
  18778. * Adds a new drag gradient
  18779. * @param gradient defines the gradient to use (between 0 and 1)
  18780. * @param factor defines the drag to affect to the specified gradient
  18781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18782. * @returns the current particle system
  18783. */
  18784. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18785. /**
  18786. * Remove a specific drag gradient
  18787. * @param gradient defines the gradient to remove
  18788. * @returns the current particle system
  18789. */
  18790. removeDragGradient(gradient: number): IParticleSystem;
  18791. /**
  18792. * Gets the current list of drag gradients.
  18793. * You must use addDragGradient and removeDragGradient to udpate this list
  18794. * @returns the list of drag gradients
  18795. */
  18796. getDragGradients(): Nullable<Array<FactorGradient>>;
  18797. /**
  18798. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18799. * @param gradient defines the gradient to use (between 0 and 1)
  18800. * @param factor defines the emit rate to affect to the specified gradient
  18801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18802. * @returns the current particle system
  18803. */
  18804. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18805. /**
  18806. * Remove a specific emit rate gradient
  18807. * @param gradient defines the gradient to remove
  18808. * @returns the current particle system
  18809. */
  18810. removeEmitRateGradient(gradient: number): IParticleSystem;
  18811. /**
  18812. * Gets the current list of emit rate gradients.
  18813. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18814. * @returns the list of emit rate gradients
  18815. */
  18816. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18817. /**
  18818. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18819. * @param gradient defines the gradient to use (between 0 and 1)
  18820. * @param factor defines the start size to affect to the specified gradient
  18821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18822. * @returns the current particle system
  18823. */
  18824. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18825. /**
  18826. * Remove a specific start size gradient
  18827. * @param gradient defines the gradient to remove
  18828. * @returns the current particle system
  18829. */
  18830. removeStartSizeGradient(gradient: number): IParticleSystem;
  18831. /**
  18832. * Gets the current list of start size gradients.
  18833. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18834. * @returns the list of start size gradients
  18835. */
  18836. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18837. /**
  18838. * Adds a new life time gradient
  18839. * @param gradient defines the gradient to use (between 0 and 1)
  18840. * @param factor defines the life time factor to affect to the specified gradient
  18841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18842. * @returns the current particle system
  18843. */
  18844. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18845. /**
  18846. * Remove a specific life time gradient
  18847. * @param gradient defines the gradient to remove
  18848. * @returns the current particle system
  18849. */
  18850. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18851. /**
  18852. * Gets the current list of life time gradients.
  18853. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18854. * @returns the list of life time gradients
  18855. */
  18856. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18857. /**
  18858. * Gets the current list of color gradients.
  18859. * You must use addColorGradient and removeColorGradient to udpate this list
  18860. * @returns the list of color gradients
  18861. */
  18862. getColorGradients(): Nullable<Array<ColorGradient>>;
  18863. /**
  18864. * Adds a new ramp gradient used to remap particle colors
  18865. * @param gradient defines the gradient to use (between 0 and 1)
  18866. * @param color defines the color to affect to the specified gradient
  18867. * @returns the current particle system
  18868. */
  18869. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18870. /**
  18871. * Gets the current list of ramp gradients.
  18872. * You must use addRampGradient and removeRampGradient to udpate this list
  18873. * @returns the list of ramp gradients
  18874. */
  18875. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18876. /** Gets or sets a boolean indicating that ramp gradients must be used
  18877. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18878. */
  18879. useRampGradients: boolean;
  18880. /**
  18881. * Adds a new color remap gradient
  18882. * @param gradient defines the gradient to use (between 0 and 1)
  18883. * @param min defines the color remap minimal range
  18884. * @param max defines the color remap maximal range
  18885. * @returns the current particle system
  18886. */
  18887. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18888. /**
  18889. * Gets the current list of color remap gradients.
  18890. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18891. * @returns the list of color remap gradients
  18892. */
  18893. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18894. /**
  18895. * Adds a new alpha remap gradient
  18896. * @param gradient defines the gradient to use (between 0 and 1)
  18897. * @param min defines the alpha remap minimal range
  18898. * @param max defines the alpha remap maximal range
  18899. * @returns the current particle system
  18900. */
  18901. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18902. /**
  18903. * Gets the current list of alpha remap gradients.
  18904. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18905. * @returns the list of alpha remap gradients
  18906. */
  18907. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18908. /**
  18909. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18910. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18911. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18912. * @returns the emitter
  18913. */
  18914. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18915. /**
  18916. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18917. * @param radius The radius of the hemisphere to emit from
  18918. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18919. * @returns the emitter
  18920. */
  18921. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18922. /**
  18923. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18924. * @param radius The radius of the sphere to emit from
  18925. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18926. * @returns the emitter
  18927. */
  18928. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18929. /**
  18930. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18931. * @param radius The radius of the sphere to emit from
  18932. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18933. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18934. * @returns the emitter
  18935. */
  18936. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18937. /**
  18938. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18939. * @param radius The radius of the emission cylinder
  18940. * @param height The height of the emission cylinder
  18941. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18942. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18943. * @returns the emitter
  18944. */
  18945. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18946. /**
  18947. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18948. * @param radius The radius of the cylinder to emit from
  18949. * @param height The height of the emission cylinder
  18950. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18951. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18952. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18953. * @returns the emitter
  18954. */
  18955. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18956. /**
  18957. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18958. * @param radius The radius of the cone to emit from
  18959. * @param angle The base angle of the cone
  18960. * @returns the emitter
  18961. */
  18962. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18963. /**
  18964. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18965. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18966. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18967. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18968. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18969. * @returns the emitter
  18970. */
  18971. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18972. /**
  18973. * Get hosting scene
  18974. * @returns the scene
  18975. */
  18976. getScene(): Scene;
  18977. }
  18978. }
  18979. declare module "babylonjs/Meshes/instancedMesh" {
  18980. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  18981. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18982. import { Camera } from "babylonjs/Cameras/camera";
  18983. import { Node } from "babylonjs/node";
  18984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18985. import { Mesh } from "babylonjs/Meshes/mesh";
  18986. import { Material } from "babylonjs/Materials/material";
  18987. import { Skeleton } from "babylonjs/Bones/skeleton";
  18988. import { Light } from "babylonjs/Lights/light";
  18989. /**
  18990. * Creates an instance based on a source mesh.
  18991. */
  18992. export class InstancedMesh extends AbstractMesh {
  18993. private _sourceMesh;
  18994. private _currentLOD;
  18995. /** @hidden */
  18996. _indexInSourceMeshInstanceArray: number;
  18997. constructor(name: string, source: Mesh);
  18998. /**
  18999. * Returns the string "InstancedMesh".
  19000. */
  19001. getClassName(): string;
  19002. /** Gets the list of lights affecting that mesh */
  19003. readonly lightSources: Light[];
  19004. _resyncLightSources(): void;
  19005. _resyncLighSource(light: Light): void;
  19006. _removeLightSource(light: Light): void;
  19007. /**
  19008. * If the source mesh receives shadows
  19009. */
  19010. readonly receiveShadows: boolean;
  19011. /**
  19012. * The material of the source mesh
  19013. */
  19014. readonly material: Nullable<Material>;
  19015. /**
  19016. * Visibility of the source mesh
  19017. */
  19018. readonly visibility: number;
  19019. /**
  19020. * Skeleton of the source mesh
  19021. */
  19022. readonly skeleton: Nullable<Skeleton>;
  19023. /**
  19024. * Rendering ground id of the source mesh
  19025. */
  19026. renderingGroupId: number;
  19027. /**
  19028. * Returns the total number of vertices (integer).
  19029. */
  19030. getTotalVertices(): number;
  19031. /**
  19032. * Returns a positive integer : the total number of indices in this mesh geometry.
  19033. * @returns the numner of indices or zero if the mesh has no geometry.
  19034. */
  19035. getTotalIndices(): number;
  19036. /**
  19037. * The source mesh of the instance
  19038. */
  19039. readonly sourceMesh: Mesh;
  19040. /**
  19041. * Is this node ready to be used/rendered
  19042. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19043. * @return {boolean} is it ready
  19044. */
  19045. isReady(completeCheck?: boolean): boolean;
  19046. /**
  19047. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19048. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19049. * @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.
  19050. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19051. */
  19052. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19053. /**
  19054. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19055. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19056. * The `data` are either a numeric array either a Float32Array.
  19057. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19058. * 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).
  19059. * Note that a new underlying VertexBuffer object is created each call.
  19060. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19061. *
  19062. * Possible `kind` values :
  19063. * - VertexBuffer.PositionKind
  19064. * - VertexBuffer.UVKind
  19065. * - VertexBuffer.UV2Kind
  19066. * - VertexBuffer.UV3Kind
  19067. * - VertexBuffer.UV4Kind
  19068. * - VertexBuffer.UV5Kind
  19069. * - VertexBuffer.UV6Kind
  19070. * - VertexBuffer.ColorKind
  19071. * - VertexBuffer.MatricesIndicesKind
  19072. * - VertexBuffer.MatricesIndicesExtraKind
  19073. * - VertexBuffer.MatricesWeightsKind
  19074. * - VertexBuffer.MatricesWeightsExtraKind
  19075. *
  19076. * Returns the Mesh.
  19077. */
  19078. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19079. /**
  19080. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19081. * If the mesh has no geometry, it is simply returned as it is.
  19082. * The `data` are either a numeric array either a Float32Array.
  19083. * No new underlying VertexBuffer object is created.
  19084. * 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.
  19085. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19086. *
  19087. * Possible `kind` values :
  19088. * - VertexBuffer.PositionKind
  19089. * - VertexBuffer.UVKind
  19090. * - VertexBuffer.UV2Kind
  19091. * - VertexBuffer.UV3Kind
  19092. * - VertexBuffer.UV4Kind
  19093. * - VertexBuffer.UV5Kind
  19094. * - VertexBuffer.UV6Kind
  19095. * - VertexBuffer.ColorKind
  19096. * - VertexBuffer.MatricesIndicesKind
  19097. * - VertexBuffer.MatricesIndicesExtraKind
  19098. * - VertexBuffer.MatricesWeightsKind
  19099. * - VertexBuffer.MatricesWeightsExtraKind
  19100. *
  19101. * Returns the Mesh.
  19102. */
  19103. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19104. /**
  19105. * Sets the mesh indices.
  19106. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19107. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19108. * This method creates a new index buffer each call.
  19109. * Returns the Mesh.
  19110. */
  19111. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19112. /**
  19113. * Boolean : True if the mesh owns the requested kind of data.
  19114. */
  19115. isVerticesDataPresent(kind: string): boolean;
  19116. /**
  19117. * Returns an array of indices (IndicesArray).
  19118. */
  19119. getIndices(): Nullable<IndicesArray>;
  19120. readonly _positions: Nullable<Vector3[]>;
  19121. /**
  19122. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19123. * This means the mesh underlying bounding box and sphere are recomputed.
  19124. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19125. * @returns the current mesh
  19126. */
  19127. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19128. /** @hidden */
  19129. _preActivate(): InstancedMesh;
  19130. /** @hidden */
  19131. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19132. /** @hidden */
  19133. _postActivate(): void;
  19134. getWorldMatrix(): Matrix;
  19135. readonly isAnInstance: boolean;
  19136. /**
  19137. * Returns the current associated LOD AbstractMesh.
  19138. */
  19139. getLOD(camera: Camera): AbstractMesh;
  19140. /** @hidden */
  19141. _syncSubMeshes(): InstancedMesh;
  19142. /** @hidden */
  19143. _generatePointsArray(): boolean;
  19144. /**
  19145. * Creates a new InstancedMesh from the current mesh.
  19146. * - name (string) : the cloned mesh name
  19147. * - newParent (optional Node) : the optional Node to parent the clone to.
  19148. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19149. *
  19150. * Returns the clone.
  19151. */
  19152. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19153. /**
  19154. * Disposes the InstancedMesh.
  19155. * Returns nothing.
  19156. */
  19157. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19158. }
  19159. }
  19160. declare module "babylonjs/Materials/shaderMaterial" {
  19161. import { Scene } from "babylonjs/scene";
  19162. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19164. import { Mesh } from "babylonjs/Meshes/mesh";
  19165. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19166. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19167. import { Texture } from "babylonjs/Materials/Textures/texture";
  19168. import { Material } from "babylonjs/Materials/material";
  19169. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19170. /**
  19171. * Defines the options associated with the creation of a shader material.
  19172. */
  19173. export interface IShaderMaterialOptions {
  19174. /**
  19175. * Does the material work in alpha blend mode
  19176. */
  19177. needAlphaBlending: boolean;
  19178. /**
  19179. * Does the material work in alpha test mode
  19180. */
  19181. needAlphaTesting: boolean;
  19182. /**
  19183. * The list of attribute names used in the shader
  19184. */
  19185. attributes: string[];
  19186. /**
  19187. * The list of unifrom names used in the shader
  19188. */
  19189. uniforms: string[];
  19190. /**
  19191. * The list of UBO names used in the shader
  19192. */
  19193. uniformBuffers: string[];
  19194. /**
  19195. * The list of sampler names used in the shader
  19196. */
  19197. samplers: string[];
  19198. /**
  19199. * The list of defines used in the shader
  19200. */
  19201. defines: string[];
  19202. }
  19203. /**
  19204. * 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.
  19205. *
  19206. * This returned material effects how the mesh will look based on the code in the shaders.
  19207. *
  19208. * @see http://doc.babylonjs.com/how_to/shader_material
  19209. */
  19210. export class ShaderMaterial extends Material {
  19211. private _shaderPath;
  19212. private _options;
  19213. private _textures;
  19214. private _textureArrays;
  19215. private _floats;
  19216. private _ints;
  19217. private _floatsArrays;
  19218. private _colors3;
  19219. private _colors3Arrays;
  19220. private _colors4;
  19221. private _colors4Arrays;
  19222. private _vectors2;
  19223. private _vectors3;
  19224. private _vectors4;
  19225. private _matrices;
  19226. private _matrices3x3;
  19227. private _matrices2x2;
  19228. private _vectors2Arrays;
  19229. private _vectors3Arrays;
  19230. private _vectors4Arrays;
  19231. private _cachedWorldViewMatrix;
  19232. private _cachedWorldViewProjectionMatrix;
  19233. private _renderId;
  19234. /**
  19235. * Instantiate a new shader material.
  19236. * 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.
  19237. * This returned material effects how the mesh will look based on the code in the shaders.
  19238. * @see http://doc.babylonjs.com/how_to/shader_material
  19239. * @param name Define the name of the material in the scene
  19240. * @param scene Define the scene the material belongs to
  19241. * @param shaderPath Defines the route to the shader code in one of three ways:
  19242. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19243. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19244. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19245. * @param options Define the options used to create the shader
  19246. */
  19247. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19248. /**
  19249. * Gets the options used to compile the shader.
  19250. * They can be modified to trigger a new compilation
  19251. */
  19252. readonly options: IShaderMaterialOptions;
  19253. /**
  19254. * Gets the current class name of the material e.g. "ShaderMaterial"
  19255. * Mainly use in serialization.
  19256. * @returns the class name
  19257. */
  19258. getClassName(): string;
  19259. /**
  19260. * Specifies if the material will require alpha blending
  19261. * @returns a boolean specifying if alpha blending is needed
  19262. */
  19263. needAlphaBlending(): boolean;
  19264. /**
  19265. * Specifies if this material should be rendered in alpha test mode
  19266. * @returns a boolean specifying if an alpha test is needed.
  19267. */
  19268. needAlphaTesting(): boolean;
  19269. private _checkUniform;
  19270. /**
  19271. * Set a texture in the shader.
  19272. * @param name Define the name of the uniform samplers as defined in the shader
  19273. * @param texture Define the texture to bind to this sampler
  19274. * @return the material itself allowing "fluent" like uniform updates
  19275. */
  19276. setTexture(name: string, texture: Texture): ShaderMaterial;
  19277. /**
  19278. * Set a texture array in the shader.
  19279. * @param name Define the name of the uniform sampler array as defined in the shader
  19280. * @param textures Define the list of textures to bind to this sampler
  19281. * @return the material itself allowing "fluent" like uniform updates
  19282. */
  19283. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19284. /**
  19285. * Set a float in the shader.
  19286. * @param name Define the name of the uniform as defined in the shader
  19287. * @param value Define the value to give to the uniform
  19288. * @return the material itself allowing "fluent" like uniform updates
  19289. */
  19290. setFloat(name: string, value: number): ShaderMaterial;
  19291. /**
  19292. * Set a int in the shader.
  19293. * @param name Define the name of the uniform as defined in the shader
  19294. * @param value Define the value to give to the uniform
  19295. * @return the material itself allowing "fluent" like uniform updates
  19296. */
  19297. setInt(name: string, value: number): ShaderMaterial;
  19298. /**
  19299. * Set an array of floats in the shader.
  19300. * @param name Define the name of the uniform as defined in the shader
  19301. * @param value Define the value to give to the uniform
  19302. * @return the material itself allowing "fluent" like uniform updates
  19303. */
  19304. setFloats(name: string, value: number[]): ShaderMaterial;
  19305. /**
  19306. * Set a vec3 in the shader from a Color3.
  19307. * @param name Define the name of the uniform as defined in the shader
  19308. * @param value Define the value to give to the uniform
  19309. * @return the material itself allowing "fluent" like uniform updates
  19310. */
  19311. setColor3(name: string, value: Color3): ShaderMaterial;
  19312. /**
  19313. * Set a vec3 array in the shader from a Color3 array.
  19314. * @param name Define the name of the uniform as defined in the shader
  19315. * @param value Define the value to give to the uniform
  19316. * @return the material itself allowing "fluent" like uniform updates
  19317. */
  19318. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19319. /**
  19320. * Set a vec4 in the shader from a Color4.
  19321. * @param name Define the name of the uniform as defined in the shader
  19322. * @param value Define the value to give to the uniform
  19323. * @return the material itself allowing "fluent" like uniform updates
  19324. */
  19325. setColor4(name: string, value: Color4): ShaderMaterial;
  19326. /**
  19327. * Set a vec4 array in the shader from a Color4 array.
  19328. * @param name Define the name of the uniform as defined in the shader
  19329. * @param value Define the value to give to the uniform
  19330. * @return the material itself allowing "fluent" like uniform updates
  19331. */
  19332. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19333. /**
  19334. * Set a vec2 in the shader from a Vector2.
  19335. * @param name Define the name of the uniform as defined in the shader
  19336. * @param value Define the value to give to the uniform
  19337. * @return the material itself allowing "fluent" like uniform updates
  19338. */
  19339. setVector2(name: string, value: Vector2): ShaderMaterial;
  19340. /**
  19341. * Set a vec3 in the shader from a Vector3.
  19342. * @param name Define the name of the uniform as defined in the shader
  19343. * @param value Define the value to give to the uniform
  19344. * @return the material itself allowing "fluent" like uniform updates
  19345. */
  19346. setVector3(name: string, value: Vector3): ShaderMaterial;
  19347. /**
  19348. * Set a vec4 in the shader from a Vector4.
  19349. * @param name Define the name of the uniform as defined in the shader
  19350. * @param value Define the value to give to the uniform
  19351. * @return the material itself allowing "fluent" like uniform updates
  19352. */
  19353. setVector4(name: string, value: Vector4): ShaderMaterial;
  19354. /**
  19355. * Set a mat4 in the shader from a Matrix.
  19356. * @param name Define the name of the uniform as defined in the shader
  19357. * @param value Define the value to give to the uniform
  19358. * @return the material itself allowing "fluent" like uniform updates
  19359. */
  19360. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19361. /**
  19362. * Set a mat3 in the shader from a Float32Array.
  19363. * @param name Define the name of the uniform as defined in the shader
  19364. * @param value Define the value to give to the uniform
  19365. * @return the material itself allowing "fluent" like uniform updates
  19366. */
  19367. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19368. /**
  19369. * Set a mat2 in the shader from a Float32Array.
  19370. * @param name Define the name of the uniform as defined in the shader
  19371. * @param value Define the value to give to the uniform
  19372. * @return the material itself allowing "fluent" like uniform updates
  19373. */
  19374. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19375. /**
  19376. * Set a vec2 array in the shader from a number array.
  19377. * @param name Define the name of the uniform as defined in the shader
  19378. * @param value Define the value to give to the uniform
  19379. * @return the material itself allowing "fluent" like uniform updates
  19380. */
  19381. setArray2(name: string, value: number[]): ShaderMaterial;
  19382. /**
  19383. * Set a vec3 array in the shader from a number array.
  19384. * @param name Define the name of the uniform as defined in the shader
  19385. * @param value Define the value to give to the uniform
  19386. * @return the material itself allowing "fluent" like uniform updates
  19387. */
  19388. setArray3(name: string, value: number[]): ShaderMaterial;
  19389. /**
  19390. * Set a vec4 array in the shader from a number array.
  19391. * @param name Define the name of the uniform as defined in the shader
  19392. * @param value Define the value to give to the uniform
  19393. * @return the material itself allowing "fluent" like uniform updates
  19394. */
  19395. setArray4(name: string, value: number[]): ShaderMaterial;
  19396. private _checkCache;
  19397. /**
  19398. * Specifies that the submesh is ready to be used
  19399. * @param mesh defines the mesh to check
  19400. * @param subMesh defines which submesh to check
  19401. * @param useInstances specifies that instances should be used
  19402. * @returns a boolean indicating that the submesh is ready or not
  19403. */
  19404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19405. /**
  19406. * Checks if the material is ready to render the requested mesh
  19407. * @param mesh Define the mesh to render
  19408. * @param useInstances Define whether or not the material is used with instances
  19409. * @returns true if ready, otherwise false
  19410. */
  19411. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19412. /**
  19413. * Binds the world matrix to the material
  19414. * @param world defines the world transformation matrix
  19415. */
  19416. bindOnlyWorldMatrix(world: Matrix): void;
  19417. /**
  19418. * Binds the material to the mesh
  19419. * @param world defines the world transformation matrix
  19420. * @param mesh defines the mesh to bind the material to
  19421. */
  19422. bind(world: Matrix, mesh?: Mesh): void;
  19423. /**
  19424. * Gets the active textures from the material
  19425. * @returns an array of textures
  19426. */
  19427. getActiveTextures(): BaseTexture[];
  19428. /**
  19429. * Specifies if the material uses a texture
  19430. * @param texture defines the texture to check against the material
  19431. * @returns a boolean specifying if the material uses the texture
  19432. */
  19433. hasTexture(texture: BaseTexture): boolean;
  19434. /**
  19435. * Makes a duplicate of the material, and gives it a new name
  19436. * @param name defines the new name for the duplicated material
  19437. * @returns the cloned material
  19438. */
  19439. clone(name: string): ShaderMaterial;
  19440. /**
  19441. * Disposes the material
  19442. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19443. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19444. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19445. */
  19446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19447. /**
  19448. * Serializes this material in a JSON representation
  19449. * @returns the serialized material object
  19450. */
  19451. serialize(): any;
  19452. /**
  19453. * Creates a shader material from parsed shader material data
  19454. * @param source defines the JSON represnetation of the material
  19455. * @param scene defines the hosting scene
  19456. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19457. * @returns a new material
  19458. */
  19459. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19460. }
  19461. }
  19462. declare module "babylonjs/Shaders/color.fragment" {
  19463. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19464. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19465. /** @hidden */
  19466. export var colorPixelShader: {
  19467. name: string;
  19468. shader: string;
  19469. };
  19470. }
  19471. declare module "babylonjs/Shaders/color.vertex" {
  19472. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19473. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19474. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19475. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19476. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19477. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19478. /** @hidden */
  19479. export var colorVertexShader: {
  19480. name: string;
  19481. shader: string;
  19482. };
  19483. }
  19484. declare module "babylonjs/Meshes/linesMesh" {
  19485. import { Nullable } from "babylonjs/types";
  19486. import { Scene } from "babylonjs/scene";
  19487. import { Color3 } from "babylonjs/Maths/math.color";
  19488. import { Node } from "babylonjs/node";
  19489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19490. import { Mesh } from "babylonjs/Meshes/mesh";
  19491. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19492. import { Effect } from "babylonjs/Materials/effect";
  19493. import { Material } from "babylonjs/Materials/material";
  19494. import "babylonjs/Shaders/color.fragment";
  19495. import "babylonjs/Shaders/color.vertex";
  19496. /**
  19497. * Line mesh
  19498. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19499. */
  19500. export class LinesMesh extends Mesh {
  19501. /**
  19502. * If vertex color should be applied to the mesh
  19503. */
  19504. readonly useVertexColor?: boolean | undefined;
  19505. /**
  19506. * If vertex alpha should be applied to the mesh
  19507. */
  19508. readonly useVertexAlpha?: boolean | undefined;
  19509. /**
  19510. * Color of the line (Default: White)
  19511. */
  19512. color: Color3;
  19513. /**
  19514. * Alpha of the line (Default: 1)
  19515. */
  19516. alpha: number;
  19517. /**
  19518. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19519. * This margin is expressed in world space coordinates, so its value may vary.
  19520. * Default value is 0.1
  19521. */
  19522. intersectionThreshold: number;
  19523. private _colorShader;
  19524. private color4;
  19525. /**
  19526. * Creates a new LinesMesh
  19527. * @param name defines the name
  19528. * @param scene defines the hosting scene
  19529. * @param parent defines the parent mesh if any
  19530. * @param source defines the optional source LinesMesh used to clone data from
  19531. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19532. * When false, achieved by calling a clone(), also passing False.
  19533. * This will make creation of children, recursive.
  19534. * @param useVertexColor defines if this LinesMesh supports vertex color
  19535. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19536. */
  19537. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19538. /**
  19539. * If vertex color should be applied to the mesh
  19540. */
  19541. useVertexColor?: boolean | undefined,
  19542. /**
  19543. * If vertex alpha should be applied to the mesh
  19544. */
  19545. useVertexAlpha?: boolean | undefined);
  19546. private _addClipPlaneDefine;
  19547. private _removeClipPlaneDefine;
  19548. isReady(): boolean;
  19549. /**
  19550. * Returns the string "LineMesh"
  19551. */
  19552. getClassName(): string;
  19553. /**
  19554. * @hidden
  19555. */
  19556. /**
  19557. * @hidden
  19558. */
  19559. material: Material;
  19560. /**
  19561. * @hidden
  19562. */
  19563. readonly checkCollisions: boolean;
  19564. /** @hidden */
  19565. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19566. /** @hidden */
  19567. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19568. /**
  19569. * Disposes of the line mesh
  19570. * @param doNotRecurse If children should be disposed
  19571. */
  19572. dispose(doNotRecurse?: boolean): void;
  19573. /**
  19574. * Returns a new LineMesh object cloned from the current one.
  19575. */
  19576. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19577. /**
  19578. * Creates a new InstancedLinesMesh object from the mesh model.
  19579. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19580. * @param name defines the name of the new instance
  19581. * @returns a new InstancedLinesMesh
  19582. */
  19583. createInstance(name: string): InstancedLinesMesh;
  19584. }
  19585. /**
  19586. * Creates an instance based on a source LinesMesh
  19587. */
  19588. export class InstancedLinesMesh extends InstancedMesh {
  19589. /**
  19590. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19591. * This margin is expressed in world space coordinates, so its value may vary.
  19592. * Initilized with the intersectionThreshold value of the source LinesMesh
  19593. */
  19594. intersectionThreshold: number;
  19595. constructor(name: string, source: LinesMesh);
  19596. /**
  19597. * Returns the string "InstancedLinesMesh".
  19598. */
  19599. getClassName(): string;
  19600. }
  19601. }
  19602. declare module "babylonjs/Shaders/line.fragment" {
  19603. /** @hidden */
  19604. export var linePixelShader: {
  19605. name: string;
  19606. shader: string;
  19607. };
  19608. }
  19609. declare module "babylonjs/Shaders/line.vertex" {
  19610. /** @hidden */
  19611. export var lineVertexShader: {
  19612. name: string;
  19613. shader: string;
  19614. };
  19615. }
  19616. declare module "babylonjs/Rendering/edgesRenderer" {
  19617. import { Nullable } from "babylonjs/types";
  19618. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19620. import { Vector3 } from "babylonjs/Maths/math.vector";
  19621. import { IDisposable } from "babylonjs/scene";
  19622. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19623. import "babylonjs/Shaders/line.fragment";
  19624. import "babylonjs/Shaders/line.vertex";
  19625. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19626. module "babylonjs/Meshes/abstractMesh" {
  19627. interface AbstractMesh {
  19628. /**
  19629. * Gets the edgesRenderer associated with the mesh
  19630. */
  19631. edgesRenderer: Nullable<EdgesRenderer>;
  19632. }
  19633. }
  19634. module "babylonjs/Meshes/linesMesh" {
  19635. interface LinesMesh {
  19636. /**
  19637. * Enables the edge rendering mode on the mesh.
  19638. * This mode makes the mesh edges visible
  19639. * @param epsilon defines the maximal distance between two angles to detect a face
  19640. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19641. * @returns the currentAbstractMesh
  19642. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19643. */
  19644. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19645. }
  19646. }
  19647. module "babylonjs/Meshes/linesMesh" {
  19648. interface InstancedLinesMesh {
  19649. /**
  19650. * Enables the edge rendering mode on the mesh.
  19651. * This mode makes the mesh edges visible
  19652. * @param epsilon defines the maximal distance between two angles to detect a face
  19653. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19654. * @returns the current InstancedLinesMesh
  19655. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19656. */
  19657. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19658. }
  19659. }
  19660. /**
  19661. * Defines the minimum contract an Edges renderer should follow.
  19662. */
  19663. export interface IEdgesRenderer extends IDisposable {
  19664. /**
  19665. * Gets or sets a boolean indicating if the edgesRenderer is active
  19666. */
  19667. isEnabled: boolean;
  19668. /**
  19669. * Renders the edges of the attached mesh,
  19670. */
  19671. render(): void;
  19672. /**
  19673. * Checks wether or not the edges renderer is ready to render.
  19674. * @return true if ready, otherwise false.
  19675. */
  19676. isReady(): boolean;
  19677. }
  19678. /**
  19679. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19680. */
  19681. export class EdgesRenderer implements IEdgesRenderer {
  19682. /**
  19683. * Define the size of the edges with an orthographic camera
  19684. */
  19685. edgesWidthScalerForOrthographic: number;
  19686. /**
  19687. * Define the size of the edges with a perspective camera
  19688. */
  19689. edgesWidthScalerForPerspective: number;
  19690. protected _source: AbstractMesh;
  19691. protected _linesPositions: number[];
  19692. protected _linesNormals: number[];
  19693. protected _linesIndices: number[];
  19694. protected _epsilon: number;
  19695. protected _indicesCount: number;
  19696. protected _lineShader: ShaderMaterial;
  19697. protected _ib: DataBuffer;
  19698. protected _buffers: {
  19699. [key: string]: Nullable<VertexBuffer>;
  19700. };
  19701. protected _checkVerticesInsteadOfIndices: boolean;
  19702. private _meshRebuildObserver;
  19703. private _meshDisposeObserver;
  19704. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19705. isEnabled: boolean;
  19706. /**
  19707. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19708. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19709. * @param source Mesh used to create edges
  19710. * @param epsilon sum of angles in adjacency to check for edge
  19711. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19712. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19713. */
  19714. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19715. protected _prepareRessources(): void;
  19716. /** @hidden */
  19717. _rebuild(): void;
  19718. /**
  19719. * Releases the required resources for the edges renderer
  19720. */
  19721. dispose(): void;
  19722. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19723. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19724. /**
  19725. * Checks if the pair of p0 and p1 is en edge
  19726. * @param faceIndex
  19727. * @param edge
  19728. * @param faceNormals
  19729. * @param p0
  19730. * @param p1
  19731. * @private
  19732. */
  19733. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19734. /**
  19735. * push line into the position, normal and index buffer
  19736. * @protected
  19737. */
  19738. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19739. /**
  19740. * Generates lines edges from adjacencjes
  19741. * @private
  19742. */
  19743. _generateEdgesLines(): void;
  19744. /**
  19745. * Checks wether or not the edges renderer is ready to render.
  19746. * @return true if ready, otherwise false.
  19747. */
  19748. isReady(): boolean;
  19749. /**
  19750. * Renders the edges of the attached mesh,
  19751. */
  19752. render(): void;
  19753. }
  19754. /**
  19755. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19756. */
  19757. export class LineEdgesRenderer extends EdgesRenderer {
  19758. /**
  19759. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19760. * @param source LineMesh used to generate edges
  19761. * @param epsilon not important (specified angle for edge detection)
  19762. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19763. */
  19764. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19765. /**
  19766. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19767. */
  19768. _generateEdgesLines(): void;
  19769. }
  19770. }
  19771. declare module "babylonjs/Rendering/renderingGroup" {
  19772. import { SmartArray } from "babylonjs/Misc/smartArray";
  19773. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19775. import { Nullable } from "babylonjs/types";
  19776. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19777. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19778. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19779. import { Material } from "babylonjs/Materials/material";
  19780. import { Scene } from "babylonjs/scene";
  19781. /**
  19782. * This represents the object necessary to create a rendering group.
  19783. * This is exclusively used and created by the rendering manager.
  19784. * To modify the behavior, you use the available helpers in your scene or meshes.
  19785. * @hidden
  19786. */
  19787. export class RenderingGroup {
  19788. index: number;
  19789. private static _zeroVector;
  19790. private _scene;
  19791. private _opaqueSubMeshes;
  19792. private _transparentSubMeshes;
  19793. private _alphaTestSubMeshes;
  19794. private _depthOnlySubMeshes;
  19795. private _particleSystems;
  19796. private _spriteManagers;
  19797. private _opaqueSortCompareFn;
  19798. private _alphaTestSortCompareFn;
  19799. private _transparentSortCompareFn;
  19800. private _renderOpaque;
  19801. private _renderAlphaTest;
  19802. private _renderTransparent;
  19803. /** @hidden */
  19804. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19805. onBeforeTransparentRendering: () => void;
  19806. /**
  19807. * Set the opaque sort comparison function.
  19808. * If null the sub meshes will be render in the order they were created
  19809. */
  19810. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19811. /**
  19812. * Set the alpha test sort comparison function.
  19813. * If null the sub meshes will be render in the order they were created
  19814. */
  19815. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19816. /**
  19817. * Set the transparent sort comparison function.
  19818. * If null the sub meshes will be render in the order they were created
  19819. */
  19820. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19821. /**
  19822. * Creates a new rendering group.
  19823. * @param index The rendering group index
  19824. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19825. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19826. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19827. */
  19828. 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>);
  19829. /**
  19830. * Render all the sub meshes contained in the group.
  19831. * @param customRenderFunction Used to override the default render behaviour of the group.
  19832. * @returns true if rendered some submeshes.
  19833. */
  19834. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19835. /**
  19836. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19837. * @param subMeshes The submeshes to render
  19838. */
  19839. private renderOpaqueSorted;
  19840. /**
  19841. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19842. * @param subMeshes The submeshes to render
  19843. */
  19844. private renderAlphaTestSorted;
  19845. /**
  19846. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19847. * @param subMeshes The submeshes to render
  19848. */
  19849. private renderTransparentSorted;
  19850. /**
  19851. * Renders the submeshes in a specified order.
  19852. * @param subMeshes The submeshes to sort before render
  19853. * @param sortCompareFn The comparison function use to sort
  19854. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19855. * @param transparent Specifies to activate blending if true
  19856. */
  19857. private static renderSorted;
  19858. /**
  19859. * Renders the submeshes in the order they were dispatched (no sort applied).
  19860. * @param subMeshes The submeshes to render
  19861. */
  19862. private static renderUnsorted;
  19863. /**
  19864. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19865. * are rendered back to front if in the same alpha index.
  19866. *
  19867. * @param a The first submesh
  19868. * @param b The second submesh
  19869. * @returns The result of the comparison
  19870. */
  19871. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19872. /**
  19873. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19874. * are rendered back to front.
  19875. *
  19876. * @param a The first submesh
  19877. * @param b The second submesh
  19878. * @returns The result of the comparison
  19879. */
  19880. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19881. /**
  19882. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19883. * are rendered front to back (prevent overdraw).
  19884. *
  19885. * @param a The first submesh
  19886. * @param b The second submesh
  19887. * @returns The result of the comparison
  19888. */
  19889. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19890. /**
  19891. * Resets the different lists of submeshes to prepare a new frame.
  19892. */
  19893. prepare(): void;
  19894. dispose(): void;
  19895. /**
  19896. * Inserts the submesh in its correct queue depending on its material.
  19897. * @param subMesh The submesh to dispatch
  19898. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19899. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19900. */
  19901. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19902. dispatchSprites(spriteManager: ISpriteManager): void;
  19903. dispatchParticles(particleSystem: IParticleSystem): void;
  19904. private _renderParticles;
  19905. private _renderSprites;
  19906. }
  19907. }
  19908. declare module "babylonjs/Rendering/renderingManager" {
  19909. import { Nullable } from "babylonjs/types";
  19910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19911. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19912. import { SmartArray } from "babylonjs/Misc/smartArray";
  19913. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19914. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19915. import { Material } from "babylonjs/Materials/material";
  19916. import { Scene } from "babylonjs/scene";
  19917. import { Camera } from "babylonjs/Cameras/camera";
  19918. /**
  19919. * Interface describing the different options available in the rendering manager
  19920. * regarding Auto Clear between groups.
  19921. */
  19922. export interface IRenderingManagerAutoClearSetup {
  19923. /**
  19924. * Defines whether or not autoclear is enable.
  19925. */
  19926. autoClear: boolean;
  19927. /**
  19928. * Defines whether or not to autoclear the depth buffer.
  19929. */
  19930. depth: boolean;
  19931. /**
  19932. * Defines whether or not to autoclear the stencil buffer.
  19933. */
  19934. stencil: boolean;
  19935. }
  19936. /**
  19937. * This class is used by the onRenderingGroupObservable
  19938. */
  19939. export class RenderingGroupInfo {
  19940. /**
  19941. * The Scene that being rendered
  19942. */
  19943. scene: Scene;
  19944. /**
  19945. * The camera currently used for the rendering pass
  19946. */
  19947. camera: Nullable<Camera>;
  19948. /**
  19949. * The ID of the renderingGroup being processed
  19950. */
  19951. renderingGroupId: number;
  19952. }
  19953. /**
  19954. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19955. * It is enable to manage the different groups as well as the different necessary sort functions.
  19956. * This should not be used directly aside of the few static configurations
  19957. */
  19958. export class RenderingManager {
  19959. /**
  19960. * The max id used for rendering groups (not included)
  19961. */
  19962. static MAX_RENDERINGGROUPS: number;
  19963. /**
  19964. * The min id used for rendering groups (included)
  19965. */
  19966. static MIN_RENDERINGGROUPS: number;
  19967. /**
  19968. * Used to globally prevent autoclearing scenes.
  19969. */
  19970. static AUTOCLEAR: boolean;
  19971. /**
  19972. * @hidden
  19973. */
  19974. _useSceneAutoClearSetup: boolean;
  19975. private _scene;
  19976. private _renderingGroups;
  19977. private _depthStencilBufferAlreadyCleaned;
  19978. private _autoClearDepthStencil;
  19979. private _customOpaqueSortCompareFn;
  19980. private _customAlphaTestSortCompareFn;
  19981. private _customTransparentSortCompareFn;
  19982. private _renderingGroupInfo;
  19983. /**
  19984. * Instantiates a new rendering group for a particular scene
  19985. * @param scene Defines the scene the groups belongs to
  19986. */
  19987. constructor(scene: Scene);
  19988. private _clearDepthStencilBuffer;
  19989. /**
  19990. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19991. * @hidden
  19992. */
  19993. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19994. /**
  19995. * Resets the different information of the group to prepare a new frame
  19996. * @hidden
  19997. */
  19998. reset(): void;
  19999. /**
  20000. * Dispose and release the group and its associated resources.
  20001. * @hidden
  20002. */
  20003. dispose(): void;
  20004. /**
  20005. * Clear the info related to rendering groups preventing retention points during dispose.
  20006. */
  20007. freeRenderingGroups(): void;
  20008. private _prepareRenderingGroup;
  20009. /**
  20010. * Add a sprite manager to the rendering manager in order to render it this frame.
  20011. * @param spriteManager Define the sprite manager to render
  20012. */
  20013. dispatchSprites(spriteManager: ISpriteManager): void;
  20014. /**
  20015. * Add a particle system to the rendering manager in order to render it this frame.
  20016. * @param particleSystem Define the particle system to render
  20017. */
  20018. dispatchParticles(particleSystem: IParticleSystem): void;
  20019. /**
  20020. * Add a submesh to the manager in order to render it this frame
  20021. * @param subMesh The submesh to dispatch
  20022. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20023. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20024. */
  20025. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20026. /**
  20027. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20028. * This allowed control for front to back rendering or reversly depending of the special needs.
  20029. *
  20030. * @param renderingGroupId The rendering group id corresponding to its index
  20031. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20032. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20033. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20034. */
  20035. 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;
  20036. /**
  20037. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20038. *
  20039. * @param renderingGroupId The rendering group id corresponding to its index
  20040. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20041. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20042. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20043. */
  20044. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20045. /**
  20046. * Gets the current auto clear configuration for one rendering group of the rendering
  20047. * manager.
  20048. * @param index the rendering group index to get the information for
  20049. * @returns The auto clear setup for the requested rendering group
  20050. */
  20051. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20052. }
  20053. }
  20054. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20055. import { Observable } from "babylonjs/Misc/observable";
  20056. import { SmartArray } from "babylonjs/Misc/smartArray";
  20057. import { Nullable } from "babylonjs/types";
  20058. import { Camera } from "babylonjs/Cameras/camera";
  20059. import { Scene } from "babylonjs/scene";
  20060. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20061. import { Color4 } from "babylonjs/Maths/math.color";
  20062. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20066. import { Texture } from "babylonjs/Materials/Textures/texture";
  20067. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20068. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20069. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20070. import { Engine } from "babylonjs/Engines/engine";
  20071. /**
  20072. * This Helps creating a texture that will be created from a camera in your scene.
  20073. * It is basically a dynamic texture that could be used to create special effects for instance.
  20074. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20075. */
  20076. export class RenderTargetTexture extends Texture {
  20077. isCube: boolean;
  20078. /**
  20079. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20080. */
  20081. static readonly REFRESHRATE_RENDER_ONCE: number;
  20082. /**
  20083. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20084. */
  20085. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20086. /**
  20087. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20088. * the central point of your effect and can save a lot of performances.
  20089. */
  20090. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20091. /**
  20092. * Use this predicate to dynamically define the list of mesh you want to render.
  20093. * If set, the renderList property will be overwritten.
  20094. */
  20095. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20096. private _renderList;
  20097. /**
  20098. * Use this list to define the list of mesh you want to render.
  20099. */
  20100. renderList: Nullable<Array<AbstractMesh>>;
  20101. private _hookArray;
  20102. /**
  20103. * Define if particles should be rendered in your texture.
  20104. */
  20105. renderParticles: boolean;
  20106. /**
  20107. * Define if sprites should be rendered in your texture.
  20108. */
  20109. renderSprites: boolean;
  20110. /**
  20111. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20112. */
  20113. coordinatesMode: number;
  20114. /**
  20115. * Define the camera used to render the texture.
  20116. */
  20117. activeCamera: Nullable<Camera>;
  20118. /**
  20119. * Override the render function of the texture with your own one.
  20120. */
  20121. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20122. /**
  20123. * Define if camera post processes should be use while rendering the texture.
  20124. */
  20125. useCameraPostProcesses: boolean;
  20126. /**
  20127. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20128. */
  20129. ignoreCameraViewport: boolean;
  20130. private _postProcessManager;
  20131. private _postProcesses;
  20132. private _resizeObserver;
  20133. /**
  20134. * An event triggered when the texture is unbind.
  20135. */
  20136. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20137. /**
  20138. * An event triggered when the texture is unbind.
  20139. */
  20140. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20141. private _onAfterUnbindObserver;
  20142. /**
  20143. * Set a after unbind callback in the texture.
  20144. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20145. */
  20146. onAfterUnbind: () => void;
  20147. /**
  20148. * An event triggered before rendering the texture
  20149. */
  20150. onBeforeRenderObservable: Observable<number>;
  20151. private _onBeforeRenderObserver;
  20152. /**
  20153. * Set a before render callback in the texture.
  20154. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20155. */
  20156. onBeforeRender: (faceIndex: number) => void;
  20157. /**
  20158. * An event triggered after rendering the texture
  20159. */
  20160. onAfterRenderObservable: Observable<number>;
  20161. private _onAfterRenderObserver;
  20162. /**
  20163. * Set a after render callback in the texture.
  20164. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20165. */
  20166. onAfterRender: (faceIndex: number) => void;
  20167. /**
  20168. * An event triggered after the texture clear
  20169. */
  20170. onClearObservable: Observable<Engine>;
  20171. private _onClearObserver;
  20172. /**
  20173. * Set a clear callback in the texture.
  20174. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20175. */
  20176. onClear: (Engine: Engine) => void;
  20177. /**
  20178. * Define the clear color of the Render Target if it should be different from the scene.
  20179. */
  20180. clearColor: Color4;
  20181. protected _size: number | {
  20182. width: number;
  20183. height: number;
  20184. };
  20185. protected _initialSizeParameter: number | {
  20186. width: number;
  20187. height: number;
  20188. } | {
  20189. ratio: number;
  20190. };
  20191. protected _sizeRatio: Nullable<number>;
  20192. /** @hidden */
  20193. _generateMipMaps: boolean;
  20194. protected _renderingManager: RenderingManager;
  20195. /** @hidden */
  20196. _waitingRenderList: string[];
  20197. protected _doNotChangeAspectRatio: boolean;
  20198. protected _currentRefreshId: number;
  20199. protected _refreshRate: number;
  20200. protected _textureMatrix: Matrix;
  20201. protected _samples: number;
  20202. protected _renderTargetOptions: RenderTargetCreationOptions;
  20203. /**
  20204. * Gets render target creation options that were used.
  20205. */
  20206. readonly renderTargetOptions: RenderTargetCreationOptions;
  20207. protected _engine: Engine;
  20208. protected _onRatioRescale(): void;
  20209. /**
  20210. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20211. * It must define where the camera used to render the texture is set
  20212. */
  20213. boundingBoxPosition: Vector3;
  20214. private _boundingBoxSize;
  20215. /**
  20216. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20217. * When defined, the cubemap will switch to local mode
  20218. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20219. * @example https://www.babylonjs-playground.com/#RNASML
  20220. */
  20221. boundingBoxSize: Vector3;
  20222. /**
  20223. * In case the RTT has been created with a depth texture, get the associated
  20224. * depth texture.
  20225. * Otherwise, return null.
  20226. */
  20227. depthStencilTexture: Nullable<InternalTexture>;
  20228. /**
  20229. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20230. * or used a shadow, depth texture...
  20231. * @param name The friendly name of the texture
  20232. * @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)
  20233. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20234. * @param generateMipMaps True if mip maps need to be generated after render.
  20235. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20236. * @param type The type of the buffer in the RTT (int, half float, float...)
  20237. * @param isCube True if a cube texture needs to be created
  20238. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20239. * @param generateDepthBuffer True to generate a depth buffer
  20240. * @param generateStencilBuffer True to generate a stencil buffer
  20241. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20242. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20243. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20244. */
  20245. constructor(name: string, size: number | {
  20246. width: number;
  20247. height: number;
  20248. } | {
  20249. ratio: number;
  20250. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20251. /**
  20252. * Creates a depth stencil texture.
  20253. * This is only available in WebGL 2 or with the depth texture extension available.
  20254. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20255. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20256. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20257. */
  20258. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20259. private _processSizeParameter;
  20260. /**
  20261. * Define the number of samples to use in case of MSAA.
  20262. * It defaults to one meaning no MSAA has been enabled.
  20263. */
  20264. samples: number;
  20265. /**
  20266. * Resets the refresh counter of the texture and start bak from scratch.
  20267. * Could be useful to regenerate the texture if it is setup to render only once.
  20268. */
  20269. resetRefreshCounter(): void;
  20270. /**
  20271. * Define the refresh rate of the texture or the rendering frequency.
  20272. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20273. */
  20274. refreshRate: number;
  20275. /**
  20276. * Adds a post process to the render target rendering passes.
  20277. * @param postProcess define the post process to add
  20278. */
  20279. addPostProcess(postProcess: PostProcess): void;
  20280. /**
  20281. * Clear all the post processes attached to the render target
  20282. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20283. */
  20284. clearPostProcesses(dispose?: boolean): void;
  20285. /**
  20286. * Remove one of the post process from the list of attached post processes to the texture
  20287. * @param postProcess define the post process to remove from the list
  20288. */
  20289. removePostProcess(postProcess: PostProcess): void;
  20290. /** @hidden */
  20291. _shouldRender(): boolean;
  20292. /**
  20293. * Gets the actual render size of the texture.
  20294. * @returns the width of the render size
  20295. */
  20296. getRenderSize(): number;
  20297. /**
  20298. * Gets the actual render width of the texture.
  20299. * @returns the width of the render size
  20300. */
  20301. getRenderWidth(): number;
  20302. /**
  20303. * Gets the actual render height of the texture.
  20304. * @returns the height of the render size
  20305. */
  20306. getRenderHeight(): number;
  20307. /**
  20308. * Get if the texture can be rescaled or not.
  20309. */
  20310. readonly canRescale: boolean;
  20311. /**
  20312. * Resize the texture using a ratio.
  20313. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20314. */
  20315. scale(ratio: number): void;
  20316. /**
  20317. * Get the texture reflection matrix used to rotate/transform the reflection.
  20318. * @returns the reflection matrix
  20319. */
  20320. getReflectionTextureMatrix(): Matrix;
  20321. /**
  20322. * Resize the texture to a new desired size.
  20323. * Be carrefull as it will recreate all the data in the new texture.
  20324. * @param size Define the new size. It can be:
  20325. * - a number for squared texture,
  20326. * - an object containing { width: number, height: number }
  20327. * - or an object containing a ratio { ratio: number }
  20328. */
  20329. resize(size: number | {
  20330. width: number;
  20331. height: number;
  20332. } | {
  20333. ratio: number;
  20334. }): void;
  20335. /**
  20336. * Renders all the objects from the render list into the texture.
  20337. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20338. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20339. */
  20340. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20341. private _bestReflectionRenderTargetDimension;
  20342. /**
  20343. * @hidden
  20344. * @param faceIndex face index to bind to if this is a cubetexture
  20345. */
  20346. _bindFrameBuffer(faceIndex?: number): void;
  20347. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20348. private renderToTarget;
  20349. /**
  20350. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20351. * This allowed control for front to back rendering or reversly depending of the special needs.
  20352. *
  20353. * @param renderingGroupId The rendering group id corresponding to its index
  20354. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20355. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20356. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20357. */
  20358. 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;
  20359. /**
  20360. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20361. *
  20362. * @param renderingGroupId The rendering group id corresponding to its index
  20363. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20364. */
  20365. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20366. /**
  20367. * Clones the texture.
  20368. * @returns the cloned texture
  20369. */
  20370. clone(): RenderTargetTexture;
  20371. /**
  20372. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20373. * @returns The JSON representation of the texture
  20374. */
  20375. serialize(): any;
  20376. /**
  20377. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20378. */
  20379. disposeFramebufferObjects(): void;
  20380. /**
  20381. * Dispose the texture and release its associated resources.
  20382. */
  20383. dispose(): void;
  20384. /** @hidden */
  20385. _rebuild(): void;
  20386. /**
  20387. * Clear the info related to rendering groups preventing retention point in material dispose.
  20388. */
  20389. freeRenderingGroups(): void;
  20390. /**
  20391. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20392. * @returns the view count
  20393. */
  20394. getViewCount(): number;
  20395. }
  20396. }
  20397. declare module "babylonjs/Materials/material" {
  20398. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20399. import { SmartArray } from "babylonjs/Misc/smartArray";
  20400. import { Observable } from "babylonjs/Misc/observable";
  20401. import { Nullable } from "babylonjs/types";
  20402. import { Scene } from "babylonjs/scene";
  20403. import { Matrix } from "babylonjs/Maths/math.vector";
  20404. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20406. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20407. import { Effect } from "babylonjs/Materials/effect";
  20408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20409. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20410. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20411. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20412. import { Mesh } from "babylonjs/Meshes/mesh";
  20413. import { Animation } from "babylonjs/Animations/animation";
  20414. /**
  20415. * Base class for the main features of a material in Babylon.js
  20416. */
  20417. export class Material implements IAnimatable {
  20418. /**
  20419. * Returns the triangle fill mode
  20420. */
  20421. static readonly TriangleFillMode: number;
  20422. /**
  20423. * Returns the wireframe mode
  20424. */
  20425. static readonly WireFrameFillMode: number;
  20426. /**
  20427. * Returns the point fill mode
  20428. */
  20429. static readonly PointFillMode: number;
  20430. /**
  20431. * Returns the point list draw mode
  20432. */
  20433. static readonly PointListDrawMode: number;
  20434. /**
  20435. * Returns the line list draw mode
  20436. */
  20437. static readonly LineListDrawMode: number;
  20438. /**
  20439. * Returns the line loop draw mode
  20440. */
  20441. static readonly LineLoopDrawMode: number;
  20442. /**
  20443. * Returns the line strip draw mode
  20444. */
  20445. static readonly LineStripDrawMode: number;
  20446. /**
  20447. * Returns the triangle strip draw mode
  20448. */
  20449. static readonly TriangleStripDrawMode: number;
  20450. /**
  20451. * Returns the triangle fan draw mode
  20452. */
  20453. static readonly TriangleFanDrawMode: number;
  20454. /**
  20455. * Stores the clock-wise side orientation
  20456. */
  20457. static readonly ClockWiseSideOrientation: number;
  20458. /**
  20459. * Stores the counter clock-wise side orientation
  20460. */
  20461. static readonly CounterClockWiseSideOrientation: number;
  20462. /**
  20463. * The dirty texture flag value
  20464. */
  20465. static readonly TextureDirtyFlag: number;
  20466. /**
  20467. * The dirty light flag value
  20468. */
  20469. static readonly LightDirtyFlag: number;
  20470. /**
  20471. * The dirty fresnel flag value
  20472. */
  20473. static readonly FresnelDirtyFlag: number;
  20474. /**
  20475. * The dirty attribute flag value
  20476. */
  20477. static readonly AttributesDirtyFlag: number;
  20478. /**
  20479. * The dirty misc flag value
  20480. */
  20481. static readonly MiscDirtyFlag: number;
  20482. /**
  20483. * The all dirty flag value
  20484. */
  20485. static readonly AllDirtyFlag: number;
  20486. /**
  20487. * The ID of the material
  20488. */
  20489. id: string;
  20490. /**
  20491. * Gets or sets the unique id of the material
  20492. */
  20493. uniqueId: number;
  20494. /**
  20495. * The name of the material
  20496. */
  20497. name: string;
  20498. /**
  20499. * Gets or sets user defined metadata
  20500. */
  20501. metadata: any;
  20502. /**
  20503. * For internal use only. Please do not use.
  20504. */
  20505. reservedDataStore: any;
  20506. /**
  20507. * Specifies if the ready state should be checked on each call
  20508. */
  20509. checkReadyOnEveryCall: boolean;
  20510. /**
  20511. * Specifies if the ready state should be checked once
  20512. */
  20513. checkReadyOnlyOnce: boolean;
  20514. /**
  20515. * The state of the material
  20516. */
  20517. state: string;
  20518. /**
  20519. * The alpha value of the material
  20520. */
  20521. protected _alpha: number;
  20522. /**
  20523. * List of inspectable custom properties (used by the Inspector)
  20524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20525. */
  20526. inspectableCustomProperties: IInspectable[];
  20527. /**
  20528. * Sets the alpha value of the material
  20529. */
  20530. /**
  20531. * Gets the alpha value of the material
  20532. */
  20533. alpha: number;
  20534. /**
  20535. * Specifies if back face culling is enabled
  20536. */
  20537. protected _backFaceCulling: boolean;
  20538. /**
  20539. * Sets the back-face culling state
  20540. */
  20541. /**
  20542. * Gets the back-face culling state
  20543. */
  20544. backFaceCulling: boolean;
  20545. /**
  20546. * Stores the value for side orientation
  20547. */
  20548. sideOrientation: number;
  20549. /**
  20550. * Callback triggered when the material is compiled
  20551. */
  20552. onCompiled: Nullable<(effect: Effect) => void>;
  20553. /**
  20554. * Callback triggered when an error occurs
  20555. */
  20556. onError: Nullable<(effect: Effect, errors: string) => void>;
  20557. /**
  20558. * Callback triggered to get the render target textures
  20559. */
  20560. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20561. /**
  20562. * Gets a boolean indicating that current material needs to register RTT
  20563. */
  20564. readonly hasRenderTargetTextures: boolean;
  20565. /**
  20566. * Specifies if the material should be serialized
  20567. */
  20568. doNotSerialize: boolean;
  20569. /**
  20570. * @hidden
  20571. */
  20572. _storeEffectOnSubMeshes: boolean;
  20573. /**
  20574. * Stores the animations for the material
  20575. */
  20576. animations: Nullable<Array<Animation>>;
  20577. /**
  20578. * An event triggered when the material is disposed
  20579. */
  20580. onDisposeObservable: Observable<Material>;
  20581. /**
  20582. * An observer which watches for dispose events
  20583. */
  20584. private _onDisposeObserver;
  20585. private _onUnBindObservable;
  20586. /**
  20587. * Called during a dispose event
  20588. */
  20589. onDispose: () => void;
  20590. private _onBindObservable;
  20591. /**
  20592. * An event triggered when the material is bound
  20593. */
  20594. readonly onBindObservable: Observable<AbstractMesh>;
  20595. /**
  20596. * An observer which watches for bind events
  20597. */
  20598. private _onBindObserver;
  20599. /**
  20600. * Called during a bind event
  20601. */
  20602. onBind: (Mesh: AbstractMesh) => void;
  20603. /**
  20604. * An event triggered when the material is unbound
  20605. */
  20606. readonly onUnBindObservable: Observable<Material>;
  20607. /**
  20608. * Stores the value of the alpha mode
  20609. */
  20610. private _alphaMode;
  20611. /**
  20612. * Sets the value of the alpha mode.
  20613. *
  20614. * | Value | Type | Description |
  20615. * | --- | --- | --- |
  20616. * | 0 | ALPHA_DISABLE | |
  20617. * | 1 | ALPHA_ADD | |
  20618. * | 2 | ALPHA_COMBINE | |
  20619. * | 3 | ALPHA_SUBTRACT | |
  20620. * | 4 | ALPHA_MULTIPLY | |
  20621. * | 5 | ALPHA_MAXIMIZED | |
  20622. * | 6 | ALPHA_ONEONE | |
  20623. * | 7 | ALPHA_PREMULTIPLIED | |
  20624. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20625. * | 9 | ALPHA_INTERPOLATE | |
  20626. * | 10 | ALPHA_SCREENMODE | |
  20627. *
  20628. */
  20629. /**
  20630. * Gets the value of the alpha mode
  20631. */
  20632. alphaMode: number;
  20633. /**
  20634. * Stores the state of the need depth pre-pass value
  20635. */
  20636. private _needDepthPrePass;
  20637. /**
  20638. * Sets the need depth pre-pass value
  20639. */
  20640. /**
  20641. * Gets the depth pre-pass value
  20642. */
  20643. needDepthPrePass: boolean;
  20644. /**
  20645. * Specifies if depth writing should be disabled
  20646. */
  20647. disableDepthWrite: boolean;
  20648. /**
  20649. * Specifies if depth writing should be forced
  20650. */
  20651. forceDepthWrite: boolean;
  20652. /**
  20653. * Specifies if there should be a separate pass for culling
  20654. */
  20655. separateCullingPass: boolean;
  20656. /**
  20657. * Stores the state specifing if fog should be enabled
  20658. */
  20659. private _fogEnabled;
  20660. /**
  20661. * Sets the state for enabling fog
  20662. */
  20663. /**
  20664. * Gets the value of the fog enabled state
  20665. */
  20666. fogEnabled: boolean;
  20667. /**
  20668. * Stores the size of points
  20669. */
  20670. pointSize: number;
  20671. /**
  20672. * Stores the z offset value
  20673. */
  20674. zOffset: number;
  20675. /**
  20676. * Gets a value specifying if wireframe mode is enabled
  20677. */
  20678. /**
  20679. * Sets the state of wireframe mode
  20680. */
  20681. wireframe: boolean;
  20682. /**
  20683. * Gets the value specifying if point clouds are enabled
  20684. */
  20685. /**
  20686. * Sets the state of point cloud mode
  20687. */
  20688. pointsCloud: boolean;
  20689. /**
  20690. * Gets the material fill mode
  20691. */
  20692. /**
  20693. * Sets the material fill mode
  20694. */
  20695. fillMode: number;
  20696. /**
  20697. * @hidden
  20698. * Stores the effects for the material
  20699. */
  20700. _effect: Nullable<Effect>;
  20701. /**
  20702. * @hidden
  20703. * Specifies if the material was previously ready
  20704. */
  20705. _wasPreviouslyReady: boolean;
  20706. /**
  20707. * Specifies if uniform buffers should be used
  20708. */
  20709. private _useUBO;
  20710. /**
  20711. * Stores a reference to the scene
  20712. */
  20713. private _scene;
  20714. /**
  20715. * Stores the fill mode state
  20716. */
  20717. private _fillMode;
  20718. /**
  20719. * Specifies if the depth write state should be cached
  20720. */
  20721. private _cachedDepthWriteState;
  20722. /**
  20723. * Stores the uniform buffer
  20724. */
  20725. protected _uniformBuffer: UniformBuffer;
  20726. /** @hidden */
  20727. _indexInSceneMaterialArray: number;
  20728. /** @hidden */
  20729. meshMap: Nullable<{
  20730. [id: string]: AbstractMesh | undefined;
  20731. }>;
  20732. /**
  20733. * Creates a material instance
  20734. * @param name defines the name of the material
  20735. * @param scene defines the scene to reference
  20736. * @param doNotAdd specifies if the material should be added to the scene
  20737. */
  20738. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20739. /**
  20740. * Returns a string representation of the current material
  20741. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20742. * @returns a string with material information
  20743. */
  20744. toString(fullDetails?: boolean): string;
  20745. /**
  20746. * Gets the class name of the material
  20747. * @returns a string with the class name of the material
  20748. */
  20749. getClassName(): string;
  20750. /**
  20751. * Specifies if updates for the material been locked
  20752. */
  20753. readonly isFrozen: boolean;
  20754. /**
  20755. * Locks updates for the material
  20756. */
  20757. freeze(): void;
  20758. /**
  20759. * Unlocks updates for the material
  20760. */
  20761. unfreeze(): void;
  20762. /**
  20763. * Specifies if the material is ready to be used
  20764. * @param mesh defines the mesh to check
  20765. * @param useInstances specifies if instances should be used
  20766. * @returns a boolean indicating if the material is ready to be used
  20767. */
  20768. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20769. /**
  20770. * Specifies that the submesh is ready to be used
  20771. * @param mesh defines the mesh to check
  20772. * @param subMesh defines which submesh to check
  20773. * @param useInstances specifies that instances should be used
  20774. * @returns a boolean indicating that the submesh is ready or not
  20775. */
  20776. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20777. /**
  20778. * Returns the material effect
  20779. * @returns the effect associated with the material
  20780. */
  20781. getEffect(): Nullable<Effect>;
  20782. /**
  20783. * Returns the current scene
  20784. * @returns a Scene
  20785. */
  20786. getScene(): Scene;
  20787. /**
  20788. * Specifies if the material will require alpha blending
  20789. * @returns a boolean specifying if alpha blending is needed
  20790. */
  20791. needAlphaBlending(): boolean;
  20792. /**
  20793. * Specifies if the mesh will require alpha blending
  20794. * @param mesh defines the mesh to check
  20795. * @returns a boolean specifying if alpha blending is needed for the mesh
  20796. */
  20797. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20798. /**
  20799. * Specifies if this material should be rendered in alpha test mode
  20800. * @returns a boolean specifying if an alpha test is needed.
  20801. */
  20802. needAlphaTesting(): boolean;
  20803. /**
  20804. * Gets the texture used for the alpha test
  20805. * @returns the texture to use for alpha testing
  20806. */
  20807. getAlphaTestTexture(): Nullable<BaseTexture>;
  20808. /**
  20809. * Marks the material to indicate that it needs to be re-calculated
  20810. */
  20811. markDirty(): void;
  20812. /** @hidden */
  20813. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20814. /**
  20815. * Binds the material to the mesh
  20816. * @param world defines the world transformation matrix
  20817. * @param mesh defines the mesh to bind the material to
  20818. */
  20819. bind(world: Matrix, mesh?: Mesh): void;
  20820. /**
  20821. * Binds the submesh to the material
  20822. * @param world defines the world transformation matrix
  20823. * @param mesh defines the mesh containing the submesh
  20824. * @param subMesh defines the submesh to bind the material to
  20825. */
  20826. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20827. /**
  20828. * Binds the world matrix to the material
  20829. * @param world defines the world transformation matrix
  20830. */
  20831. bindOnlyWorldMatrix(world: Matrix): void;
  20832. /**
  20833. * Binds the scene's uniform buffer to the effect.
  20834. * @param effect defines the effect to bind to the scene uniform buffer
  20835. * @param sceneUbo defines the uniform buffer storing scene data
  20836. */
  20837. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20838. /**
  20839. * Binds the view matrix to the effect
  20840. * @param effect defines the effect to bind the view matrix to
  20841. */
  20842. bindView(effect: Effect): void;
  20843. /**
  20844. * Binds the view projection matrix to the effect
  20845. * @param effect defines the effect to bind the view projection matrix to
  20846. */
  20847. bindViewProjection(effect: Effect): void;
  20848. /**
  20849. * Specifies if material alpha testing should be turned on for the mesh
  20850. * @param mesh defines the mesh to check
  20851. */
  20852. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20853. /**
  20854. * Processes to execute after binding the material to a mesh
  20855. * @param mesh defines the rendered mesh
  20856. */
  20857. protected _afterBind(mesh?: Mesh): void;
  20858. /**
  20859. * Unbinds the material from the mesh
  20860. */
  20861. unbind(): void;
  20862. /**
  20863. * Gets the active textures from the material
  20864. * @returns an array of textures
  20865. */
  20866. getActiveTextures(): BaseTexture[];
  20867. /**
  20868. * Specifies if the material uses a texture
  20869. * @param texture defines the texture to check against the material
  20870. * @returns a boolean specifying if the material uses the texture
  20871. */
  20872. hasTexture(texture: BaseTexture): boolean;
  20873. /**
  20874. * Makes a duplicate of the material, and gives it a new name
  20875. * @param name defines the new name for the duplicated material
  20876. * @returns the cloned material
  20877. */
  20878. clone(name: string): Nullable<Material>;
  20879. /**
  20880. * Gets the meshes bound to the material
  20881. * @returns an array of meshes bound to the material
  20882. */
  20883. getBindedMeshes(): AbstractMesh[];
  20884. /**
  20885. * Force shader compilation
  20886. * @param mesh defines the mesh associated with this material
  20887. * @param onCompiled defines a function to execute once the material is compiled
  20888. * @param options defines the options to configure the compilation
  20889. */
  20890. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20891. clipPlane: boolean;
  20892. }>): void;
  20893. /**
  20894. * Force shader compilation
  20895. * @param mesh defines the mesh that will use this material
  20896. * @param options defines additional options for compiling the shaders
  20897. * @returns a promise that resolves when the compilation completes
  20898. */
  20899. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20900. clipPlane: boolean;
  20901. }>): Promise<void>;
  20902. private static readonly _AllDirtyCallBack;
  20903. private static readonly _ImageProcessingDirtyCallBack;
  20904. private static readonly _TextureDirtyCallBack;
  20905. private static readonly _FresnelDirtyCallBack;
  20906. private static readonly _MiscDirtyCallBack;
  20907. private static readonly _LightsDirtyCallBack;
  20908. private static readonly _AttributeDirtyCallBack;
  20909. private static _FresnelAndMiscDirtyCallBack;
  20910. private static _TextureAndMiscDirtyCallBack;
  20911. private static readonly _DirtyCallbackArray;
  20912. private static readonly _RunDirtyCallBacks;
  20913. /**
  20914. * Marks a define in the material to indicate that it needs to be re-computed
  20915. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20916. */
  20917. markAsDirty(flag: number): void;
  20918. /**
  20919. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20920. * @param func defines a function which checks material defines against the submeshes
  20921. */
  20922. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20923. /**
  20924. * Indicates that we need to re-calculated for all submeshes
  20925. */
  20926. protected _markAllSubMeshesAsAllDirty(): void;
  20927. /**
  20928. * Indicates that image processing needs to be re-calculated for all submeshes
  20929. */
  20930. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20931. /**
  20932. * Indicates that textures need to be re-calculated for all submeshes
  20933. */
  20934. protected _markAllSubMeshesAsTexturesDirty(): void;
  20935. /**
  20936. * Indicates that fresnel needs to be re-calculated for all submeshes
  20937. */
  20938. protected _markAllSubMeshesAsFresnelDirty(): void;
  20939. /**
  20940. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20941. */
  20942. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20943. /**
  20944. * Indicates that lights need to be re-calculated for all submeshes
  20945. */
  20946. protected _markAllSubMeshesAsLightsDirty(): void;
  20947. /**
  20948. * Indicates that attributes need to be re-calculated for all submeshes
  20949. */
  20950. protected _markAllSubMeshesAsAttributesDirty(): void;
  20951. /**
  20952. * Indicates that misc needs to be re-calculated for all submeshes
  20953. */
  20954. protected _markAllSubMeshesAsMiscDirty(): void;
  20955. /**
  20956. * Indicates that textures and misc need to be re-calculated for all submeshes
  20957. */
  20958. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20959. /**
  20960. * Disposes the material
  20961. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20962. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20963. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20964. */
  20965. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20966. /** @hidden */
  20967. private releaseVertexArrayObject;
  20968. /**
  20969. * Serializes this material
  20970. * @returns the serialized material object
  20971. */
  20972. serialize(): any;
  20973. /**
  20974. * Creates a material from parsed material data
  20975. * @param parsedMaterial defines parsed material data
  20976. * @param scene defines the hosting scene
  20977. * @param rootUrl defines the root URL to use to load textures
  20978. * @returns a new material
  20979. */
  20980. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20981. }
  20982. }
  20983. declare module "babylonjs/Materials/multiMaterial" {
  20984. import { Nullable } from "babylonjs/types";
  20985. import { Scene } from "babylonjs/scene";
  20986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20987. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  20988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20989. import { Material } from "babylonjs/Materials/material";
  20990. /**
  20991. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20992. * separate meshes. This can be use to improve performances.
  20993. * @see http://doc.babylonjs.com/how_to/multi_materials
  20994. */
  20995. export class MultiMaterial extends Material {
  20996. private _subMaterials;
  20997. /**
  20998. * Gets or Sets the list of Materials used within the multi material.
  20999. * They need to be ordered according to the submeshes order in the associated mesh
  21000. */
  21001. subMaterials: Nullable<Material>[];
  21002. /**
  21003. * Function used to align with Node.getChildren()
  21004. * @returns the list of Materials used within the multi material
  21005. */
  21006. getChildren(): Nullable<Material>[];
  21007. /**
  21008. * Instantiates a new Multi Material
  21009. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21010. * separate meshes. This can be use to improve performances.
  21011. * @see http://doc.babylonjs.com/how_to/multi_materials
  21012. * @param name Define the name in the scene
  21013. * @param scene Define the scene the material belongs to
  21014. */
  21015. constructor(name: string, scene: Scene);
  21016. private _hookArray;
  21017. /**
  21018. * Get one of the submaterial by its index in the submaterials array
  21019. * @param index The index to look the sub material at
  21020. * @returns The Material if the index has been defined
  21021. */
  21022. getSubMaterial(index: number): Nullable<Material>;
  21023. /**
  21024. * Get the list of active textures for the whole sub materials list.
  21025. * @returns All the textures that will be used during the rendering
  21026. */
  21027. getActiveTextures(): BaseTexture[];
  21028. /**
  21029. * Gets the current class name of the material e.g. "MultiMaterial"
  21030. * Mainly use in serialization.
  21031. * @returns the class name
  21032. */
  21033. getClassName(): string;
  21034. /**
  21035. * Checks if the material is ready to render the requested sub mesh
  21036. * @param mesh Define the mesh the submesh belongs to
  21037. * @param subMesh Define the sub mesh to look readyness for
  21038. * @param useInstances Define whether or not the material is used with instances
  21039. * @returns true if ready, otherwise false
  21040. */
  21041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21042. /**
  21043. * Clones the current material and its related sub materials
  21044. * @param name Define the name of the newly cloned material
  21045. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21046. * @returns the cloned material
  21047. */
  21048. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21049. /**
  21050. * Serializes the materials into a JSON representation.
  21051. * @returns the JSON representation
  21052. */
  21053. serialize(): any;
  21054. /**
  21055. * Dispose the material and release its associated resources
  21056. * @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)
  21057. * @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)
  21058. * @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)
  21059. */
  21060. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21061. /**
  21062. * Creates a MultiMaterial from parsed MultiMaterial data.
  21063. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21064. * @param scene defines the hosting scene
  21065. * @returns a new MultiMaterial
  21066. */
  21067. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21068. }
  21069. }
  21070. declare module "babylonjs/Meshes/subMesh" {
  21071. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21072. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21073. import { Engine } from "babylonjs/Engines/engine";
  21074. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21075. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21076. import { Effect } from "babylonjs/Materials/effect";
  21077. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21078. import { Plane } from "babylonjs/Maths/math.plane";
  21079. import { Collider } from "babylonjs/Collisions/collider";
  21080. import { Material } from "babylonjs/Materials/material";
  21081. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21083. import { Mesh } from "babylonjs/Meshes/mesh";
  21084. import { Ray } from "babylonjs/Culling/ray";
  21085. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21086. /**
  21087. * Base class for submeshes
  21088. */
  21089. export class BaseSubMesh {
  21090. /** @hidden */
  21091. _materialDefines: Nullable<MaterialDefines>;
  21092. /** @hidden */
  21093. _materialEffect: Nullable<Effect>;
  21094. /**
  21095. * Gets associated effect
  21096. */
  21097. readonly effect: Nullable<Effect>;
  21098. /**
  21099. * Sets associated effect (effect used to render this submesh)
  21100. * @param effect defines the effect to associate with
  21101. * @param defines defines the set of defines used to compile this effect
  21102. */
  21103. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21104. }
  21105. /**
  21106. * Defines a subdivision inside a mesh
  21107. */
  21108. export class SubMesh extends BaseSubMesh implements ICullable {
  21109. /** the material index to use */
  21110. materialIndex: number;
  21111. /** vertex index start */
  21112. verticesStart: number;
  21113. /** vertices count */
  21114. verticesCount: number;
  21115. /** index start */
  21116. indexStart: number;
  21117. /** indices count */
  21118. indexCount: number;
  21119. /** @hidden */
  21120. _linesIndexCount: number;
  21121. private _mesh;
  21122. private _renderingMesh;
  21123. private _boundingInfo;
  21124. private _linesIndexBuffer;
  21125. /** @hidden */
  21126. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21127. /** @hidden */
  21128. _trianglePlanes: Plane[];
  21129. /** @hidden */
  21130. _lastColliderTransformMatrix: Nullable<Matrix>;
  21131. /** @hidden */
  21132. _renderId: number;
  21133. /** @hidden */
  21134. _alphaIndex: number;
  21135. /** @hidden */
  21136. _distanceToCamera: number;
  21137. /** @hidden */
  21138. _id: number;
  21139. private _currentMaterial;
  21140. /**
  21141. * Add a new submesh to a mesh
  21142. * @param materialIndex defines the material index to use
  21143. * @param verticesStart defines vertex index start
  21144. * @param verticesCount defines vertices count
  21145. * @param indexStart defines index start
  21146. * @param indexCount defines indices count
  21147. * @param mesh defines the parent mesh
  21148. * @param renderingMesh defines an optional rendering mesh
  21149. * @param createBoundingBox defines if bounding box should be created for this submesh
  21150. * @returns the new submesh
  21151. */
  21152. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21153. /**
  21154. * Creates a new submesh
  21155. * @param materialIndex defines the material index to use
  21156. * @param verticesStart defines vertex index start
  21157. * @param verticesCount defines vertices count
  21158. * @param indexStart defines index start
  21159. * @param indexCount defines indices count
  21160. * @param mesh defines the parent mesh
  21161. * @param renderingMesh defines an optional rendering mesh
  21162. * @param createBoundingBox defines if bounding box should be created for this submesh
  21163. */
  21164. constructor(
  21165. /** the material index to use */
  21166. materialIndex: number,
  21167. /** vertex index start */
  21168. verticesStart: number,
  21169. /** vertices count */
  21170. verticesCount: number,
  21171. /** index start */
  21172. indexStart: number,
  21173. /** indices count */
  21174. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21175. /**
  21176. * Returns true if this submesh covers the entire parent mesh
  21177. * @ignorenaming
  21178. */
  21179. readonly IsGlobal: boolean;
  21180. /**
  21181. * Returns the submesh BoudingInfo object
  21182. * @returns current bounding info (or mesh's one if the submesh is global)
  21183. */
  21184. getBoundingInfo(): BoundingInfo;
  21185. /**
  21186. * Sets the submesh BoundingInfo
  21187. * @param boundingInfo defines the new bounding info to use
  21188. * @returns the SubMesh
  21189. */
  21190. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21191. /**
  21192. * Returns the mesh of the current submesh
  21193. * @return the parent mesh
  21194. */
  21195. getMesh(): AbstractMesh;
  21196. /**
  21197. * Returns the rendering mesh of the submesh
  21198. * @returns the rendering mesh (could be different from parent mesh)
  21199. */
  21200. getRenderingMesh(): Mesh;
  21201. /**
  21202. * Returns the submesh material
  21203. * @returns null or the current material
  21204. */
  21205. getMaterial(): Nullable<Material>;
  21206. /**
  21207. * Sets a new updated BoundingInfo object to the submesh
  21208. * @param data defines an optional position array to use to determine the bounding info
  21209. * @returns the SubMesh
  21210. */
  21211. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21212. /** @hidden */
  21213. _checkCollision(collider: Collider): boolean;
  21214. /**
  21215. * Updates the submesh BoundingInfo
  21216. * @param world defines the world matrix to use to update the bounding info
  21217. * @returns the submesh
  21218. */
  21219. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21220. /**
  21221. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21222. * @param frustumPlanes defines the frustum planes
  21223. * @returns true if the submesh is intersecting with the frustum
  21224. */
  21225. isInFrustum(frustumPlanes: Plane[]): boolean;
  21226. /**
  21227. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21228. * @param frustumPlanes defines the frustum planes
  21229. * @returns true if the submesh is inside the frustum
  21230. */
  21231. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21232. /**
  21233. * Renders the submesh
  21234. * @param enableAlphaMode defines if alpha needs to be used
  21235. * @returns the submesh
  21236. */
  21237. render(enableAlphaMode: boolean): SubMesh;
  21238. /**
  21239. * @hidden
  21240. */
  21241. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21242. /**
  21243. * Checks if the submesh intersects with a ray
  21244. * @param ray defines the ray to test
  21245. * @returns true is the passed ray intersects the submesh bounding box
  21246. */
  21247. canIntersects(ray: Ray): boolean;
  21248. /**
  21249. * Intersects current submesh with a ray
  21250. * @param ray defines the ray to test
  21251. * @param positions defines mesh's positions array
  21252. * @param indices defines mesh's indices array
  21253. * @param fastCheck defines if only bounding info should be used
  21254. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21255. * @returns intersection info or null if no intersection
  21256. */
  21257. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21258. /** @hidden */
  21259. private _intersectLines;
  21260. /** @hidden */
  21261. private _intersectUnIndexedLines;
  21262. /** @hidden */
  21263. private _intersectTriangles;
  21264. /** @hidden */
  21265. private _intersectUnIndexedTriangles;
  21266. /** @hidden */
  21267. _rebuild(): void;
  21268. /**
  21269. * Creates a new submesh from the passed mesh
  21270. * @param newMesh defines the new hosting mesh
  21271. * @param newRenderingMesh defines an optional rendering mesh
  21272. * @returns the new submesh
  21273. */
  21274. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21275. /**
  21276. * Release associated resources
  21277. */
  21278. dispose(): void;
  21279. /**
  21280. * Gets the class name
  21281. * @returns the string "SubMesh".
  21282. */
  21283. getClassName(): string;
  21284. /**
  21285. * Creates a new submesh from indices data
  21286. * @param materialIndex the index of the main mesh material
  21287. * @param startIndex the index where to start the copy in the mesh indices array
  21288. * @param indexCount the number of indices to copy then from the startIndex
  21289. * @param mesh the main mesh to create the submesh from
  21290. * @param renderingMesh the optional rendering mesh
  21291. * @returns a new submesh
  21292. */
  21293. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21294. }
  21295. }
  21296. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21297. /**
  21298. * Class used to represent data loading progression
  21299. */
  21300. export class SceneLoaderFlags {
  21301. private static _ForceFullSceneLoadingForIncremental;
  21302. private static _ShowLoadingScreen;
  21303. private static _CleanBoneMatrixWeights;
  21304. private static _loggingLevel;
  21305. /**
  21306. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21307. */
  21308. static ForceFullSceneLoadingForIncremental: boolean;
  21309. /**
  21310. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21311. */
  21312. static ShowLoadingScreen: boolean;
  21313. /**
  21314. * Defines the current logging level (while loading the scene)
  21315. * @ignorenaming
  21316. */
  21317. static loggingLevel: number;
  21318. /**
  21319. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21320. */
  21321. static CleanBoneMatrixWeights: boolean;
  21322. }
  21323. }
  21324. declare module "babylonjs/Meshes/geometry" {
  21325. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21326. import { Scene } from "babylonjs/scene";
  21327. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21328. import { Engine } from "babylonjs/Engines/engine";
  21329. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21330. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21331. import { Effect } from "babylonjs/Materials/effect";
  21332. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21333. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21334. import { Mesh } from "babylonjs/Meshes/mesh";
  21335. /**
  21336. * Class used to store geometry data (vertex buffers + index buffer)
  21337. */
  21338. export class Geometry implements IGetSetVerticesData {
  21339. /**
  21340. * Gets or sets the ID of the geometry
  21341. */
  21342. id: string;
  21343. /**
  21344. * Gets or sets the unique ID of the geometry
  21345. */
  21346. uniqueId: number;
  21347. /**
  21348. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21349. */
  21350. delayLoadState: number;
  21351. /**
  21352. * Gets the file containing the data to load when running in delay load state
  21353. */
  21354. delayLoadingFile: Nullable<string>;
  21355. /**
  21356. * Callback called when the geometry is updated
  21357. */
  21358. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21359. private _scene;
  21360. private _engine;
  21361. private _meshes;
  21362. private _totalVertices;
  21363. /** @hidden */
  21364. _indices: IndicesArray;
  21365. /** @hidden */
  21366. _vertexBuffers: {
  21367. [key: string]: VertexBuffer;
  21368. };
  21369. private _isDisposed;
  21370. private _extend;
  21371. private _boundingBias;
  21372. /** @hidden */
  21373. _delayInfo: Array<string>;
  21374. private _indexBuffer;
  21375. private _indexBufferIsUpdatable;
  21376. /** @hidden */
  21377. _boundingInfo: Nullable<BoundingInfo>;
  21378. /** @hidden */
  21379. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21380. /** @hidden */
  21381. _softwareSkinningFrameId: number;
  21382. private _vertexArrayObjects;
  21383. private _updatable;
  21384. /** @hidden */
  21385. _positions: Nullable<Vector3[]>;
  21386. /**
  21387. * 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
  21388. */
  21389. /**
  21390. * 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
  21391. */
  21392. boundingBias: Vector2;
  21393. /**
  21394. * Static function used to attach a new empty geometry to a mesh
  21395. * @param mesh defines the mesh to attach the geometry to
  21396. * @returns the new Geometry
  21397. */
  21398. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21399. /**
  21400. * Creates a new geometry
  21401. * @param id defines the unique ID
  21402. * @param scene defines the hosting scene
  21403. * @param vertexData defines the VertexData used to get geometry data
  21404. * @param updatable defines if geometry must be updatable (false by default)
  21405. * @param mesh defines the mesh that will be associated with the geometry
  21406. */
  21407. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21408. /**
  21409. * Gets the current extend of the geometry
  21410. */
  21411. readonly extend: {
  21412. minimum: Vector3;
  21413. maximum: Vector3;
  21414. };
  21415. /**
  21416. * Gets the hosting scene
  21417. * @returns the hosting Scene
  21418. */
  21419. getScene(): Scene;
  21420. /**
  21421. * Gets the hosting engine
  21422. * @returns the hosting Engine
  21423. */
  21424. getEngine(): Engine;
  21425. /**
  21426. * Defines if the geometry is ready to use
  21427. * @returns true if the geometry is ready to be used
  21428. */
  21429. isReady(): boolean;
  21430. /**
  21431. * Gets a value indicating that the geometry should not be serialized
  21432. */
  21433. readonly doNotSerialize: boolean;
  21434. /** @hidden */
  21435. _rebuild(): void;
  21436. /**
  21437. * Affects all geometry data in one call
  21438. * @param vertexData defines the geometry data
  21439. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21440. */
  21441. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21442. /**
  21443. * Set specific vertex data
  21444. * @param kind defines the data kind (Position, normal, etc...)
  21445. * @param data defines the vertex data to use
  21446. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21447. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21448. */
  21449. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21450. /**
  21451. * Removes a specific vertex data
  21452. * @param kind defines the data kind (Position, normal, etc...)
  21453. */
  21454. removeVerticesData(kind: string): void;
  21455. /**
  21456. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21457. * @param buffer defines the vertex buffer to use
  21458. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21459. */
  21460. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21461. /**
  21462. * Update a specific vertex buffer
  21463. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21464. * It will do nothing if the buffer is not updatable
  21465. * @param kind defines the data kind (Position, normal, etc...)
  21466. * @param data defines the data to use
  21467. * @param offset defines the offset in the target buffer where to store the data
  21468. * @param useBytes set to true if the offset is in bytes
  21469. */
  21470. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21471. /**
  21472. * Update a specific vertex buffer
  21473. * This function will create a new buffer if the current one is not updatable
  21474. * @param kind defines the data kind (Position, normal, etc...)
  21475. * @param data defines the data to use
  21476. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21477. */
  21478. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21479. private _updateBoundingInfo;
  21480. /** @hidden */
  21481. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21482. /**
  21483. * Gets total number of vertices
  21484. * @returns the total number of vertices
  21485. */
  21486. getTotalVertices(): number;
  21487. /**
  21488. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21489. * @param kind defines the data kind (Position, normal, etc...)
  21490. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21492. * @returns a float array containing vertex data
  21493. */
  21494. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21495. /**
  21496. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21497. * @param kind defines the data kind (Position, normal, etc...)
  21498. * @returns true if the vertex buffer with the specified kind is updatable
  21499. */
  21500. isVertexBufferUpdatable(kind: string): boolean;
  21501. /**
  21502. * Gets a specific vertex buffer
  21503. * @param kind defines the data kind (Position, normal, etc...)
  21504. * @returns a VertexBuffer
  21505. */
  21506. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21507. /**
  21508. * Returns all vertex buffers
  21509. * @return an object holding all vertex buffers indexed by kind
  21510. */
  21511. getVertexBuffers(): Nullable<{
  21512. [key: string]: VertexBuffer;
  21513. }>;
  21514. /**
  21515. * Gets a boolean indicating if specific vertex buffer is present
  21516. * @param kind defines the data kind (Position, normal, etc...)
  21517. * @returns true if data is present
  21518. */
  21519. isVerticesDataPresent(kind: string): boolean;
  21520. /**
  21521. * Gets a list of all attached data kinds (Position, normal, etc...)
  21522. * @returns a list of string containing all kinds
  21523. */
  21524. getVerticesDataKinds(): string[];
  21525. /**
  21526. * Update index buffer
  21527. * @param indices defines the indices to store in the index buffer
  21528. * @param offset defines the offset in the target buffer where to store the data
  21529. * @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)
  21530. */
  21531. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21532. /**
  21533. * Creates a new index buffer
  21534. * @param indices defines the indices to store in the index buffer
  21535. * @param totalVertices defines the total number of vertices (could be null)
  21536. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21537. */
  21538. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21539. /**
  21540. * Return the total number of indices
  21541. * @returns the total number of indices
  21542. */
  21543. getTotalIndices(): number;
  21544. /**
  21545. * Gets the index buffer array
  21546. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21547. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21548. * @returns the index buffer array
  21549. */
  21550. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21551. /**
  21552. * Gets the index buffer
  21553. * @return the index buffer
  21554. */
  21555. getIndexBuffer(): Nullable<DataBuffer>;
  21556. /** @hidden */
  21557. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21558. /**
  21559. * Release the associated resources for a specific mesh
  21560. * @param mesh defines the source mesh
  21561. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21562. */
  21563. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21564. /**
  21565. * Apply current geometry to a given mesh
  21566. * @param mesh defines the mesh to apply geometry to
  21567. */
  21568. applyToMesh(mesh: Mesh): void;
  21569. private _updateExtend;
  21570. private _applyToMesh;
  21571. private notifyUpdate;
  21572. /**
  21573. * Load the geometry if it was flagged as delay loaded
  21574. * @param scene defines the hosting scene
  21575. * @param onLoaded defines a callback called when the geometry is loaded
  21576. */
  21577. load(scene: Scene, onLoaded?: () => void): void;
  21578. private _queueLoad;
  21579. /**
  21580. * Invert the geometry to move from a right handed system to a left handed one.
  21581. */
  21582. toLeftHanded(): void;
  21583. /** @hidden */
  21584. _resetPointsArrayCache(): void;
  21585. /** @hidden */
  21586. _generatePointsArray(): boolean;
  21587. /**
  21588. * Gets a value indicating if the geometry is disposed
  21589. * @returns true if the geometry was disposed
  21590. */
  21591. isDisposed(): boolean;
  21592. private _disposeVertexArrayObjects;
  21593. /**
  21594. * Free all associated resources
  21595. */
  21596. dispose(): void;
  21597. /**
  21598. * Clone the current geometry into a new geometry
  21599. * @param id defines the unique ID of the new geometry
  21600. * @returns a new geometry object
  21601. */
  21602. copy(id: string): Geometry;
  21603. /**
  21604. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21605. * @return a JSON representation of the current geometry data (without the vertices data)
  21606. */
  21607. serialize(): any;
  21608. private toNumberArray;
  21609. /**
  21610. * Serialize all vertices data into a JSON oject
  21611. * @returns a JSON representation of the current geometry data
  21612. */
  21613. serializeVerticeData(): any;
  21614. /**
  21615. * Extracts a clone of a mesh geometry
  21616. * @param mesh defines the source mesh
  21617. * @param id defines the unique ID of the new geometry object
  21618. * @returns the new geometry object
  21619. */
  21620. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21621. /**
  21622. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21623. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21624. * Be aware Math.random() could cause collisions, but:
  21625. * "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"
  21626. * @returns a string containing a new GUID
  21627. */
  21628. static RandomId(): string;
  21629. /** @hidden */
  21630. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21631. private static _CleanMatricesWeights;
  21632. /**
  21633. * Create a new geometry from persisted data (Using .babylon file format)
  21634. * @param parsedVertexData defines the persisted data
  21635. * @param scene defines the hosting scene
  21636. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21637. * @returns the new geometry object
  21638. */
  21639. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21640. }
  21641. }
  21642. declare module "babylonjs/Meshes/mesh.vertexData" {
  21643. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21644. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21645. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21646. import { Geometry } from "babylonjs/Meshes/geometry";
  21647. import { Mesh } from "babylonjs/Meshes/mesh";
  21648. /**
  21649. * Define an interface for all classes that will get and set the data on vertices
  21650. */
  21651. export interface IGetSetVerticesData {
  21652. /**
  21653. * Gets a boolean indicating if specific vertex data is present
  21654. * @param kind defines the vertex data kind to use
  21655. * @returns true is data kind is present
  21656. */
  21657. isVerticesDataPresent(kind: string): boolean;
  21658. /**
  21659. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21660. * @param kind defines the data kind (Position, normal, etc...)
  21661. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21662. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21663. * @returns a float array containing vertex data
  21664. */
  21665. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21666. /**
  21667. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21668. * @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.
  21669. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21670. * @returns the indices array or an empty array if the mesh has no geometry
  21671. */
  21672. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21673. /**
  21674. * Set specific vertex data
  21675. * @param kind defines the data kind (Position, normal, etc...)
  21676. * @param data defines the vertex data to use
  21677. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21678. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21679. */
  21680. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21681. /**
  21682. * Update a specific associated vertex buffer
  21683. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21684. * - VertexBuffer.PositionKind
  21685. * - VertexBuffer.UVKind
  21686. * - VertexBuffer.UV2Kind
  21687. * - VertexBuffer.UV3Kind
  21688. * - VertexBuffer.UV4Kind
  21689. * - VertexBuffer.UV5Kind
  21690. * - VertexBuffer.UV6Kind
  21691. * - VertexBuffer.ColorKind
  21692. * - VertexBuffer.MatricesIndicesKind
  21693. * - VertexBuffer.MatricesIndicesExtraKind
  21694. * - VertexBuffer.MatricesWeightsKind
  21695. * - VertexBuffer.MatricesWeightsExtraKind
  21696. * @param data defines the data source
  21697. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21698. * @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)
  21699. */
  21700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21701. /**
  21702. * Creates a new index buffer
  21703. * @param indices defines the indices to store in the index buffer
  21704. * @param totalVertices defines the total number of vertices (could be null)
  21705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21706. */
  21707. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21708. }
  21709. /**
  21710. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21711. */
  21712. export class VertexData {
  21713. /**
  21714. * Mesh side orientation : usually the external or front surface
  21715. */
  21716. static readonly FRONTSIDE: number;
  21717. /**
  21718. * Mesh side orientation : usually the internal or back surface
  21719. */
  21720. static readonly BACKSIDE: number;
  21721. /**
  21722. * Mesh side orientation : both internal and external or front and back surfaces
  21723. */
  21724. static readonly DOUBLESIDE: number;
  21725. /**
  21726. * Mesh side orientation : by default, `FRONTSIDE`
  21727. */
  21728. static readonly DEFAULTSIDE: number;
  21729. /**
  21730. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21731. */
  21732. positions: Nullable<FloatArray>;
  21733. /**
  21734. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21735. */
  21736. normals: Nullable<FloatArray>;
  21737. /**
  21738. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21739. */
  21740. tangents: Nullable<FloatArray>;
  21741. /**
  21742. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21743. */
  21744. uvs: Nullable<FloatArray>;
  21745. /**
  21746. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21747. */
  21748. uvs2: Nullable<FloatArray>;
  21749. /**
  21750. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21751. */
  21752. uvs3: Nullable<FloatArray>;
  21753. /**
  21754. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21755. */
  21756. uvs4: Nullable<FloatArray>;
  21757. /**
  21758. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21759. */
  21760. uvs5: Nullable<FloatArray>;
  21761. /**
  21762. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21763. */
  21764. uvs6: Nullable<FloatArray>;
  21765. /**
  21766. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21767. */
  21768. colors: Nullable<FloatArray>;
  21769. /**
  21770. * 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).
  21771. */
  21772. matricesIndices: Nullable<FloatArray>;
  21773. /**
  21774. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21775. */
  21776. matricesWeights: Nullable<FloatArray>;
  21777. /**
  21778. * An array extending the number of possible indices
  21779. */
  21780. matricesIndicesExtra: Nullable<FloatArray>;
  21781. /**
  21782. * An array extending the number of possible weights when the number of indices is extended
  21783. */
  21784. matricesWeightsExtra: Nullable<FloatArray>;
  21785. /**
  21786. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21787. */
  21788. indices: Nullable<IndicesArray>;
  21789. /**
  21790. * Uses the passed data array to set the set the values for the specified kind of data
  21791. * @param data a linear array of floating numbers
  21792. * @param kind the type of data that is being set, eg positions, colors etc
  21793. */
  21794. set(data: FloatArray, kind: string): void;
  21795. /**
  21796. * Associates the vertexData to the passed Mesh.
  21797. * Sets it as updatable or not (default `false`)
  21798. * @param mesh the mesh the vertexData is applied to
  21799. * @param updatable when used and having the value true allows new data to update the vertexData
  21800. * @returns the VertexData
  21801. */
  21802. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21803. /**
  21804. * Associates the vertexData to the passed Geometry.
  21805. * Sets it as updatable or not (default `false`)
  21806. * @param geometry the geometry the vertexData is applied to
  21807. * @param updatable when used and having the value true allows new data to update the vertexData
  21808. * @returns VertexData
  21809. */
  21810. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21811. /**
  21812. * Updates the associated mesh
  21813. * @param mesh the mesh to be updated
  21814. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21815. * @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
  21816. * @returns VertexData
  21817. */
  21818. updateMesh(mesh: Mesh): VertexData;
  21819. /**
  21820. * Updates the associated geometry
  21821. * @param geometry the geometry to be updated
  21822. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21823. * @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
  21824. * @returns VertexData.
  21825. */
  21826. updateGeometry(geometry: Geometry): VertexData;
  21827. private _applyTo;
  21828. private _update;
  21829. /**
  21830. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21831. * @param matrix the transforming matrix
  21832. * @returns the VertexData
  21833. */
  21834. transform(matrix: Matrix): VertexData;
  21835. /**
  21836. * Merges the passed VertexData into the current one
  21837. * @param other the VertexData to be merged into the current one
  21838. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21839. * @returns the modified VertexData
  21840. */
  21841. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21842. private _mergeElement;
  21843. private _validate;
  21844. /**
  21845. * Serializes the VertexData
  21846. * @returns a serialized object
  21847. */
  21848. serialize(): any;
  21849. /**
  21850. * Extracts the vertexData from a mesh
  21851. * @param mesh the mesh from which to extract the VertexData
  21852. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21853. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21854. * @returns the object VertexData associated to the passed mesh
  21855. */
  21856. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21857. /**
  21858. * Extracts the vertexData from the geometry
  21859. * @param geometry the geometry from which to extract the VertexData
  21860. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21861. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21862. * @returns the object VertexData associated to the passed mesh
  21863. */
  21864. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21865. private static _ExtractFrom;
  21866. /**
  21867. * Creates the VertexData for a Ribbon
  21868. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21869. * * pathArray array of paths, each of which an array of successive Vector3
  21870. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21871. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21872. * * 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
  21873. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21874. * * 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)
  21875. * * 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)
  21876. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21877. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21878. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21879. * @returns the VertexData of the ribbon
  21880. */
  21881. static CreateRibbon(options: {
  21882. pathArray: Vector3[][];
  21883. closeArray?: boolean;
  21884. closePath?: boolean;
  21885. offset?: number;
  21886. sideOrientation?: number;
  21887. frontUVs?: Vector4;
  21888. backUVs?: Vector4;
  21889. invertUV?: boolean;
  21890. uvs?: Vector2[];
  21891. colors?: Color4[];
  21892. }): VertexData;
  21893. /**
  21894. * Creates the VertexData for a box
  21895. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21896. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21897. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21898. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21899. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21900. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21901. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21902. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21903. * * 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)
  21904. * * 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)
  21905. * @returns the VertexData of the box
  21906. */
  21907. static CreateBox(options: {
  21908. size?: number;
  21909. width?: number;
  21910. height?: number;
  21911. depth?: number;
  21912. faceUV?: Vector4[];
  21913. faceColors?: Color4[];
  21914. sideOrientation?: number;
  21915. frontUVs?: Vector4;
  21916. backUVs?: Vector4;
  21917. }): VertexData;
  21918. /**
  21919. * Creates the VertexData for a tiled box
  21920. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21921. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21922. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21923. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21925. * @returns the VertexData of the box
  21926. */
  21927. static CreateTiledBox(options: {
  21928. pattern?: number;
  21929. width?: number;
  21930. height?: number;
  21931. depth?: number;
  21932. tileSize?: number;
  21933. tileWidth?: number;
  21934. tileHeight?: number;
  21935. alignHorizontal?: number;
  21936. alignVertical?: number;
  21937. faceUV?: Vector4[];
  21938. faceColors?: Color4[];
  21939. sideOrientation?: number;
  21940. }): VertexData;
  21941. /**
  21942. * Creates the VertexData for a tiled plane
  21943. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21944. * * pattern a limited pattern arrangement depending on the number
  21945. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21946. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21947. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21949. * * 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)
  21950. * * 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)
  21951. * @returns the VertexData of the tiled plane
  21952. */
  21953. static CreateTiledPlane(options: {
  21954. pattern?: number;
  21955. tileSize?: number;
  21956. tileWidth?: number;
  21957. tileHeight?: number;
  21958. size?: number;
  21959. width?: number;
  21960. height?: number;
  21961. alignHorizontal?: number;
  21962. alignVertical?: number;
  21963. sideOrientation?: number;
  21964. frontUVs?: Vector4;
  21965. backUVs?: Vector4;
  21966. }): VertexData;
  21967. /**
  21968. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21969. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21970. * * segments sets the number of horizontal strips optional, default 32
  21971. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21972. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21973. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21974. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21975. * * 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
  21976. * * 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
  21977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21978. * * 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)
  21979. * * 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)
  21980. * @returns the VertexData of the ellipsoid
  21981. */
  21982. static CreateSphere(options: {
  21983. segments?: number;
  21984. diameter?: number;
  21985. diameterX?: number;
  21986. diameterY?: number;
  21987. diameterZ?: number;
  21988. arc?: number;
  21989. slice?: number;
  21990. sideOrientation?: number;
  21991. frontUVs?: Vector4;
  21992. backUVs?: Vector4;
  21993. }): VertexData;
  21994. /**
  21995. * Creates the VertexData for a cylinder, cone or prism
  21996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21997. * * height sets the height (y direction) of the cylinder, optional, default 2
  21998. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21999. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22000. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22001. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22002. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22003. * * 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
  22004. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22005. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22006. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22007. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22009. * * 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)
  22010. * * 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)
  22011. * @returns the VertexData of the cylinder, cone or prism
  22012. */
  22013. static CreateCylinder(options: {
  22014. height?: number;
  22015. diameterTop?: number;
  22016. diameterBottom?: number;
  22017. diameter?: number;
  22018. tessellation?: number;
  22019. subdivisions?: number;
  22020. arc?: number;
  22021. faceColors?: Color4[];
  22022. faceUV?: Vector4[];
  22023. hasRings?: boolean;
  22024. enclose?: boolean;
  22025. sideOrientation?: number;
  22026. frontUVs?: Vector4;
  22027. backUVs?: Vector4;
  22028. }): VertexData;
  22029. /**
  22030. * Creates the VertexData for a torus
  22031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22032. * * diameter the diameter of the torus, optional default 1
  22033. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22034. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22036. * * 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)
  22037. * * 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)
  22038. * @returns the VertexData of the torus
  22039. */
  22040. static CreateTorus(options: {
  22041. diameter?: number;
  22042. thickness?: number;
  22043. tessellation?: number;
  22044. sideOrientation?: number;
  22045. frontUVs?: Vector4;
  22046. backUVs?: Vector4;
  22047. }): VertexData;
  22048. /**
  22049. * Creates the VertexData of the LineSystem
  22050. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22051. * - lines an array of lines, each line being an array of successive Vector3
  22052. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22053. * @returns the VertexData of the LineSystem
  22054. */
  22055. static CreateLineSystem(options: {
  22056. lines: Vector3[][];
  22057. colors?: Nullable<Color4[][]>;
  22058. }): VertexData;
  22059. /**
  22060. * Create the VertexData for a DashedLines
  22061. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22062. * - points an array successive Vector3
  22063. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22064. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22065. * - dashNb the intended total number of dashes, optional, default 200
  22066. * @returns the VertexData for the DashedLines
  22067. */
  22068. static CreateDashedLines(options: {
  22069. points: Vector3[];
  22070. dashSize?: number;
  22071. gapSize?: number;
  22072. dashNb?: number;
  22073. }): VertexData;
  22074. /**
  22075. * Creates the VertexData for a Ground
  22076. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22077. * - width the width (x direction) of the ground, optional, default 1
  22078. * - height the height (z direction) of the ground, optional, default 1
  22079. * - subdivisions the number of subdivisions per side, optional, default 1
  22080. * @returns the VertexData of the Ground
  22081. */
  22082. static CreateGround(options: {
  22083. width?: number;
  22084. height?: number;
  22085. subdivisions?: number;
  22086. subdivisionsX?: number;
  22087. subdivisionsY?: number;
  22088. }): VertexData;
  22089. /**
  22090. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22091. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22092. * * xmin the ground minimum X coordinate, optional, default -1
  22093. * * zmin the ground minimum Z coordinate, optional, default -1
  22094. * * xmax the ground maximum X coordinate, optional, default 1
  22095. * * zmax the ground maximum Z coordinate, optional, default 1
  22096. * * 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}
  22097. * * 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}
  22098. * @returns the VertexData of the TiledGround
  22099. */
  22100. static CreateTiledGround(options: {
  22101. xmin: number;
  22102. zmin: number;
  22103. xmax: number;
  22104. zmax: number;
  22105. subdivisions?: {
  22106. w: number;
  22107. h: number;
  22108. };
  22109. precision?: {
  22110. w: number;
  22111. h: number;
  22112. };
  22113. }): VertexData;
  22114. /**
  22115. * Creates the VertexData of the Ground designed from a heightmap
  22116. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22117. * * width the width (x direction) of the ground
  22118. * * height the height (z direction) of the ground
  22119. * * subdivisions the number of subdivisions per side
  22120. * * minHeight the minimum altitude on the ground, optional, default 0
  22121. * * maxHeight the maximum altitude on the ground, optional default 1
  22122. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22123. * * buffer the array holding the image color data
  22124. * * bufferWidth the width of image
  22125. * * bufferHeight the height of image
  22126. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22127. * @returns the VertexData of the Ground designed from a heightmap
  22128. */
  22129. static CreateGroundFromHeightMap(options: {
  22130. width: number;
  22131. height: number;
  22132. subdivisions: number;
  22133. minHeight: number;
  22134. maxHeight: number;
  22135. colorFilter: Color3;
  22136. buffer: Uint8Array;
  22137. bufferWidth: number;
  22138. bufferHeight: number;
  22139. alphaFilter: number;
  22140. }): VertexData;
  22141. /**
  22142. * Creates the VertexData for a Plane
  22143. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22144. * * size sets the width and height of the plane to the value of size, optional default 1
  22145. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22146. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22148. * * 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)
  22149. * * 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)
  22150. * @returns the VertexData of the box
  22151. */
  22152. static CreatePlane(options: {
  22153. size?: number;
  22154. width?: number;
  22155. height?: number;
  22156. sideOrientation?: number;
  22157. frontUVs?: Vector4;
  22158. backUVs?: Vector4;
  22159. }): VertexData;
  22160. /**
  22161. * Creates the VertexData of the Disc or regular Polygon
  22162. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22163. * * radius the radius of the disc, optional default 0.5
  22164. * * tessellation the number of polygon sides, optional, default 64
  22165. * * 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
  22166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22167. * * 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)
  22168. * * 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)
  22169. * @returns the VertexData of the box
  22170. */
  22171. static CreateDisc(options: {
  22172. radius?: number;
  22173. tessellation?: number;
  22174. arc?: number;
  22175. sideOrientation?: number;
  22176. frontUVs?: Vector4;
  22177. backUVs?: Vector4;
  22178. }): VertexData;
  22179. /**
  22180. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22181. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22182. * @param polygon a mesh built from polygonTriangulation.build()
  22183. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22184. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22185. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22186. * @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)
  22187. * @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)
  22188. * @returns the VertexData of the Polygon
  22189. */
  22190. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22191. /**
  22192. * Creates the VertexData of the IcoSphere
  22193. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22194. * * radius the radius of the IcoSphere, optional default 1
  22195. * * radiusX allows stretching in the x direction, optional, default radius
  22196. * * radiusY allows stretching in the y direction, optional, default radius
  22197. * * radiusZ allows stretching in the z direction, optional, default radius
  22198. * * flat when true creates a flat shaded mesh, optional, default true
  22199. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22201. * * 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)
  22202. * * 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)
  22203. * @returns the VertexData of the IcoSphere
  22204. */
  22205. static CreateIcoSphere(options: {
  22206. radius?: number;
  22207. radiusX?: number;
  22208. radiusY?: number;
  22209. radiusZ?: number;
  22210. flat?: boolean;
  22211. subdivisions?: number;
  22212. sideOrientation?: number;
  22213. frontUVs?: Vector4;
  22214. backUVs?: Vector4;
  22215. }): VertexData;
  22216. /**
  22217. * Creates the VertexData for a Polyhedron
  22218. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22219. * * type provided types are:
  22220. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22221. * * 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)
  22222. * * size the size of the IcoSphere, optional default 1
  22223. * * sizeX allows stretching in the x direction, optional, default size
  22224. * * sizeY allows stretching in the y direction, optional, default size
  22225. * * sizeZ allows stretching in the z direction, optional, default size
  22226. * * 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
  22227. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22228. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22229. * * flat when true creates a flat shaded mesh, optional, default true
  22230. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22232. * * 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)
  22233. * * 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)
  22234. * @returns the VertexData of the Polyhedron
  22235. */
  22236. static CreatePolyhedron(options: {
  22237. type?: number;
  22238. size?: number;
  22239. sizeX?: number;
  22240. sizeY?: number;
  22241. sizeZ?: number;
  22242. custom?: any;
  22243. faceUV?: Vector4[];
  22244. faceColors?: Color4[];
  22245. flat?: boolean;
  22246. sideOrientation?: number;
  22247. frontUVs?: Vector4;
  22248. backUVs?: Vector4;
  22249. }): VertexData;
  22250. /**
  22251. * Creates the VertexData for a TorusKnot
  22252. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22253. * * radius the radius of the torus knot, optional, default 2
  22254. * * tube the thickness of the tube, optional, default 0.5
  22255. * * radialSegments the number of sides on each tube segments, optional, default 32
  22256. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22257. * * p the number of windings around the z axis, optional, default 2
  22258. * * q the number of windings around the x axis, optional, default 3
  22259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22260. * * 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)
  22261. * * 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)
  22262. * @returns the VertexData of the Torus Knot
  22263. */
  22264. static CreateTorusKnot(options: {
  22265. radius?: number;
  22266. tube?: number;
  22267. radialSegments?: number;
  22268. tubularSegments?: number;
  22269. p?: number;
  22270. q?: number;
  22271. sideOrientation?: number;
  22272. frontUVs?: Vector4;
  22273. backUVs?: Vector4;
  22274. }): VertexData;
  22275. /**
  22276. * Compute normals for given positions and indices
  22277. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22278. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22279. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22280. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22281. * * facetNormals : optional array of facet normals (vector3)
  22282. * * facetPositions : optional array of facet positions (vector3)
  22283. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22284. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22285. * * bInfo : optional bounding info, required for facetPartitioning computation
  22286. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22287. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22288. * * useRightHandedSystem: optional boolean to for right handed system computation
  22289. * * depthSort : optional boolean to enable the facet depth sort computation
  22290. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22291. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22292. */
  22293. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22294. facetNormals?: any;
  22295. facetPositions?: any;
  22296. facetPartitioning?: any;
  22297. ratio?: number;
  22298. bInfo?: any;
  22299. bbSize?: Vector3;
  22300. subDiv?: any;
  22301. useRightHandedSystem?: boolean;
  22302. depthSort?: boolean;
  22303. distanceTo?: Vector3;
  22304. depthSortedFacets?: any;
  22305. }): void;
  22306. /** @hidden */
  22307. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22308. /**
  22309. * Applies VertexData created from the imported parameters to the geometry
  22310. * @param parsedVertexData the parsed data from an imported file
  22311. * @param geometry the geometry to apply the VertexData to
  22312. */
  22313. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22314. }
  22315. }
  22316. declare module "babylonjs/Morph/morphTarget" {
  22317. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22318. import { Observable } from "babylonjs/Misc/observable";
  22319. import { Nullable, FloatArray } from "babylonjs/types";
  22320. import { Scene } from "babylonjs/scene";
  22321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22322. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22323. /**
  22324. * Defines a target to use with MorphTargetManager
  22325. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22326. */
  22327. export class MorphTarget implements IAnimatable {
  22328. /** defines the name of the target */
  22329. name: string;
  22330. /**
  22331. * Gets or sets the list of animations
  22332. */
  22333. animations: import("babylonjs/Animations/animation").Animation[];
  22334. private _scene;
  22335. private _positions;
  22336. private _normals;
  22337. private _tangents;
  22338. private _uvs;
  22339. private _influence;
  22340. /**
  22341. * Observable raised when the influence changes
  22342. */
  22343. onInfluenceChanged: Observable<boolean>;
  22344. /** @hidden */
  22345. _onDataLayoutChanged: Observable<void>;
  22346. /**
  22347. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22348. */
  22349. influence: number;
  22350. /**
  22351. * Gets or sets the id of the morph Target
  22352. */
  22353. id: string;
  22354. private _animationPropertiesOverride;
  22355. /**
  22356. * Gets or sets the animation properties override
  22357. */
  22358. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22359. /**
  22360. * Creates a new MorphTarget
  22361. * @param name defines the name of the target
  22362. * @param influence defines the influence to use
  22363. * @param scene defines the scene the morphtarget belongs to
  22364. */
  22365. constructor(
  22366. /** defines the name of the target */
  22367. name: string, influence?: number, scene?: Nullable<Scene>);
  22368. /**
  22369. * Gets a boolean defining if the target contains position data
  22370. */
  22371. readonly hasPositions: boolean;
  22372. /**
  22373. * Gets a boolean defining if the target contains normal data
  22374. */
  22375. readonly hasNormals: boolean;
  22376. /**
  22377. * Gets a boolean defining if the target contains tangent data
  22378. */
  22379. readonly hasTangents: boolean;
  22380. /**
  22381. * Gets a boolean defining if the target contains texture coordinates data
  22382. */
  22383. readonly hasUVs: boolean;
  22384. /**
  22385. * Affects position data to this target
  22386. * @param data defines the position data to use
  22387. */
  22388. setPositions(data: Nullable<FloatArray>): void;
  22389. /**
  22390. * Gets the position data stored in this target
  22391. * @returns a FloatArray containing the position data (or null if not present)
  22392. */
  22393. getPositions(): Nullable<FloatArray>;
  22394. /**
  22395. * Affects normal data to this target
  22396. * @param data defines the normal data to use
  22397. */
  22398. setNormals(data: Nullable<FloatArray>): void;
  22399. /**
  22400. * Gets the normal data stored in this target
  22401. * @returns a FloatArray containing the normal data (or null if not present)
  22402. */
  22403. getNormals(): Nullable<FloatArray>;
  22404. /**
  22405. * Affects tangent data to this target
  22406. * @param data defines the tangent data to use
  22407. */
  22408. setTangents(data: Nullable<FloatArray>): void;
  22409. /**
  22410. * Gets the tangent data stored in this target
  22411. * @returns a FloatArray containing the tangent data (or null if not present)
  22412. */
  22413. getTangents(): Nullable<FloatArray>;
  22414. /**
  22415. * Affects texture coordinates data to this target
  22416. * @param data defines the texture coordinates data to use
  22417. */
  22418. setUVs(data: Nullable<FloatArray>): void;
  22419. /**
  22420. * Gets the texture coordinates data stored in this target
  22421. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22422. */
  22423. getUVs(): Nullable<FloatArray>;
  22424. /**
  22425. * Serializes the current target into a Serialization object
  22426. * @returns the serialized object
  22427. */
  22428. serialize(): any;
  22429. /**
  22430. * Returns the string "MorphTarget"
  22431. * @returns "MorphTarget"
  22432. */
  22433. getClassName(): string;
  22434. /**
  22435. * Creates a new target from serialized data
  22436. * @param serializationObject defines the serialized data to use
  22437. * @returns a new MorphTarget
  22438. */
  22439. static Parse(serializationObject: any): MorphTarget;
  22440. /**
  22441. * Creates a MorphTarget from mesh data
  22442. * @param mesh defines the source mesh
  22443. * @param name defines the name to use for the new target
  22444. * @param influence defines the influence to attach to the target
  22445. * @returns a new MorphTarget
  22446. */
  22447. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22448. }
  22449. }
  22450. declare module "babylonjs/Morph/morphTargetManager" {
  22451. import { Nullable } from "babylonjs/types";
  22452. import { Scene } from "babylonjs/scene";
  22453. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22454. /**
  22455. * This class is used to deform meshes using morphing between different targets
  22456. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22457. */
  22458. export class MorphTargetManager {
  22459. private _targets;
  22460. private _targetInfluenceChangedObservers;
  22461. private _targetDataLayoutChangedObservers;
  22462. private _activeTargets;
  22463. private _scene;
  22464. private _influences;
  22465. private _supportsNormals;
  22466. private _supportsTangents;
  22467. private _supportsUVs;
  22468. private _vertexCount;
  22469. private _uniqueId;
  22470. private _tempInfluences;
  22471. /**
  22472. * Gets or sets a boolean indicating if normals must be morphed
  22473. */
  22474. enableNormalMorphing: boolean;
  22475. /**
  22476. * Gets or sets a boolean indicating if tangents must be morphed
  22477. */
  22478. enableTangentMorphing: boolean;
  22479. /**
  22480. * Gets or sets a boolean indicating if UV must be morphed
  22481. */
  22482. enableUVMorphing: boolean;
  22483. /**
  22484. * Creates a new MorphTargetManager
  22485. * @param scene defines the current scene
  22486. */
  22487. constructor(scene?: Nullable<Scene>);
  22488. /**
  22489. * Gets the unique ID of this manager
  22490. */
  22491. readonly uniqueId: number;
  22492. /**
  22493. * Gets the number of vertices handled by this manager
  22494. */
  22495. readonly vertexCount: number;
  22496. /**
  22497. * Gets a boolean indicating if this manager supports morphing of normals
  22498. */
  22499. readonly supportsNormals: boolean;
  22500. /**
  22501. * Gets a boolean indicating if this manager supports morphing of tangents
  22502. */
  22503. readonly supportsTangents: boolean;
  22504. /**
  22505. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22506. */
  22507. readonly supportsUVs: boolean;
  22508. /**
  22509. * Gets the number of targets stored in this manager
  22510. */
  22511. readonly numTargets: number;
  22512. /**
  22513. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22514. */
  22515. readonly numInfluencers: number;
  22516. /**
  22517. * Gets the list of influences (one per target)
  22518. */
  22519. readonly influences: Float32Array;
  22520. /**
  22521. * Gets the active target at specified index. An active target is a target with an influence > 0
  22522. * @param index defines the index to check
  22523. * @returns the requested target
  22524. */
  22525. getActiveTarget(index: number): MorphTarget;
  22526. /**
  22527. * Gets the target at specified index
  22528. * @param index defines the index to check
  22529. * @returns the requested target
  22530. */
  22531. getTarget(index: number): MorphTarget;
  22532. /**
  22533. * Add a new target to this manager
  22534. * @param target defines the target to add
  22535. */
  22536. addTarget(target: MorphTarget): void;
  22537. /**
  22538. * Removes a target from the manager
  22539. * @param target defines the target to remove
  22540. */
  22541. removeTarget(target: MorphTarget): void;
  22542. /**
  22543. * Serializes the current manager into a Serialization object
  22544. * @returns the serialized object
  22545. */
  22546. serialize(): any;
  22547. private _syncActiveTargets;
  22548. /**
  22549. * Syncrhonize the targets with all the meshes using this morph target manager
  22550. */
  22551. synchronize(): void;
  22552. /**
  22553. * Creates a new MorphTargetManager from serialized data
  22554. * @param serializationObject defines the serialized data
  22555. * @param scene defines the hosting scene
  22556. * @returns the new MorphTargetManager
  22557. */
  22558. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22559. }
  22560. }
  22561. declare module "babylonjs/Meshes/meshLODLevel" {
  22562. import { Mesh } from "babylonjs/Meshes/mesh";
  22563. import { Nullable } from "babylonjs/types";
  22564. /**
  22565. * Class used to represent a specific level of detail of a mesh
  22566. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22567. */
  22568. export class MeshLODLevel {
  22569. /** Defines the distance where this level should star being displayed */
  22570. distance: number;
  22571. /** Defines the mesh to use to render this level */
  22572. mesh: Nullable<Mesh>;
  22573. /**
  22574. * Creates a new LOD level
  22575. * @param distance defines the distance where this level should star being displayed
  22576. * @param mesh defines the mesh to use to render this level
  22577. */
  22578. constructor(
  22579. /** Defines the distance where this level should star being displayed */
  22580. distance: number,
  22581. /** Defines the mesh to use to render this level */
  22582. mesh: Nullable<Mesh>);
  22583. }
  22584. }
  22585. declare module "babylonjs/Meshes/groundMesh" {
  22586. import { Scene } from "babylonjs/scene";
  22587. import { Vector3 } from "babylonjs/Maths/math.vector";
  22588. import { Mesh } from "babylonjs/Meshes/mesh";
  22589. /**
  22590. * Mesh representing the gorund
  22591. */
  22592. export class GroundMesh extends Mesh {
  22593. /** If octree should be generated */
  22594. generateOctree: boolean;
  22595. private _heightQuads;
  22596. /** @hidden */
  22597. _subdivisionsX: number;
  22598. /** @hidden */
  22599. _subdivisionsY: number;
  22600. /** @hidden */
  22601. _width: number;
  22602. /** @hidden */
  22603. _height: number;
  22604. /** @hidden */
  22605. _minX: number;
  22606. /** @hidden */
  22607. _maxX: number;
  22608. /** @hidden */
  22609. _minZ: number;
  22610. /** @hidden */
  22611. _maxZ: number;
  22612. constructor(name: string, scene: Scene);
  22613. /**
  22614. * "GroundMesh"
  22615. * @returns "GroundMesh"
  22616. */
  22617. getClassName(): string;
  22618. /**
  22619. * The minimum of x and y subdivisions
  22620. */
  22621. readonly subdivisions: number;
  22622. /**
  22623. * X subdivisions
  22624. */
  22625. readonly subdivisionsX: number;
  22626. /**
  22627. * Y subdivisions
  22628. */
  22629. readonly subdivisionsY: number;
  22630. /**
  22631. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22632. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22633. * @param chunksCount the number of subdivisions for x and y
  22634. * @param octreeBlocksSize (Default: 32)
  22635. */
  22636. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22637. /**
  22638. * Returns a height (y) value in the Worl system :
  22639. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22640. * @param x x coordinate
  22641. * @param z z coordinate
  22642. * @returns the ground y position if (x, z) are outside the ground surface.
  22643. */
  22644. getHeightAtCoordinates(x: number, z: number): number;
  22645. /**
  22646. * Returns a normalized vector (Vector3) orthogonal to the ground
  22647. * at the ground coordinates (x, z) expressed in the World system.
  22648. * @param x x coordinate
  22649. * @param z z coordinate
  22650. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22651. */
  22652. getNormalAtCoordinates(x: number, z: number): Vector3;
  22653. /**
  22654. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22655. * at the ground coordinates (x, z) expressed in the World system.
  22656. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22657. * @param x x coordinate
  22658. * @param z z coordinate
  22659. * @param ref vector to store the result
  22660. * @returns the GroundMesh.
  22661. */
  22662. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22663. /**
  22664. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22665. * if the ground has been updated.
  22666. * This can be used in the render loop.
  22667. * @returns the GroundMesh.
  22668. */
  22669. updateCoordinateHeights(): GroundMesh;
  22670. private _getFacetAt;
  22671. private _initHeightQuads;
  22672. private _computeHeightQuads;
  22673. /**
  22674. * Serializes this ground mesh
  22675. * @param serializationObject object to write serialization to
  22676. */
  22677. serialize(serializationObject: any): void;
  22678. /**
  22679. * Parses a serialized ground mesh
  22680. * @param parsedMesh the serialized mesh
  22681. * @param scene the scene to create the ground mesh in
  22682. * @returns the created ground mesh
  22683. */
  22684. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22685. }
  22686. }
  22687. declare module "babylonjs/Physics/physicsJoint" {
  22688. import { Vector3 } from "babylonjs/Maths/math.vector";
  22689. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22690. /**
  22691. * Interface for Physics-Joint data
  22692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22693. */
  22694. export interface PhysicsJointData {
  22695. /**
  22696. * The main pivot of the joint
  22697. */
  22698. mainPivot?: Vector3;
  22699. /**
  22700. * The connected pivot of the joint
  22701. */
  22702. connectedPivot?: Vector3;
  22703. /**
  22704. * The main axis of the joint
  22705. */
  22706. mainAxis?: Vector3;
  22707. /**
  22708. * The connected axis of the joint
  22709. */
  22710. connectedAxis?: Vector3;
  22711. /**
  22712. * The collision of the joint
  22713. */
  22714. collision?: boolean;
  22715. /**
  22716. * Native Oimo/Cannon/Energy data
  22717. */
  22718. nativeParams?: any;
  22719. }
  22720. /**
  22721. * This is a holder class for the physics joint created by the physics plugin
  22722. * It holds a set of functions to control the underlying joint
  22723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22724. */
  22725. export class PhysicsJoint {
  22726. /**
  22727. * The type of the physics joint
  22728. */
  22729. type: number;
  22730. /**
  22731. * The data for the physics joint
  22732. */
  22733. jointData: PhysicsJointData;
  22734. private _physicsJoint;
  22735. protected _physicsPlugin: IPhysicsEnginePlugin;
  22736. /**
  22737. * Initializes the physics joint
  22738. * @param type The type of the physics joint
  22739. * @param jointData The data for the physics joint
  22740. */
  22741. constructor(
  22742. /**
  22743. * The type of the physics joint
  22744. */
  22745. type: number,
  22746. /**
  22747. * The data for the physics joint
  22748. */
  22749. jointData: PhysicsJointData);
  22750. /**
  22751. * Gets the physics joint
  22752. */
  22753. /**
  22754. * Sets the physics joint
  22755. */
  22756. physicsJoint: any;
  22757. /**
  22758. * Sets the physics plugin
  22759. */
  22760. physicsPlugin: IPhysicsEnginePlugin;
  22761. /**
  22762. * Execute a function that is physics-plugin specific.
  22763. * @param {Function} func the function that will be executed.
  22764. * It accepts two parameters: the physics world and the physics joint
  22765. */
  22766. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22767. /**
  22768. * Distance-Joint type
  22769. */
  22770. static DistanceJoint: number;
  22771. /**
  22772. * Hinge-Joint type
  22773. */
  22774. static HingeJoint: number;
  22775. /**
  22776. * Ball-and-Socket joint type
  22777. */
  22778. static BallAndSocketJoint: number;
  22779. /**
  22780. * Wheel-Joint type
  22781. */
  22782. static WheelJoint: number;
  22783. /**
  22784. * Slider-Joint type
  22785. */
  22786. static SliderJoint: number;
  22787. /**
  22788. * Prismatic-Joint type
  22789. */
  22790. static PrismaticJoint: number;
  22791. /**
  22792. * Universal-Joint type
  22793. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22794. */
  22795. static UniversalJoint: number;
  22796. /**
  22797. * Hinge-Joint 2 type
  22798. */
  22799. static Hinge2Joint: number;
  22800. /**
  22801. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22802. */
  22803. static PointToPointJoint: number;
  22804. /**
  22805. * Spring-Joint type
  22806. */
  22807. static SpringJoint: number;
  22808. /**
  22809. * Lock-Joint type
  22810. */
  22811. static LockJoint: number;
  22812. }
  22813. /**
  22814. * A class representing a physics distance joint
  22815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22816. */
  22817. export class DistanceJoint extends PhysicsJoint {
  22818. /**
  22819. *
  22820. * @param jointData The data for the Distance-Joint
  22821. */
  22822. constructor(jointData: DistanceJointData);
  22823. /**
  22824. * Update the predefined distance.
  22825. * @param maxDistance The maximum preferred distance
  22826. * @param minDistance The minimum preferred distance
  22827. */
  22828. updateDistance(maxDistance: number, minDistance?: number): void;
  22829. }
  22830. /**
  22831. * Represents a Motor-Enabled Joint
  22832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22833. */
  22834. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22835. /**
  22836. * Initializes the Motor-Enabled Joint
  22837. * @param type The type of the joint
  22838. * @param jointData The physica joint data for the joint
  22839. */
  22840. constructor(type: number, jointData: PhysicsJointData);
  22841. /**
  22842. * Set the motor values.
  22843. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22844. * @param force the force to apply
  22845. * @param maxForce max force for this motor.
  22846. */
  22847. setMotor(force?: number, maxForce?: number): void;
  22848. /**
  22849. * Set the motor's limits.
  22850. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22851. * @param upperLimit The upper limit of the motor
  22852. * @param lowerLimit The lower limit of the motor
  22853. */
  22854. setLimit(upperLimit: number, lowerLimit?: number): void;
  22855. }
  22856. /**
  22857. * This class represents a single physics Hinge-Joint
  22858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22859. */
  22860. export class HingeJoint extends MotorEnabledJoint {
  22861. /**
  22862. * Initializes the Hinge-Joint
  22863. * @param jointData The joint data for the Hinge-Joint
  22864. */
  22865. constructor(jointData: PhysicsJointData);
  22866. /**
  22867. * Set the motor values.
  22868. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22869. * @param {number} force the force to apply
  22870. * @param {number} maxForce max force for this motor.
  22871. */
  22872. setMotor(force?: number, maxForce?: number): void;
  22873. /**
  22874. * Set the motor's limits.
  22875. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22876. * @param upperLimit The upper limit of the motor
  22877. * @param lowerLimit The lower limit of the motor
  22878. */
  22879. setLimit(upperLimit: number, lowerLimit?: number): void;
  22880. }
  22881. /**
  22882. * This class represents a dual hinge physics joint (same as wheel joint)
  22883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22884. */
  22885. export class Hinge2Joint extends MotorEnabledJoint {
  22886. /**
  22887. * Initializes the Hinge2-Joint
  22888. * @param jointData The joint data for the Hinge2-Joint
  22889. */
  22890. constructor(jointData: PhysicsJointData);
  22891. /**
  22892. * Set the motor values.
  22893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22894. * @param {number} targetSpeed the speed the motor is to reach
  22895. * @param {number} maxForce max force for this motor.
  22896. * @param {motorIndex} the motor's index, 0 or 1.
  22897. */
  22898. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22899. /**
  22900. * Set the motor limits.
  22901. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22902. * @param {number} upperLimit the upper limit
  22903. * @param {number} lowerLimit lower limit
  22904. * @param {motorIndex} the motor's index, 0 or 1.
  22905. */
  22906. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22907. }
  22908. /**
  22909. * Interface for a motor enabled joint
  22910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22911. */
  22912. export interface IMotorEnabledJoint {
  22913. /**
  22914. * Physics joint
  22915. */
  22916. physicsJoint: any;
  22917. /**
  22918. * Sets the motor of the motor-enabled joint
  22919. * @param force The force of the motor
  22920. * @param maxForce The maximum force of the motor
  22921. * @param motorIndex The index of the motor
  22922. */
  22923. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22924. /**
  22925. * Sets the limit of the motor
  22926. * @param upperLimit The upper limit of the motor
  22927. * @param lowerLimit The lower limit of the motor
  22928. * @param motorIndex The index of the motor
  22929. */
  22930. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22931. }
  22932. /**
  22933. * Joint data for a Distance-Joint
  22934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22935. */
  22936. export interface DistanceJointData extends PhysicsJointData {
  22937. /**
  22938. * Max distance the 2 joint objects can be apart
  22939. */
  22940. maxDistance: number;
  22941. }
  22942. /**
  22943. * Joint data from a spring joint
  22944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22945. */
  22946. export interface SpringJointData extends PhysicsJointData {
  22947. /**
  22948. * Length of the spring
  22949. */
  22950. length: number;
  22951. /**
  22952. * Stiffness of the spring
  22953. */
  22954. stiffness: number;
  22955. /**
  22956. * Damping of the spring
  22957. */
  22958. damping: number;
  22959. /** this callback will be called when applying the force to the impostors. */
  22960. forceApplicationCallback: () => void;
  22961. }
  22962. }
  22963. declare module "babylonjs/Physics/physicsRaycastResult" {
  22964. import { Vector3 } from "babylonjs/Maths/math.vector";
  22965. /**
  22966. * Holds the data for the raycast result
  22967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22968. */
  22969. export class PhysicsRaycastResult {
  22970. private _hasHit;
  22971. private _hitDistance;
  22972. private _hitNormalWorld;
  22973. private _hitPointWorld;
  22974. private _rayFromWorld;
  22975. private _rayToWorld;
  22976. /**
  22977. * Gets if there was a hit
  22978. */
  22979. readonly hasHit: boolean;
  22980. /**
  22981. * Gets the distance from the hit
  22982. */
  22983. readonly hitDistance: number;
  22984. /**
  22985. * Gets the hit normal/direction in the world
  22986. */
  22987. readonly hitNormalWorld: Vector3;
  22988. /**
  22989. * Gets the hit point in the world
  22990. */
  22991. readonly hitPointWorld: Vector3;
  22992. /**
  22993. * Gets the ray "start point" of the ray in the world
  22994. */
  22995. readonly rayFromWorld: Vector3;
  22996. /**
  22997. * Gets the ray "end point" of the ray in the world
  22998. */
  22999. readonly rayToWorld: Vector3;
  23000. /**
  23001. * Sets the hit data (normal & point in world space)
  23002. * @param hitNormalWorld defines the normal in world space
  23003. * @param hitPointWorld defines the point in world space
  23004. */
  23005. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23006. /**
  23007. * Sets the distance from the start point to the hit point
  23008. * @param distance
  23009. */
  23010. setHitDistance(distance: number): void;
  23011. /**
  23012. * Calculates the distance manually
  23013. */
  23014. calculateHitDistance(): void;
  23015. /**
  23016. * Resets all the values to default
  23017. * @param from The from point on world space
  23018. * @param to The to point on world space
  23019. */
  23020. reset(from?: Vector3, to?: Vector3): void;
  23021. }
  23022. /**
  23023. * Interface for the size containing width and height
  23024. */
  23025. interface IXYZ {
  23026. /**
  23027. * X
  23028. */
  23029. x: number;
  23030. /**
  23031. * Y
  23032. */
  23033. y: number;
  23034. /**
  23035. * Z
  23036. */
  23037. z: number;
  23038. }
  23039. }
  23040. declare module "babylonjs/Physics/IPhysicsEngine" {
  23041. import { Nullable } from "babylonjs/types";
  23042. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23044. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23045. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23046. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23047. /**
  23048. * Interface used to describe a physics joint
  23049. */
  23050. export interface PhysicsImpostorJoint {
  23051. /** Defines the main impostor to which the joint is linked */
  23052. mainImpostor: PhysicsImpostor;
  23053. /** Defines the impostor that is connected to the main impostor using this joint */
  23054. connectedImpostor: PhysicsImpostor;
  23055. /** Defines the joint itself */
  23056. joint: PhysicsJoint;
  23057. }
  23058. /** @hidden */
  23059. export interface IPhysicsEnginePlugin {
  23060. world: any;
  23061. name: string;
  23062. setGravity(gravity: Vector3): void;
  23063. setTimeStep(timeStep: number): void;
  23064. getTimeStep(): number;
  23065. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23066. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23067. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23068. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23069. removePhysicsBody(impostor: PhysicsImpostor): void;
  23070. generateJoint(joint: PhysicsImpostorJoint): void;
  23071. removeJoint(joint: PhysicsImpostorJoint): void;
  23072. isSupported(): boolean;
  23073. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23074. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23075. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23076. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23077. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23078. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23079. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23080. getBodyMass(impostor: PhysicsImpostor): number;
  23081. getBodyFriction(impostor: PhysicsImpostor): number;
  23082. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23083. getBodyRestitution(impostor: PhysicsImpostor): number;
  23084. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23085. getBodyPressure?(impostor: PhysicsImpostor): number;
  23086. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23087. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23088. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23089. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23090. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23091. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23092. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23093. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23094. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23095. sleepBody(impostor: PhysicsImpostor): void;
  23096. wakeUpBody(impostor: PhysicsImpostor): void;
  23097. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23098. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23099. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23100. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23101. getRadius(impostor: PhysicsImpostor): number;
  23102. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23103. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23104. dispose(): void;
  23105. }
  23106. /**
  23107. * Interface used to define a physics engine
  23108. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23109. */
  23110. export interface IPhysicsEngine {
  23111. /**
  23112. * Gets the gravity vector used by the simulation
  23113. */
  23114. gravity: Vector3;
  23115. /**
  23116. * Sets the gravity vector used by the simulation
  23117. * @param gravity defines the gravity vector to use
  23118. */
  23119. setGravity(gravity: Vector3): void;
  23120. /**
  23121. * Set the time step of the physics engine.
  23122. * Default is 1/60.
  23123. * To slow it down, enter 1/600 for example.
  23124. * To speed it up, 1/30
  23125. * @param newTimeStep the new timestep to apply to this world.
  23126. */
  23127. setTimeStep(newTimeStep: number): void;
  23128. /**
  23129. * Get the time step of the physics engine.
  23130. * @returns the current time step
  23131. */
  23132. getTimeStep(): number;
  23133. /**
  23134. * Release all resources
  23135. */
  23136. dispose(): void;
  23137. /**
  23138. * Gets the name of the current physics plugin
  23139. * @returns the name of the plugin
  23140. */
  23141. getPhysicsPluginName(): string;
  23142. /**
  23143. * Adding a new impostor for the impostor tracking.
  23144. * This will be done by the impostor itself.
  23145. * @param impostor the impostor to add
  23146. */
  23147. addImpostor(impostor: PhysicsImpostor): void;
  23148. /**
  23149. * Remove an impostor from the engine.
  23150. * This impostor and its mesh will not longer be updated by the physics engine.
  23151. * @param impostor the impostor to remove
  23152. */
  23153. removeImpostor(impostor: PhysicsImpostor): void;
  23154. /**
  23155. * Add a joint to the physics engine
  23156. * @param mainImpostor defines the main impostor to which the joint is added.
  23157. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23158. * @param joint defines the joint that will connect both impostors.
  23159. */
  23160. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23161. /**
  23162. * Removes a joint from the simulation
  23163. * @param mainImpostor defines the impostor used with the joint
  23164. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23165. * @param joint defines the joint to remove
  23166. */
  23167. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23168. /**
  23169. * Gets the current plugin used to run the simulation
  23170. * @returns current plugin
  23171. */
  23172. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23173. /**
  23174. * Gets the list of physic impostors
  23175. * @returns an array of PhysicsImpostor
  23176. */
  23177. getImpostors(): Array<PhysicsImpostor>;
  23178. /**
  23179. * Gets the impostor for a physics enabled object
  23180. * @param object defines the object impersonated by the impostor
  23181. * @returns the PhysicsImpostor or null if not found
  23182. */
  23183. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23184. /**
  23185. * Gets the impostor for a physics body object
  23186. * @param body defines physics body used by the impostor
  23187. * @returns the PhysicsImpostor or null if not found
  23188. */
  23189. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23190. /**
  23191. * Does a raycast in the physics world
  23192. * @param from when should the ray start?
  23193. * @param to when should the ray end?
  23194. * @returns PhysicsRaycastResult
  23195. */
  23196. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23197. /**
  23198. * Called by the scene. No need to call it.
  23199. * @param delta defines the timespam between frames
  23200. */
  23201. _step(delta: number): void;
  23202. }
  23203. }
  23204. declare module "babylonjs/Physics/physicsImpostor" {
  23205. import { Nullable, IndicesArray } from "babylonjs/types";
  23206. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23207. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23209. import { Scene } from "babylonjs/scene";
  23210. import { Bone } from "babylonjs/Bones/bone";
  23211. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23212. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23213. import { Space } from "babylonjs/Maths/math.axis";
  23214. /**
  23215. * The interface for the physics imposter parameters
  23216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23217. */
  23218. export interface PhysicsImpostorParameters {
  23219. /**
  23220. * The mass of the physics imposter
  23221. */
  23222. mass: number;
  23223. /**
  23224. * The friction of the physics imposter
  23225. */
  23226. friction?: number;
  23227. /**
  23228. * The coefficient of restitution of the physics imposter
  23229. */
  23230. restitution?: number;
  23231. /**
  23232. * The native options of the physics imposter
  23233. */
  23234. nativeOptions?: any;
  23235. /**
  23236. * Specifies if the parent should be ignored
  23237. */
  23238. ignoreParent?: boolean;
  23239. /**
  23240. * Specifies if bi-directional transformations should be disabled
  23241. */
  23242. disableBidirectionalTransformation?: boolean;
  23243. /**
  23244. * The pressure inside the physics imposter, soft object only
  23245. */
  23246. pressure?: number;
  23247. /**
  23248. * The stiffness the physics imposter, soft object only
  23249. */
  23250. stiffness?: number;
  23251. /**
  23252. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23253. */
  23254. velocityIterations?: number;
  23255. /**
  23256. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23257. */
  23258. positionIterations?: number;
  23259. /**
  23260. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23261. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23262. * Add to fix multiple points
  23263. */
  23264. fixedPoints?: number;
  23265. /**
  23266. * The collision margin around a soft object
  23267. */
  23268. margin?: number;
  23269. /**
  23270. * The collision margin around a soft object
  23271. */
  23272. damping?: number;
  23273. /**
  23274. * The path for a rope based on an extrusion
  23275. */
  23276. path?: any;
  23277. /**
  23278. * The shape of an extrusion used for a rope based on an extrusion
  23279. */
  23280. shape?: any;
  23281. }
  23282. /**
  23283. * Interface for a physics-enabled object
  23284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23285. */
  23286. export interface IPhysicsEnabledObject {
  23287. /**
  23288. * The position of the physics-enabled object
  23289. */
  23290. position: Vector3;
  23291. /**
  23292. * The rotation of the physics-enabled object
  23293. */
  23294. rotationQuaternion: Nullable<Quaternion>;
  23295. /**
  23296. * The scale of the physics-enabled object
  23297. */
  23298. scaling: Vector3;
  23299. /**
  23300. * The rotation of the physics-enabled object
  23301. */
  23302. rotation?: Vector3;
  23303. /**
  23304. * The parent of the physics-enabled object
  23305. */
  23306. parent?: any;
  23307. /**
  23308. * The bounding info of the physics-enabled object
  23309. * @returns The bounding info of the physics-enabled object
  23310. */
  23311. getBoundingInfo(): BoundingInfo;
  23312. /**
  23313. * Computes the world matrix
  23314. * @param force Specifies if the world matrix should be computed by force
  23315. * @returns A world matrix
  23316. */
  23317. computeWorldMatrix(force: boolean): Matrix;
  23318. /**
  23319. * Gets the world matrix
  23320. * @returns A world matrix
  23321. */
  23322. getWorldMatrix?(): Matrix;
  23323. /**
  23324. * Gets the child meshes
  23325. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23326. * @returns An array of abstract meshes
  23327. */
  23328. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23329. /**
  23330. * Gets the vertex data
  23331. * @param kind The type of vertex data
  23332. * @returns A nullable array of numbers, or a float32 array
  23333. */
  23334. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23335. /**
  23336. * Gets the indices from the mesh
  23337. * @returns A nullable array of index arrays
  23338. */
  23339. getIndices?(): Nullable<IndicesArray>;
  23340. /**
  23341. * Gets the scene from the mesh
  23342. * @returns the indices array or null
  23343. */
  23344. getScene?(): Scene;
  23345. /**
  23346. * Gets the absolute position from the mesh
  23347. * @returns the absolute position
  23348. */
  23349. getAbsolutePosition(): Vector3;
  23350. /**
  23351. * Gets the absolute pivot point from the mesh
  23352. * @returns the absolute pivot point
  23353. */
  23354. getAbsolutePivotPoint(): Vector3;
  23355. /**
  23356. * Rotates the mesh
  23357. * @param axis The axis of rotation
  23358. * @param amount The amount of rotation
  23359. * @param space The space of the rotation
  23360. * @returns The rotation transform node
  23361. */
  23362. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23363. /**
  23364. * Translates the mesh
  23365. * @param axis The axis of translation
  23366. * @param distance The distance of translation
  23367. * @param space The space of the translation
  23368. * @returns The transform node
  23369. */
  23370. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23371. /**
  23372. * Sets the absolute position of the mesh
  23373. * @param absolutePosition The absolute position of the mesh
  23374. * @returns The transform node
  23375. */
  23376. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23377. /**
  23378. * Gets the class name of the mesh
  23379. * @returns The class name
  23380. */
  23381. getClassName(): string;
  23382. }
  23383. /**
  23384. * Represents a physics imposter
  23385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23386. */
  23387. export class PhysicsImpostor {
  23388. /**
  23389. * The physics-enabled object used as the physics imposter
  23390. */
  23391. object: IPhysicsEnabledObject;
  23392. /**
  23393. * The type of the physics imposter
  23394. */
  23395. type: number;
  23396. private _options;
  23397. private _scene?;
  23398. /**
  23399. * The default object size of the imposter
  23400. */
  23401. static DEFAULT_OBJECT_SIZE: Vector3;
  23402. /**
  23403. * The identity quaternion of the imposter
  23404. */
  23405. static IDENTITY_QUATERNION: Quaternion;
  23406. /** @hidden */
  23407. _pluginData: any;
  23408. private _physicsEngine;
  23409. private _physicsBody;
  23410. private _bodyUpdateRequired;
  23411. private _onBeforePhysicsStepCallbacks;
  23412. private _onAfterPhysicsStepCallbacks;
  23413. /** @hidden */
  23414. _onPhysicsCollideCallbacks: Array<{
  23415. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23416. otherImpostors: Array<PhysicsImpostor>;
  23417. }>;
  23418. private _deltaPosition;
  23419. private _deltaRotation;
  23420. private _deltaRotationConjugated;
  23421. /** @hidden */
  23422. _isFromLine: boolean;
  23423. private _parent;
  23424. private _isDisposed;
  23425. private static _tmpVecs;
  23426. private static _tmpQuat;
  23427. /**
  23428. * Specifies if the physics imposter is disposed
  23429. */
  23430. readonly isDisposed: boolean;
  23431. /**
  23432. * Gets the mass of the physics imposter
  23433. */
  23434. mass: number;
  23435. /**
  23436. * Gets the coefficient of friction
  23437. */
  23438. /**
  23439. * Sets the coefficient of friction
  23440. */
  23441. friction: number;
  23442. /**
  23443. * Gets the coefficient of restitution
  23444. */
  23445. /**
  23446. * Sets the coefficient of restitution
  23447. */
  23448. restitution: number;
  23449. /**
  23450. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23451. */
  23452. /**
  23453. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23454. */
  23455. pressure: number;
  23456. /**
  23457. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23458. */
  23459. /**
  23460. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23461. */
  23462. stiffness: number;
  23463. /**
  23464. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23465. */
  23466. /**
  23467. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23468. */
  23469. velocityIterations: number;
  23470. /**
  23471. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23472. */
  23473. /**
  23474. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23475. */
  23476. positionIterations: number;
  23477. /**
  23478. * The unique id of the physics imposter
  23479. * set by the physics engine when adding this impostor to the array
  23480. */
  23481. uniqueId: number;
  23482. /**
  23483. * @hidden
  23484. */
  23485. soft: boolean;
  23486. /**
  23487. * @hidden
  23488. */
  23489. segments: number;
  23490. private _joints;
  23491. /**
  23492. * Initializes the physics imposter
  23493. * @param object The physics-enabled object used as the physics imposter
  23494. * @param type The type of the physics imposter
  23495. * @param _options The options for the physics imposter
  23496. * @param _scene The Babylon scene
  23497. */
  23498. constructor(
  23499. /**
  23500. * The physics-enabled object used as the physics imposter
  23501. */
  23502. object: IPhysicsEnabledObject,
  23503. /**
  23504. * The type of the physics imposter
  23505. */
  23506. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23507. /**
  23508. * This function will completly initialize this impostor.
  23509. * It will create a new body - but only if this mesh has no parent.
  23510. * If it has, this impostor will not be used other than to define the impostor
  23511. * of the child mesh.
  23512. * @hidden
  23513. */
  23514. _init(): void;
  23515. private _getPhysicsParent;
  23516. /**
  23517. * Should a new body be generated.
  23518. * @returns boolean specifying if body initialization is required
  23519. */
  23520. isBodyInitRequired(): boolean;
  23521. /**
  23522. * Sets the updated scaling
  23523. * @param updated Specifies if the scaling is updated
  23524. */
  23525. setScalingUpdated(): void;
  23526. /**
  23527. * Force a regeneration of this or the parent's impostor's body.
  23528. * Use under cautious - This will remove all joints already implemented.
  23529. */
  23530. forceUpdate(): void;
  23531. /**
  23532. * Gets the body that holds this impostor. Either its own, or its parent.
  23533. */
  23534. /**
  23535. * Set the physics body. Used mainly by the physics engine/plugin
  23536. */
  23537. physicsBody: any;
  23538. /**
  23539. * Get the parent of the physics imposter
  23540. * @returns Physics imposter or null
  23541. */
  23542. /**
  23543. * Sets the parent of the physics imposter
  23544. */
  23545. parent: Nullable<PhysicsImpostor>;
  23546. /**
  23547. * Resets the update flags
  23548. */
  23549. resetUpdateFlags(): void;
  23550. /**
  23551. * Gets the object extend size
  23552. * @returns the object extend size
  23553. */
  23554. getObjectExtendSize(): Vector3;
  23555. /**
  23556. * Gets the object center
  23557. * @returns The object center
  23558. */
  23559. getObjectCenter(): Vector3;
  23560. /**
  23561. * Get a specific parametes from the options parameter
  23562. * @param paramName The object parameter name
  23563. * @returns The object parameter
  23564. */
  23565. getParam(paramName: string): any;
  23566. /**
  23567. * Sets a specific parameter in the options given to the physics plugin
  23568. * @param paramName The parameter name
  23569. * @param value The value of the parameter
  23570. */
  23571. setParam(paramName: string, value: number): void;
  23572. /**
  23573. * Specifically change the body's mass option. Won't recreate the physics body object
  23574. * @param mass The mass of the physics imposter
  23575. */
  23576. setMass(mass: number): void;
  23577. /**
  23578. * Gets the linear velocity
  23579. * @returns linear velocity or null
  23580. */
  23581. getLinearVelocity(): Nullable<Vector3>;
  23582. /**
  23583. * Sets the linear velocity
  23584. * @param velocity linear velocity or null
  23585. */
  23586. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23587. /**
  23588. * Gets the angular velocity
  23589. * @returns angular velocity or null
  23590. */
  23591. getAngularVelocity(): Nullable<Vector3>;
  23592. /**
  23593. * Sets the angular velocity
  23594. * @param velocity The velocity or null
  23595. */
  23596. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23597. /**
  23598. * Execute a function with the physics plugin native code
  23599. * Provide a function the will have two variables - the world object and the physics body object
  23600. * @param func The function to execute with the physics plugin native code
  23601. */
  23602. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23603. /**
  23604. * Register a function that will be executed before the physics world is stepping forward
  23605. * @param func The function to execute before the physics world is stepped forward
  23606. */
  23607. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23608. /**
  23609. * Unregister a function that will be executed before the physics world is stepping forward
  23610. * @param func The function to execute before the physics world is stepped forward
  23611. */
  23612. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23613. /**
  23614. * Register a function that will be executed after the physics step
  23615. * @param func The function to execute after physics step
  23616. */
  23617. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23618. /**
  23619. * Unregisters a function that will be executed after the physics step
  23620. * @param func The function to execute after physics step
  23621. */
  23622. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23623. /**
  23624. * register a function that will be executed when this impostor collides against a different body
  23625. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23626. * @param func Callback that is executed on collision
  23627. */
  23628. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23629. /**
  23630. * Unregisters the physics imposter on contact
  23631. * @param collideAgainst The physics object to collide against
  23632. * @param func Callback to execute on collision
  23633. */
  23634. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23635. private _tmpQuat;
  23636. private _tmpQuat2;
  23637. /**
  23638. * Get the parent rotation
  23639. * @returns The parent rotation
  23640. */
  23641. getParentsRotation(): Quaternion;
  23642. /**
  23643. * this function is executed by the physics engine.
  23644. */
  23645. beforeStep: () => void;
  23646. /**
  23647. * this function is executed by the physics engine
  23648. */
  23649. afterStep: () => void;
  23650. /**
  23651. * Legacy collision detection event support
  23652. */
  23653. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23654. /**
  23655. * event and body object due to cannon's event-based architecture.
  23656. */
  23657. onCollide: (e: {
  23658. body: any;
  23659. }) => void;
  23660. /**
  23661. * Apply a force
  23662. * @param force The force to apply
  23663. * @param contactPoint The contact point for the force
  23664. * @returns The physics imposter
  23665. */
  23666. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23667. /**
  23668. * Apply an impulse
  23669. * @param force The impulse force
  23670. * @param contactPoint The contact point for the impulse force
  23671. * @returns The physics imposter
  23672. */
  23673. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23674. /**
  23675. * A help function to create a joint
  23676. * @param otherImpostor A physics imposter used to create a joint
  23677. * @param jointType The type of joint
  23678. * @param jointData The data for the joint
  23679. * @returns The physics imposter
  23680. */
  23681. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23682. /**
  23683. * Add a joint to this impostor with a different impostor
  23684. * @param otherImpostor A physics imposter used to add a joint
  23685. * @param joint The joint to add
  23686. * @returns The physics imposter
  23687. */
  23688. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23689. /**
  23690. * Add an anchor to a cloth impostor
  23691. * @param otherImpostor rigid impostor to anchor to
  23692. * @param width ratio across width from 0 to 1
  23693. * @param height ratio up height from 0 to 1
  23694. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23695. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23696. * @returns impostor the soft imposter
  23697. */
  23698. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23699. /**
  23700. * Add a hook to a rope impostor
  23701. * @param otherImpostor rigid impostor to anchor to
  23702. * @param length ratio across rope from 0 to 1
  23703. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23704. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23705. * @returns impostor the rope imposter
  23706. */
  23707. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23708. /**
  23709. * Will keep this body still, in a sleep mode.
  23710. * @returns the physics imposter
  23711. */
  23712. sleep(): PhysicsImpostor;
  23713. /**
  23714. * Wake the body up.
  23715. * @returns The physics imposter
  23716. */
  23717. wakeUp(): PhysicsImpostor;
  23718. /**
  23719. * Clones the physics imposter
  23720. * @param newObject The physics imposter clones to this physics-enabled object
  23721. * @returns A nullable physics imposter
  23722. */
  23723. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23724. /**
  23725. * Disposes the physics imposter
  23726. */
  23727. dispose(): void;
  23728. /**
  23729. * Sets the delta position
  23730. * @param position The delta position amount
  23731. */
  23732. setDeltaPosition(position: Vector3): void;
  23733. /**
  23734. * Sets the delta rotation
  23735. * @param rotation The delta rotation amount
  23736. */
  23737. setDeltaRotation(rotation: Quaternion): void;
  23738. /**
  23739. * Gets the box size of the physics imposter and stores the result in the input parameter
  23740. * @param result Stores the box size
  23741. * @returns The physics imposter
  23742. */
  23743. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23744. /**
  23745. * Gets the radius of the physics imposter
  23746. * @returns Radius of the physics imposter
  23747. */
  23748. getRadius(): number;
  23749. /**
  23750. * Sync a bone with this impostor
  23751. * @param bone The bone to sync to the impostor.
  23752. * @param boneMesh The mesh that the bone is influencing.
  23753. * @param jointPivot The pivot of the joint / bone in local space.
  23754. * @param distToJoint Optional distance from the impostor to the joint.
  23755. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23756. */
  23757. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23758. /**
  23759. * Sync impostor to a bone
  23760. * @param bone The bone that the impostor will be synced to.
  23761. * @param boneMesh The mesh that the bone is influencing.
  23762. * @param jointPivot The pivot of the joint / bone in local space.
  23763. * @param distToJoint Optional distance from the impostor to the joint.
  23764. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23765. * @param boneAxis Optional vector3 axis the bone is aligned with
  23766. */
  23767. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23768. /**
  23769. * No-Imposter type
  23770. */
  23771. static NoImpostor: number;
  23772. /**
  23773. * Sphere-Imposter type
  23774. */
  23775. static SphereImpostor: number;
  23776. /**
  23777. * Box-Imposter type
  23778. */
  23779. static BoxImpostor: number;
  23780. /**
  23781. * Plane-Imposter type
  23782. */
  23783. static PlaneImpostor: number;
  23784. /**
  23785. * Mesh-imposter type
  23786. */
  23787. static MeshImpostor: number;
  23788. /**
  23789. * Capsule-Impostor type (Ammo.js plugin only)
  23790. */
  23791. static CapsuleImpostor: number;
  23792. /**
  23793. * Cylinder-Imposter type
  23794. */
  23795. static CylinderImpostor: number;
  23796. /**
  23797. * Particle-Imposter type
  23798. */
  23799. static ParticleImpostor: number;
  23800. /**
  23801. * Heightmap-Imposter type
  23802. */
  23803. static HeightmapImpostor: number;
  23804. /**
  23805. * ConvexHull-Impostor type (Ammo.js plugin only)
  23806. */
  23807. static ConvexHullImpostor: number;
  23808. /**
  23809. * Rope-Imposter type
  23810. */
  23811. static RopeImpostor: number;
  23812. /**
  23813. * Cloth-Imposter type
  23814. */
  23815. static ClothImpostor: number;
  23816. /**
  23817. * Softbody-Imposter type
  23818. */
  23819. static SoftbodyImpostor: number;
  23820. }
  23821. }
  23822. declare module "babylonjs/Meshes/mesh" {
  23823. import { Observable } from "babylonjs/Misc/observable";
  23824. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23825. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23826. import { Camera } from "babylonjs/Cameras/camera";
  23827. import { Scene } from "babylonjs/scene";
  23828. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23829. import { Color4 } from "babylonjs/Maths/math.color";
  23830. import { Engine } from "babylonjs/Engines/engine";
  23831. import { Node } from "babylonjs/node";
  23832. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23833. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23834. import { Buffer } from "babylonjs/Meshes/buffer";
  23835. import { Geometry } from "babylonjs/Meshes/geometry";
  23836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23837. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23838. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23839. import { Effect } from "babylonjs/Materials/effect";
  23840. import { Material } from "babylonjs/Materials/material";
  23841. import { Skeleton } from "babylonjs/Bones/skeleton";
  23842. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23843. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23844. import { Path3D } from "babylonjs/Maths/math.path";
  23845. import { Plane } from "babylonjs/Maths/math.plane";
  23846. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23847. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23848. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23849. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23850. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23851. /**
  23852. * @hidden
  23853. **/
  23854. export class _CreationDataStorage {
  23855. closePath?: boolean;
  23856. closeArray?: boolean;
  23857. idx: number[];
  23858. dashSize: number;
  23859. gapSize: number;
  23860. path3D: Path3D;
  23861. pathArray: Vector3[][];
  23862. arc: number;
  23863. radius: number;
  23864. cap: number;
  23865. tessellation: number;
  23866. }
  23867. /**
  23868. * @hidden
  23869. **/
  23870. class _InstanceDataStorage {
  23871. visibleInstances: any;
  23872. batchCache: _InstancesBatch;
  23873. instancesBufferSize: number;
  23874. instancesBuffer: Nullable<Buffer>;
  23875. instancesData: Float32Array;
  23876. overridenInstanceCount: number;
  23877. isFrozen: boolean;
  23878. previousBatch: Nullable<_InstancesBatch>;
  23879. hardwareInstancedRendering: boolean;
  23880. sideOrientation: number;
  23881. }
  23882. /**
  23883. * @hidden
  23884. **/
  23885. export class _InstancesBatch {
  23886. mustReturn: boolean;
  23887. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23888. renderSelf: boolean[];
  23889. hardwareInstancedRendering: boolean[];
  23890. }
  23891. /**
  23892. * Class used to represent renderable models
  23893. */
  23894. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23895. /**
  23896. * Mesh side orientation : usually the external or front surface
  23897. */
  23898. static readonly FRONTSIDE: number;
  23899. /**
  23900. * Mesh side orientation : usually the internal or back surface
  23901. */
  23902. static readonly BACKSIDE: number;
  23903. /**
  23904. * Mesh side orientation : both internal and external or front and back surfaces
  23905. */
  23906. static readonly DOUBLESIDE: number;
  23907. /**
  23908. * Mesh side orientation : by default, `FRONTSIDE`
  23909. */
  23910. static readonly DEFAULTSIDE: number;
  23911. /**
  23912. * Mesh cap setting : no cap
  23913. */
  23914. static readonly NO_CAP: number;
  23915. /**
  23916. * Mesh cap setting : one cap at the beginning of the mesh
  23917. */
  23918. static readonly CAP_START: number;
  23919. /**
  23920. * Mesh cap setting : one cap at the end of the mesh
  23921. */
  23922. static readonly CAP_END: number;
  23923. /**
  23924. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23925. */
  23926. static readonly CAP_ALL: number;
  23927. /**
  23928. * Mesh pattern setting : no flip or rotate
  23929. */
  23930. static readonly NO_FLIP: number;
  23931. /**
  23932. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23933. */
  23934. static readonly FLIP_TILE: number;
  23935. /**
  23936. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23937. */
  23938. static readonly ROTATE_TILE: number;
  23939. /**
  23940. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23941. */
  23942. static readonly FLIP_ROW: number;
  23943. /**
  23944. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23945. */
  23946. static readonly ROTATE_ROW: number;
  23947. /**
  23948. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23949. */
  23950. static readonly FLIP_N_ROTATE_TILE: number;
  23951. /**
  23952. * Mesh pattern setting : rotate pattern and rotate
  23953. */
  23954. static readonly FLIP_N_ROTATE_ROW: number;
  23955. /**
  23956. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23957. */
  23958. static readonly CENTER: number;
  23959. /**
  23960. * Mesh tile positioning : part tiles on left
  23961. */
  23962. static readonly LEFT: number;
  23963. /**
  23964. * Mesh tile positioning : part tiles on right
  23965. */
  23966. static readonly RIGHT: number;
  23967. /**
  23968. * Mesh tile positioning : part tiles on top
  23969. */
  23970. static readonly TOP: number;
  23971. /**
  23972. * Mesh tile positioning : part tiles on bottom
  23973. */
  23974. static readonly BOTTOM: number;
  23975. /**
  23976. * Gets the default side orientation.
  23977. * @param orientation the orientation to value to attempt to get
  23978. * @returns the default orientation
  23979. * @hidden
  23980. */
  23981. static _GetDefaultSideOrientation(orientation?: number): number;
  23982. private _internalMeshDataInfo;
  23983. /**
  23984. * An event triggered before rendering the mesh
  23985. */
  23986. readonly onBeforeRenderObservable: Observable<Mesh>;
  23987. /**
  23988. * An event triggered before binding the mesh
  23989. */
  23990. readonly onBeforeBindObservable: Observable<Mesh>;
  23991. /**
  23992. * An event triggered after rendering the mesh
  23993. */
  23994. readonly onAfterRenderObservable: Observable<Mesh>;
  23995. /**
  23996. * An event triggered before drawing the mesh
  23997. */
  23998. readonly onBeforeDrawObservable: Observable<Mesh>;
  23999. private _onBeforeDrawObserver;
  24000. /**
  24001. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24002. */
  24003. onBeforeDraw: () => void;
  24004. /**
  24005. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24006. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24007. */
  24008. delayLoadState: number;
  24009. /**
  24010. * Gets the list of instances created from this mesh
  24011. * it is not supposed to be modified manually.
  24012. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24013. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24014. */
  24015. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24016. /**
  24017. * Gets the file containing delay loading data for this mesh
  24018. */
  24019. delayLoadingFile: string;
  24020. /** @hidden */
  24021. _binaryInfo: any;
  24022. /**
  24023. * User defined function used to change how LOD level selection is done
  24024. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24025. */
  24026. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24027. /**
  24028. * Gets or sets the morph target manager
  24029. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24030. */
  24031. morphTargetManager: Nullable<MorphTargetManager>;
  24032. /** @hidden */
  24033. _creationDataStorage: Nullable<_CreationDataStorage>;
  24034. /** @hidden */
  24035. _geometry: Nullable<Geometry>;
  24036. /** @hidden */
  24037. _delayInfo: Array<string>;
  24038. /** @hidden */
  24039. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24040. /** @hidden */
  24041. _instanceDataStorage: _InstanceDataStorage;
  24042. private _effectiveMaterial;
  24043. /** @hidden */
  24044. _shouldGenerateFlatShading: boolean;
  24045. /** @hidden */
  24046. _originalBuilderSideOrientation: number;
  24047. /**
  24048. * Use this property to change the original side orientation defined at construction time
  24049. */
  24050. overrideMaterialSideOrientation: Nullable<number>;
  24051. /**
  24052. * Gets the source mesh (the one used to clone this one from)
  24053. */
  24054. readonly source: Nullable<Mesh>;
  24055. /**
  24056. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24057. */
  24058. isUnIndexed: boolean;
  24059. /**
  24060. * @constructor
  24061. * @param name The value used by scene.getMeshByName() to do a lookup.
  24062. * @param scene The scene to add this mesh to.
  24063. * @param parent The parent of this mesh, if it has one
  24064. * @param source An optional Mesh from which geometry is shared, cloned.
  24065. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24066. * When false, achieved by calling a clone(), also passing False.
  24067. * This will make creation of children, recursive.
  24068. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24069. */
  24070. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24071. /**
  24072. * Gets the class name
  24073. * @returns the string "Mesh".
  24074. */
  24075. getClassName(): string;
  24076. /** @hidden */
  24077. readonly _isMesh: boolean;
  24078. /**
  24079. * Returns a description of this mesh
  24080. * @param fullDetails define if full details about this mesh must be used
  24081. * @returns a descriptive string representing this mesh
  24082. */
  24083. toString(fullDetails?: boolean): string;
  24084. /** @hidden */
  24085. _unBindEffect(): void;
  24086. /**
  24087. * Gets a boolean indicating if this mesh has LOD
  24088. */
  24089. readonly hasLODLevels: boolean;
  24090. /**
  24091. * Gets the list of MeshLODLevel associated with the current mesh
  24092. * @returns an array of MeshLODLevel
  24093. */
  24094. getLODLevels(): MeshLODLevel[];
  24095. private _sortLODLevels;
  24096. /**
  24097. * Add a mesh as LOD level triggered at the given distance.
  24098. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24099. * @param distance The distance from the center of the object to show this level
  24100. * @param mesh The mesh to be added as LOD level (can be null)
  24101. * @return This mesh (for chaining)
  24102. */
  24103. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24104. /**
  24105. * Returns the LOD level mesh at the passed distance or null if not found.
  24106. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24107. * @param distance The distance from the center of the object to show this level
  24108. * @returns a Mesh or `null`
  24109. */
  24110. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24111. /**
  24112. * Remove a mesh from the LOD array
  24113. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24114. * @param mesh defines the mesh to be removed
  24115. * @return This mesh (for chaining)
  24116. */
  24117. removeLODLevel(mesh: Mesh): Mesh;
  24118. /**
  24119. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24120. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24121. * @param camera defines the camera to use to compute distance
  24122. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24123. * @return This mesh (for chaining)
  24124. */
  24125. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24126. /**
  24127. * Gets the mesh internal Geometry object
  24128. */
  24129. readonly geometry: Nullable<Geometry>;
  24130. /**
  24131. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24132. * @returns the total number of vertices
  24133. */
  24134. getTotalVertices(): number;
  24135. /**
  24136. * Returns the content of an associated vertex buffer
  24137. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24138. * - VertexBuffer.PositionKind
  24139. * - VertexBuffer.UVKind
  24140. * - VertexBuffer.UV2Kind
  24141. * - VertexBuffer.UV3Kind
  24142. * - VertexBuffer.UV4Kind
  24143. * - VertexBuffer.UV5Kind
  24144. * - VertexBuffer.UV6Kind
  24145. * - VertexBuffer.ColorKind
  24146. * - VertexBuffer.MatricesIndicesKind
  24147. * - VertexBuffer.MatricesIndicesExtraKind
  24148. * - VertexBuffer.MatricesWeightsKind
  24149. * - VertexBuffer.MatricesWeightsExtraKind
  24150. * @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
  24151. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24152. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24153. */
  24154. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24155. /**
  24156. * Returns the mesh VertexBuffer object from the requested `kind`
  24157. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24158. * - VertexBuffer.PositionKind
  24159. * - VertexBuffer.NormalKind
  24160. * - VertexBuffer.UVKind
  24161. * - VertexBuffer.UV2Kind
  24162. * - VertexBuffer.UV3Kind
  24163. * - VertexBuffer.UV4Kind
  24164. * - VertexBuffer.UV5Kind
  24165. * - VertexBuffer.UV6Kind
  24166. * - VertexBuffer.ColorKind
  24167. * - VertexBuffer.MatricesIndicesKind
  24168. * - VertexBuffer.MatricesIndicesExtraKind
  24169. * - VertexBuffer.MatricesWeightsKind
  24170. * - VertexBuffer.MatricesWeightsExtraKind
  24171. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24172. */
  24173. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24174. /**
  24175. * Tests if a specific vertex buffer is associated with this mesh
  24176. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24177. * - VertexBuffer.PositionKind
  24178. * - VertexBuffer.NormalKind
  24179. * - VertexBuffer.UVKind
  24180. * - VertexBuffer.UV2Kind
  24181. * - VertexBuffer.UV3Kind
  24182. * - VertexBuffer.UV4Kind
  24183. * - VertexBuffer.UV5Kind
  24184. * - VertexBuffer.UV6Kind
  24185. * - VertexBuffer.ColorKind
  24186. * - VertexBuffer.MatricesIndicesKind
  24187. * - VertexBuffer.MatricesIndicesExtraKind
  24188. * - VertexBuffer.MatricesWeightsKind
  24189. * - VertexBuffer.MatricesWeightsExtraKind
  24190. * @returns a boolean
  24191. */
  24192. isVerticesDataPresent(kind: string): boolean;
  24193. /**
  24194. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24195. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24196. * - VertexBuffer.PositionKind
  24197. * - VertexBuffer.UVKind
  24198. * - VertexBuffer.UV2Kind
  24199. * - VertexBuffer.UV3Kind
  24200. * - VertexBuffer.UV4Kind
  24201. * - VertexBuffer.UV5Kind
  24202. * - VertexBuffer.UV6Kind
  24203. * - VertexBuffer.ColorKind
  24204. * - VertexBuffer.MatricesIndicesKind
  24205. * - VertexBuffer.MatricesIndicesExtraKind
  24206. * - VertexBuffer.MatricesWeightsKind
  24207. * - VertexBuffer.MatricesWeightsExtraKind
  24208. * @returns a boolean
  24209. */
  24210. isVertexBufferUpdatable(kind: string): boolean;
  24211. /**
  24212. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24213. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24214. * - VertexBuffer.PositionKind
  24215. * - VertexBuffer.NormalKind
  24216. * - VertexBuffer.UVKind
  24217. * - VertexBuffer.UV2Kind
  24218. * - VertexBuffer.UV3Kind
  24219. * - VertexBuffer.UV4Kind
  24220. * - VertexBuffer.UV5Kind
  24221. * - VertexBuffer.UV6Kind
  24222. * - VertexBuffer.ColorKind
  24223. * - VertexBuffer.MatricesIndicesKind
  24224. * - VertexBuffer.MatricesIndicesExtraKind
  24225. * - VertexBuffer.MatricesWeightsKind
  24226. * - VertexBuffer.MatricesWeightsExtraKind
  24227. * @returns an array of strings
  24228. */
  24229. getVerticesDataKinds(): string[];
  24230. /**
  24231. * Returns a positive integer : the total number of indices in this mesh geometry.
  24232. * @returns the numner of indices or zero if the mesh has no geometry.
  24233. */
  24234. getTotalIndices(): number;
  24235. /**
  24236. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24237. * @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.
  24238. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24239. * @returns the indices array or an empty array if the mesh has no geometry
  24240. */
  24241. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24242. readonly isBlocked: boolean;
  24243. /**
  24244. * Determine if the current mesh is ready to be rendered
  24245. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24246. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24247. * @returns true if all associated assets are ready (material, textures, shaders)
  24248. */
  24249. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24250. /**
  24251. * 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.
  24252. */
  24253. readonly areNormalsFrozen: boolean;
  24254. /**
  24255. * 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.
  24256. * @returns the current mesh
  24257. */
  24258. freezeNormals(): Mesh;
  24259. /**
  24260. * 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
  24261. * @returns the current mesh
  24262. */
  24263. unfreezeNormals(): Mesh;
  24264. /**
  24265. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24266. */
  24267. overridenInstanceCount: number;
  24268. /** @hidden */
  24269. _preActivate(): Mesh;
  24270. /** @hidden */
  24271. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24272. /** @hidden */
  24273. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24274. /**
  24275. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24276. * This means the mesh underlying bounding box and sphere are recomputed.
  24277. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24278. * @returns the current mesh
  24279. */
  24280. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24281. /** @hidden */
  24282. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24283. /**
  24284. * This function will subdivide the mesh into multiple submeshes
  24285. * @param count defines the expected number of submeshes
  24286. */
  24287. subdivide(count: number): void;
  24288. /**
  24289. * Copy a FloatArray into a specific associated vertex buffer
  24290. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24291. * - VertexBuffer.PositionKind
  24292. * - VertexBuffer.UVKind
  24293. * - VertexBuffer.UV2Kind
  24294. * - VertexBuffer.UV3Kind
  24295. * - VertexBuffer.UV4Kind
  24296. * - VertexBuffer.UV5Kind
  24297. * - VertexBuffer.UV6Kind
  24298. * - VertexBuffer.ColorKind
  24299. * - VertexBuffer.MatricesIndicesKind
  24300. * - VertexBuffer.MatricesIndicesExtraKind
  24301. * - VertexBuffer.MatricesWeightsKind
  24302. * - VertexBuffer.MatricesWeightsExtraKind
  24303. * @param data defines the data source
  24304. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24305. * @param stride defines the data stride size (can be null)
  24306. * @returns the current mesh
  24307. */
  24308. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24309. /**
  24310. * Flags an associated vertex buffer as updatable
  24311. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24312. * - VertexBuffer.PositionKind
  24313. * - VertexBuffer.UVKind
  24314. * - VertexBuffer.UV2Kind
  24315. * - VertexBuffer.UV3Kind
  24316. * - VertexBuffer.UV4Kind
  24317. * - VertexBuffer.UV5Kind
  24318. * - VertexBuffer.UV6Kind
  24319. * - VertexBuffer.ColorKind
  24320. * - VertexBuffer.MatricesIndicesKind
  24321. * - VertexBuffer.MatricesIndicesExtraKind
  24322. * - VertexBuffer.MatricesWeightsKind
  24323. * - VertexBuffer.MatricesWeightsExtraKind
  24324. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24325. */
  24326. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24327. /**
  24328. * Sets the mesh global Vertex Buffer
  24329. * @param buffer defines the buffer to use
  24330. * @returns the current mesh
  24331. */
  24332. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24333. /**
  24334. * Update a specific associated vertex buffer
  24335. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24336. * - VertexBuffer.PositionKind
  24337. * - VertexBuffer.UVKind
  24338. * - VertexBuffer.UV2Kind
  24339. * - VertexBuffer.UV3Kind
  24340. * - VertexBuffer.UV4Kind
  24341. * - VertexBuffer.UV5Kind
  24342. * - VertexBuffer.UV6Kind
  24343. * - VertexBuffer.ColorKind
  24344. * - VertexBuffer.MatricesIndicesKind
  24345. * - VertexBuffer.MatricesIndicesExtraKind
  24346. * - VertexBuffer.MatricesWeightsKind
  24347. * - VertexBuffer.MatricesWeightsExtraKind
  24348. * @param data defines the data source
  24349. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24350. * @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)
  24351. * @returns the current mesh
  24352. */
  24353. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24354. /**
  24355. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24356. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24357. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24358. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24359. * @returns the current mesh
  24360. */
  24361. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24362. /**
  24363. * Creates a un-shared specific occurence of the geometry for the mesh.
  24364. * @returns the current mesh
  24365. */
  24366. makeGeometryUnique(): Mesh;
  24367. /**
  24368. * Set the index buffer of this mesh
  24369. * @param indices defines the source data
  24370. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24371. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24372. * @returns the current mesh
  24373. */
  24374. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24375. /**
  24376. * Update the current index buffer
  24377. * @param indices defines the source data
  24378. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24379. * @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)
  24380. * @returns the current mesh
  24381. */
  24382. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24383. /**
  24384. * Invert the geometry to move from a right handed system to a left handed one.
  24385. * @returns the current mesh
  24386. */
  24387. toLeftHanded(): Mesh;
  24388. /** @hidden */
  24389. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24390. /** @hidden */
  24391. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24392. /**
  24393. * Registers for this mesh a javascript function called just before the rendering process
  24394. * @param func defines the function to call before rendering this mesh
  24395. * @returns the current mesh
  24396. */
  24397. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24398. /**
  24399. * Disposes a previously registered javascript function called before the rendering
  24400. * @param func defines the function to remove
  24401. * @returns the current mesh
  24402. */
  24403. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24404. /**
  24405. * Registers for this mesh a javascript function called just after the rendering is complete
  24406. * @param func defines the function to call after rendering this mesh
  24407. * @returns the current mesh
  24408. */
  24409. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24410. /**
  24411. * Disposes a previously registered javascript function called after the rendering.
  24412. * @param func defines the function to remove
  24413. * @returns the current mesh
  24414. */
  24415. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24416. /** @hidden */
  24417. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24418. /** @hidden */
  24419. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24420. /** @hidden */
  24421. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24422. /** @hidden */
  24423. _rebuild(): void;
  24424. /** @hidden */
  24425. _freeze(): void;
  24426. /** @hidden */
  24427. _unFreeze(): void;
  24428. /**
  24429. * 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
  24430. * @param subMesh defines the subMesh to render
  24431. * @param enableAlphaMode defines if alpha mode can be changed
  24432. * @returns the current mesh
  24433. */
  24434. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24435. private _onBeforeDraw;
  24436. /**
  24437. * Renormalize the mesh and patch it up if there are no weights
  24438. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24439. * However in the case of zero weights then we set just a single influence to 1.
  24440. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24441. */
  24442. cleanMatrixWeights(): void;
  24443. private normalizeSkinFourWeights;
  24444. private normalizeSkinWeightsAndExtra;
  24445. /**
  24446. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24447. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24448. * the user know there was an issue with importing the mesh
  24449. * @returns a validation object with skinned, valid and report string
  24450. */
  24451. validateSkinning(): {
  24452. skinned: boolean;
  24453. valid: boolean;
  24454. report: string;
  24455. };
  24456. /** @hidden */
  24457. _checkDelayState(): Mesh;
  24458. private _queueLoad;
  24459. /**
  24460. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24461. * A mesh is in the frustum if its bounding box intersects the frustum
  24462. * @param frustumPlanes defines the frustum to test
  24463. * @returns true if the mesh is in the frustum planes
  24464. */
  24465. isInFrustum(frustumPlanes: Plane[]): boolean;
  24466. /**
  24467. * Sets the mesh material by the material or multiMaterial `id` property
  24468. * @param id is a string identifying the material or the multiMaterial
  24469. * @returns the current mesh
  24470. */
  24471. setMaterialByID(id: string): Mesh;
  24472. /**
  24473. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24474. * @returns an array of IAnimatable
  24475. */
  24476. getAnimatables(): IAnimatable[];
  24477. /**
  24478. * Modifies the mesh geometry according to the passed transformation matrix.
  24479. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24480. * The mesh normals are modified using the same transformation.
  24481. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24482. * @param transform defines the transform matrix to use
  24483. * @see http://doc.babylonjs.com/resources/baking_transformations
  24484. * @returns the current mesh
  24485. */
  24486. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24487. /**
  24488. * Modifies the mesh geometry according to its own current World Matrix.
  24489. * The mesh World Matrix is then reset.
  24490. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24491. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24492. * @see http://doc.babylonjs.com/resources/baking_transformations
  24493. * @returns the current mesh
  24494. */
  24495. bakeCurrentTransformIntoVertices(): Mesh;
  24496. /** @hidden */
  24497. readonly _positions: Nullable<Vector3[]>;
  24498. /** @hidden */
  24499. _resetPointsArrayCache(): Mesh;
  24500. /** @hidden */
  24501. _generatePointsArray(): boolean;
  24502. /**
  24503. * Returns a new Mesh object generated from the current mesh properties.
  24504. * This method must not get confused with createInstance()
  24505. * @param name is a string, the name given to the new mesh
  24506. * @param newParent can be any Node object (default `null`)
  24507. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24508. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24509. * @returns a new mesh
  24510. */
  24511. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24512. /**
  24513. * Releases resources associated with this mesh.
  24514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24516. */
  24517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24518. /**
  24519. * Modifies the mesh geometry according to a displacement map.
  24520. * 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.
  24521. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24522. * @param url is a string, the URL from the image file is to be downloaded.
  24523. * @param minHeight is the lower limit of the displacement.
  24524. * @param maxHeight is the upper limit of the displacement.
  24525. * @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.
  24526. * @param uvOffset is an optional vector2 used to offset UV.
  24527. * @param uvScale is an optional vector2 used to scale UV.
  24528. * @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.
  24529. * @returns the Mesh.
  24530. */
  24531. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24532. /**
  24533. * Modifies the mesh geometry according to a displacementMap buffer.
  24534. * 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.
  24535. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24536. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24537. * @param heightMapWidth is the width of the buffer image.
  24538. * @param heightMapHeight is the height of the buffer image.
  24539. * @param minHeight is the lower limit of the displacement.
  24540. * @param maxHeight is the upper limit of the displacement.
  24541. * @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.
  24542. * @param uvOffset is an optional vector2 used to offset UV.
  24543. * @param uvScale is an optional vector2 used to scale UV.
  24544. * @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.
  24545. * @returns the Mesh.
  24546. */
  24547. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24548. /**
  24549. * Modify the mesh to get a flat shading rendering.
  24550. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24551. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24552. * @returns current mesh
  24553. */
  24554. convertToFlatShadedMesh(): Mesh;
  24555. /**
  24556. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24557. * In other words, more vertices, no more indices and a single bigger VBO.
  24558. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24559. * @returns current mesh
  24560. */
  24561. convertToUnIndexedMesh(): Mesh;
  24562. /**
  24563. * Inverses facet orientations.
  24564. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24565. * @param flipNormals will also inverts the normals
  24566. * @returns current mesh
  24567. */
  24568. flipFaces(flipNormals?: boolean): Mesh;
  24569. /**
  24570. * Increase the number of facets and hence vertices in a mesh
  24571. * Vertex normals are interpolated from existing vertex normals
  24572. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24573. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24574. */
  24575. increaseVertices(numberPerEdge: number): void;
  24576. /**
  24577. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24578. * This will undo any application of covertToFlatShadedMesh
  24579. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24580. */
  24581. forceSharedVertices(): void;
  24582. /** @hidden */
  24583. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24584. /** @hidden */
  24585. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24586. /**
  24587. * Creates a new InstancedMesh object from the mesh model.
  24588. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24589. * @param name defines the name of the new instance
  24590. * @returns a new InstancedMesh
  24591. */
  24592. createInstance(name: string): InstancedMesh;
  24593. /**
  24594. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24595. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24596. * @returns the current mesh
  24597. */
  24598. synchronizeInstances(): Mesh;
  24599. /**
  24600. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24601. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24602. * This should be used together with the simplification to avoid disappearing triangles.
  24603. * @param successCallback an optional success callback to be called after the optimization finished.
  24604. * @returns the current mesh
  24605. */
  24606. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24607. /**
  24608. * Serialize current mesh
  24609. * @param serializationObject defines the object which will receive the serialization data
  24610. */
  24611. serialize(serializationObject: any): void;
  24612. /** @hidden */
  24613. _syncGeometryWithMorphTargetManager(): void;
  24614. /** @hidden */
  24615. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24616. /**
  24617. * Returns a new Mesh object parsed from the source provided.
  24618. * @param parsedMesh is the source
  24619. * @param scene defines the hosting scene
  24620. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24621. * @returns a new Mesh
  24622. */
  24623. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24624. /**
  24625. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24626. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24627. * @param name defines the name of the mesh to create
  24628. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24629. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24630. * @param closePath creates a seam between the first and the last points of each path of the path array
  24631. * @param offset is taken in account only if the `pathArray` is containing a single path
  24632. * @param scene defines the hosting scene
  24633. * @param updatable defines if the mesh must be flagged as updatable
  24634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24635. * @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)
  24636. * @returns a new Mesh
  24637. */
  24638. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24639. /**
  24640. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24641. * @param name defines the name of the mesh to create
  24642. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24643. * @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
  24644. * @param scene defines the hosting scene
  24645. * @param updatable defines if the mesh must be flagged as updatable
  24646. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24647. * @returns a new Mesh
  24648. */
  24649. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24650. /**
  24651. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24652. * @param name defines the name of the mesh to create
  24653. * @param size sets the size (float) of each box side (default 1)
  24654. * @param scene defines the hosting scene
  24655. * @param updatable defines if the mesh must be flagged as updatable
  24656. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24657. * @returns a new Mesh
  24658. */
  24659. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24660. /**
  24661. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24662. * @param name defines the name of the mesh to create
  24663. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24664. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24665. * @param scene defines the hosting scene
  24666. * @param updatable defines if the mesh must be flagged as updatable
  24667. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24668. * @returns a new Mesh
  24669. */
  24670. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24671. /**
  24672. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24673. * @param name defines the name of the mesh to create
  24674. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24675. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24676. * @param scene defines the hosting scene
  24677. * @returns a new Mesh
  24678. */
  24679. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24680. /**
  24681. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24682. * @param name defines the name of the mesh to create
  24683. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24684. * @param diameterTop set the top cap diameter (floats, default 1)
  24685. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24686. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24687. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24688. * @param scene defines the hosting scene
  24689. * @param updatable defines if the mesh must be flagged as updatable
  24690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24691. * @returns a new Mesh
  24692. */
  24693. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24694. /**
  24695. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24696. * @param name defines the name of the mesh to create
  24697. * @param diameter sets the diameter size (float) of the torus (default 1)
  24698. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24699. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24700. * @param scene defines the hosting scene
  24701. * @param updatable defines if the mesh must be flagged as updatable
  24702. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24703. * @returns a new Mesh
  24704. */
  24705. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24706. /**
  24707. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24708. * @param name defines the name of the mesh to create
  24709. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24710. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24711. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24712. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24713. * @param p the number of windings on X axis (positive integers, default 2)
  24714. * @param q the number of windings on Y axis (positive integers, default 3)
  24715. * @param scene defines the hosting scene
  24716. * @param updatable defines if the mesh must be flagged as updatable
  24717. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24718. * @returns a new Mesh
  24719. */
  24720. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24721. /**
  24722. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24723. * @param name defines the name of the mesh to create
  24724. * @param points is an array successive Vector3
  24725. * @param scene defines the hosting scene
  24726. * @param updatable defines if the mesh must be flagged as updatable
  24727. * @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).
  24728. * @returns a new Mesh
  24729. */
  24730. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24731. /**
  24732. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24733. * @param name defines the name of the mesh to create
  24734. * @param points is an array successive Vector3
  24735. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24736. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24737. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24738. * @param scene defines the hosting scene
  24739. * @param updatable defines if the mesh must be flagged as updatable
  24740. * @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)
  24741. * @returns a new Mesh
  24742. */
  24743. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24744. /**
  24745. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24746. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24747. * 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.
  24748. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24749. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24750. * Remember you can only change the shape positions, not their number when updating a polygon.
  24751. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24752. * @param name defines the name of the mesh to create
  24753. * @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
  24754. * @param scene defines the hosting scene
  24755. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24756. * @param updatable defines if the mesh must be flagged as updatable
  24757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24758. * @param earcutInjection can be used to inject your own earcut reference
  24759. * @returns a new Mesh
  24760. */
  24761. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24762. /**
  24763. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24764. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24765. * @param name defines the name of the mesh to create
  24766. * @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
  24767. * @param depth defines the height of extrusion
  24768. * @param scene defines the hosting scene
  24769. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24770. * @param updatable defines if the mesh must be flagged as updatable
  24771. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24772. * @param earcutInjection can be used to inject your own earcut reference
  24773. * @returns a new Mesh
  24774. */
  24775. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24776. /**
  24777. * Creates an extruded shape mesh.
  24778. * 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
  24779. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24780. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24781. * @param name defines the name of the mesh to create
  24782. * @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
  24783. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24784. * @param scale is the value to scale the shape
  24785. * @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
  24786. * @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
  24787. * @param scene defines the hosting scene
  24788. * @param updatable defines if the mesh must be flagged as updatable
  24789. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24790. * @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)
  24791. * @returns a new Mesh
  24792. */
  24793. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24794. /**
  24795. * Creates an custom extruded shape mesh.
  24796. * The custom extrusion is a parametric shape.
  24797. * It has no predefined shape. Its final shape will depend on the input parameters.
  24798. * Please consider using the same method from the MeshBuilder class instead
  24799. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24800. * @param name defines the name of the mesh to create
  24801. * @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
  24802. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24803. * @param scaleFunction is a custom Javascript function called on each path point
  24804. * @param rotationFunction is a custom Javascript function called on each path point
  24805. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24806. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24807. * @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
  24808. * @param scene defines the hosting scene
  24809. * @param updatable defines if the mesh must be flagged as updatable
  24810. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24811. * @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)
  24812. * @returns a new Mesh
  24813. */
  24814. 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;
  24815. /**
  24816. * Creates lathe mesh.
  24817. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24818. * Please consider using the same method from the MeshBuilder class instead
  24819. * @param name defines the name of the mesh to create
  24820. * @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
  24821. * @param radius is the radius value of the lathe
  24822. * @param tessellation is the side number of the lathe.
  24823. * @param scene defines the hosting scene
  24824. * @param updatable defines if the mesh must be flagged as updatable
  24825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24826. * @returns a new Mesh
  24827. */
  24828. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24829. /**
  24830. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24831. * @param name defines the name of the mesh to create
  24832. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24833. * @param scene defines the hosting scene
  24834. * @param updatable defines if the mesh must be flagged as updatable
  24835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24836. * @returns a new Mesh
  24837. */
  24838. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24839. /**
  24840. * Creates a ground mesh.
  24841. * Please consider using the same method from the MeshBuilder class instead
  24842. * @param name defines the name of the mesh to create
  24843. * @param width set the width of the ground
  24844. * @param height set the height of the ground
  24845. * @param subdivisions sets the number of subdivisions per side
  24846. * @param scene defines the hosting scene
  24847. * @param updatable defines if the mesh must be flagged as updatable
  24848. * @returns a new Mesh
  24849. */
  24850. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24851. /**
  24852. * Creates a tiled ground mesh.
  24853. * Please consider using the same method from the MeshBuilder class instead
  24854. * @param name defines the name of the mesh to create
  24855. * @param xmin set the ground minimum X coordinate
  24856. * @param zmin set the ground minimum Y coordinate
  24857. * @param xmax set the ground maximum X coordinate
  24858. * @param zmax set the ground maximum Z coordinate
  24859. * @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
  24860. * @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
  24861. * @param scene defines the hosting scene
  24862. * @param updatable defines if the mesh must be flagged as updatable
  24863. * @returns a new Mesh
  24864. */
  24865. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24866. w: number;
  24867. h: number;
  24868. }, precision: {
  24869. w: number;
  24870. h: number;
  24871. }, scene: Scene, updatable?: boolean): Mesh;
  24872. /**
  24873. * Creates a ground mesh from a height map.
  24874. * Please consider using the same method from the MeshBuilder class instead
  24875. * @see http://doc.babylonjs.com/babylon101/height_map
  24876. * @param name defines the name of the mesh to create
  24877. * @param url sets the URL of the height map image resource
  24878. * @param width set the ground width size
  24879. * @param height set the ground height size
  24880. * @param subdivisions sets the number of subdivision per side
  24881. * @param minHeight is the minimum altitude on the ground
  24882. * @param maxHeight is the maximum altitude on the ground
  24883. * @param scene defines the hosting scene
  24884. * @param updatable defines if the mesh must be flagged as updatable
  24885. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24886. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24887. * @returns a new Mesh
  24888. */
  24889. 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;
  24890. /**
  24891. * Creates a tube mesh.
  24892. * The tube is a parametric shape.
  24893. * It has no predefined shape. Its final shape will depend on the input parameters.
  24894. * Please consider using the same method from the MeshBuilder class instead
  24895. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24896. * @param name defines the name of the mesh to create
  24897. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24898. * @param radius sets the tube radius size
  24899. * @param tessellation is the number of sides on the tubular surface
  24900. * @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
  24901. * @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
  24902. * @param scene defines the hosting scene
  24903. * @param updatable defines if the mesh must be flagged as updatable
  24904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24905. * @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)
  24906. * @returns a new Mesh
  24907. */
  24908. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24909. (i: number, distance: number): number;
  24910. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24911. /**
  24912. * Creates a polyhedron mesh.
  24913. * Please consider using the same method from the MeshBuilder class instead.
  24914. * * 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
  24915. * * The parameter `size` (positive float, default 1) sets the polygon size
  24916. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24917. * * 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`
  24918. * * 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
  24919. * * 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)`)
  24920. * * 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
  24921. * * 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
  24922. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24923. * * If you create a double-sided mesh, you can choose what parts of 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
  24924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24925. * @param name defines the name of the mesh to create
  24926. * @param options defines the options used to create the mesh
  24927. * @param scene defines the hosting scene
  24928. * @returns a new Mesh
  24929. */
  24930. static CreatePolyhedron(name: string, options: {
  24931. type?: number;
  24932. size?: number;
  24933. sizeX?: number;
  24934. sizeY?: number;
  24935. sizeZ?: number;
  24936. custom?: any;
  24937. faceUV?: Vector4[];
  24938. faceColors?: Color4[];
  24939. updatable?: boolean;
  24940. sideOrientation?: number;
  24941. }, scene: Scene): Mesh;
  24942. /**
  24943. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24944. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24945. * * 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`)
  24946. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24947. * * 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
  24948. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24949. * * If you create a double-sided mesh, you can choose what parts of 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
  24950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24951. * @param name defines the name of the mesh
  24952. * @param options defines the options used to create the mesh
  24953. * @param scene defines the hosting scene
  24954. * @returns a new Mesh
  24955. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24956. */
  24957. static CreateIcoSphere(name: string, options: {
  24958. radius?: number;
  24959. flat?: boolean;
  24960. subdivisions?: number;
  24961. sideOrientation?: number;
  24962. updatable?: boolean;
  24963. }, scene: Scene): Mesh;
  24964. /**
  24965. * Creates a decal mesh.
  24966. * Please consider using the same method from the MeshBuilder class instead.
  24967. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24968. * @param name defines the name of the mesh
  24969. * @param sourceMesh defines the mesh receiving the decal
  24970. * @param position sets the position of the decal in world coordinates
  24971. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24972. * @param size sets the decal scaling
  24973. * @param angle sets the angle to rotate the decal
  24974. * @returns a new Mesh
  24975. */
  24976. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24977. /**
  24978. * Prepare internal position array for software CPU skinning
  24979. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24980. */
  24981. setPositionsForCPUSkinning(): Float32Array;
  24982. /**
  24983. * Prepare internal normal array for software CPU skinning
  24984. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24985. */
  24986. setNormalsForCPUSkinning(): Float32Array;
  24987. /**
  24988. * Updates the vertex buffer by applying transformation from the bones
  24989. * @param skeleton defines the skeleton to apply to current mesh
  24990. * @returns the current mesh
  24991. */
  24992. applySkeleton(skeleton: Skeleton): Mesh;
  24993. /**
  24994. * 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
  24995. * @param meshes defines the list of meshes to scan
  24996. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24997. */
  24998. static MinMax(meshes: AbstractMesh[]): {
  24999. min: Vector3;
  25000. max: Vector3;
  25001. };
  25002. /**
  25003. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25004. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25005. * @returns a vector3
  25006. */
  25007. static Center(meshesOrMinMaxVector: {
  25008. min: Vector3;
  25009. max: Vector3;
  25010. } | AbstractMesh[]): Vector3;
  25011. /**
  25012. * Merge the array of meshes into a single mesh for performance reasons.
  25013. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25014. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25015. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25016. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25017. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25018. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25019. * @returns a new mesh
  25020. */
  25021. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25022. /** @hidden */
  25023. addInstance(instance: InstancedMesh): void;
  25024. /** @hidden */
  25025. removeInstance(instance: InstancedMesh): void;
  25026. }
  25027. }
  25028. declare module "babylonjs/Cameras/camera" {
  25029. import { SmartArray } from "babylonjs/Misc/smartArray";
  25030. import { Observable } from "babylonjs/Misc/observable";
  25031. import { Nullable } from "babylonjs/types";
  25032. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25033. import { Scene } from "babylonjs/scene";
  25034. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25035. import { Node } from "babylonjs/node";
  25036. import { Mesh } from "babylonjs/Meshes/mesh";
  25037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25038. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25039. import { Viewport } from "babylonjs/Maths/math.viewport";
  25040. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25042. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25043. import { Ray } from "babylonjs/Culling/ray";
  25044. /**
  25045. * This is the base class of all the camera used in the application.
  25046. * @see http://doc.babylonjs.com/features/cameras
  25047. */
  25048. export class Camera extends Node {
  25049. /** @hidden */
  25050. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25051. /**
  25052. * This is the default projection mode used by the cameras.
  25053. * It helps recreating a feeling of perspective and better appreciate depth.
  25054. * This is the best way to simulate real life cameras.
  25055. */
  25056. static readonly PERSPECTIVE_CAMERA: number;
  25057. /**
  25058. * This helps creating camera with an orthographic mode.
  25059. * 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.
  25060. */
  25061. static readonly ORTHOGRAPHIC_CAMERA: number;
  25062. /**
  25063. * This is the default FOV mode for perspective cameras.
  25064. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25065. */
  25066. static readonly FOVMODE_VERTICAL_FIXED: number;
  25067. /**
  25068. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25069. */
  25070. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25071. /**
  25072. * This specifies ther is no need for a camera rig.
  25073. * Basically only one eye is rendered corresponding to the camera.
  25074. */
  25075. static readonly RIG_MODE_NONE: number;
  25076. /**
  25077. * Simulates a camera Rig with one blue eye and one red eye.
  25078. * This can be use with 3d blue and red glasses.
  25079. */
  25080. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25081. /**
  25082. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25083. */
  25084. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25085. /**
  25086. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25087. */
  25088. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25089. /**
  25090. * Defines that both eyes of the camera will be rendered over under each other.
  25091. */
  25092. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25093. /**
  25094. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25095. */
  25096. static readonly RIG_MODE_VR: number;
  25097. /**
  25098. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25099. */
  25100. static readonly RIG_MODE_WEBVR: number;
  25101. /**
  25102. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25103. */
  25104. static readonly RIG_MODE_CUSTOM: number;
  25105. /**
  25106. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25107. */
  25108. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25109. /**
  25110. * Define the input manager associated with the camera.
  25111. */
  25112. inputs: CameraInputsManager<Camera>;
  25113. /** @hidden */
  25114. _position: Vector3;
  25115. /**
  25116. * Define the current local position of the camera in the scene
  25117. */
  25118. position: Vector3;
  25119. /**
  25120. * The vector the camera should consider as up.
  25121. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25122. */
  25123. upVector: Vector3;
  25124. /**
  25125. * Define the current limit on the left side for an orthographic camera
  25126. * In scene unit
  25127. */
  25128. orthoLeft: Nullable<number>;
  25129. /**
  25130. * Define the current limit on the right side for an orthographic camera
  25131. * In scene unit
  25132. */
  25133. orthoRight: Nullable<number>;
  25134. /**
  25135. * Define the current limit on the bottom side for an orthographic camera
  25136. * In scene unit
  25137. */
  25138. orthoBottom: Nullable<number>;
  25139. /**
  25140. * Define the current limit on the top side for an orthographic camera
  25141. * In scene unit
  25142. */
  25143. orthoTop: Nullable<number>;
  25144. /**
  25145. * Field Of View is set in Radians. (default is 0.8)
  25146. */
  25147. fov: number;
  25148. /**
  25149. * Define the minimum distance the camera can see from.
  25150. * This is important to note that the depth buffer are not infinite and the closer it starts
  25151. * the more your scene might encounter depth fighting issue.
  25152. */
  25153. minZ: number;
  25154. /**
  25155. * Define the maximum distance the camera can see to.
  25156. * This is important to note that the depth buffer are not infinite and the further it end
  25157. * the more your scene might encounter depth fighting issue.
  25158. */
  25159. maxZ: number;
  25160. /**
  25161. * Define the default inertia of the camera.
  25162. * This helps giving a smooth feeling to the camera movement.
  25163. */
  25164. inertia: number;
  25165. /**
  25166. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25167. */
  25168. mode: number;
  25169. /**
  25170. * Define wether the camera is intermediate.
  25171. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25172. */
  25173. isIntermediate: boolean;
  25174. /**
  25175. * Define the viewport of the camera.
  25176. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25177. */
  25178. viewport: Viewport;
  25179. /**
  25180. * Restricts the camera to viewing objects with the same layerMask.
  25181. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25182. */
  25183. layerMask: number;
  25184. /**
  25185. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25186. */
  25187. fovMode: number;
  25188. /**
  25189. * Rig mode of the camera.
  25190. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25191. * This is normally controlled byt the camera themselves as internal use.
  25192. */
  25193. cameraRigMode: number;
  25194. /**
  25195. * Defines the distance between both "eyes" in case of a RIG
  25196. */
  25197. interaxialDistance: number;
  25198. /**
  25199. * Defines if stereoscopic rendering is done side by side or over under.
  25200. */
  25201. isStereoscopicSideBySide: boolean;
  25202. /**
  25203. * 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
  25204. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25205. * else in the scene. (Eg. security camera)
  25206. *
  25207. * 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)
  25208. */
  25209. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25210. /**
  25211. * When set, the camera will render to this render target instead of the default canvas
  25212. *
  25213. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25214. */
  25215. outputRenderTarget: Nullable<RenderTargetTexture>;
  25216. /**
  25217. * Observable triggered when the camera view matrix has changed.
  25218. */
  25219. onViewMatrixChangedObservable: Observable<Camera>;
  25220. /**
  25221. * Observable triggered when the camera Projection matrix has changed.
  25222. */
  25223. onProjectionMatrixChangedObservable: Observable<Camera>;
  25224. /**
  25225. * Observable triggered when the inputs have been processed.
  25226. */
  25227. onAfterCheckInputsObservable: Observable<Camera>;
  25228. /**
  25229. * Observable triggered when reset has been called and applied to the camera.
  25230. */
  25231. onRestoreStateObservable: Observable<Camera>;
  25232. /** @hidden */
  25233. _cameraRigParams: any;
  25234. /** @hidden */
  25235. _rigCameras: Camera[];
  25236. /** @hidden */
  25237. _rigPostProcess: Nullable<PostProcess>;
  25238. protected _webvrViewMatrix: Matrix;
  25239. /** @hidden */
  25240. _skipRendering: boolean;
  25241. /** @hidden */
  25242. _projectionMatrix: Matrix;
  25243. /** @hidden */
  25244. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25245. /** @hidden */
  25246. _activeMeshes: SmartArray<AbstractMesh>;
  25247. protected _globalPosition: Vector3;
  25248. /** @hidden */
  25249. _computedViewMatrix: Matrix;
  25250. private _doNotComputeProjectionMatrix;
  25251. private _transformMatrix;
  25252. private _frustumPlanes;
  25253. private _refreshFrustumPlanes;
  25254. private _storedFov;
  25255. private _stateStored;
  25256. /**
  25257. * Instantiates a new camera object.
  25258. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25259. * @see http://doc.babylonjs.com/features/cameras
  25260. * @param name Defines the name of the camera in the scene
  25261. * @param position Defines the position of the camera
  25262. * @param scene Defines the scene the camera belongs too
  25263. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25264. */
  25265. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25266. /**
  25267. * Store current camera state (fov, position, etc..)
  25268. * @returns the camera
  25269. */
  25270. storeState(): Camera;
  25271. /**
  25272. * Restores the camera state values if it has been stored. You must call storeState() first
  25273. */
  25274. protected _restoreStateValues(): boolean;
  25275. /**
  25276. * Restored camera state. You must call storeState() first.
  25277. * @returns true if restored and false otherwise
  25278. */
  25279. restoreState(): boolean;
  25280. /**
  25281. * Gets the class name of the camera.
  25282. * @returns the class name
  25283. */
  25284. getClassName(): string;
  25285. /** @hidden */
  25286. readonly _isCamera: boolean;
  25287. /**
  25288. * Gets a string representation of the camera useful for debug purpose.
  25289. * @param fullDetails Defines that a more verboe level of logging is required
  25290. * @returns the string representation
  25291. */
  25292. toString(fullDetails?: boolean): string;
  25293. /**
  25294. * Gets the current world space position of the camera.
  25295. */
  25296. readonly globalPosition: Vector3;
  25297. /**
  25298. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25299. * @returns the active meshe list
  25300. */
  25301. getActiveMeshes(): SmartArray<AbstractMesh>;
  25302. /**
  25303. * Check wether a mesh is part of the current active mesh list of the camera
  25304. * @param mesh Defines the mesh to check
  25305. * @returns true if active, false otherwise
  25306. */
  25307. isActiveMesh(mesh: Mesh): boolean;
  25308. /**
  25309. * Is this camera ready to be used/rendered
  25310. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25311. * @return true if the camera is ready
  25312. */
  25313. isReady(completeCheck?: boolean): boolean;
  25314. /** @hidden */
  25315. _initCache(): void;
  25316. /** @hidden */
  25317. _updateCache(ignoreParentClass?: boolean): void;
  25318. /** @hidden */
  25319. _isSynchronized(): boolean;
  25320. /** @hidden */
  25321. _isSynchronizedViewMatrix(): boolean;
  25322. /** @hidden */
  25323. _isSynchronizedProjectionMatrix(): boolean;
  25324. /**
  25325. * Attach the input controls to a specific dom element to get the input from.
  25326. * @param element Defines the element the controls should be listened from
  25327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25328. */
  25329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25330. /**
  25331. * Detach the current controls from the specified dom element.
  25332. * @param element Defines the element to stop listening the inputs from
  25333. */
  25334. detachControl(element: HTMLElement): void;
  25335. /**
  25336. * Update the camera state according to the different inputs gathered during the frame.
  25337. */
  25338. update(): void;
  25339. /** @hidden */
  25340. _checkInputs(): void;
  25341. /** @hidden */
  25342. readonly rigCameras: Camera[];
  25343. /**
  25344. * Gets the post process used by the rig cameras
  25345. */
  25346. readonly rigPostProcess: Nullable<PostProcess>;
  25347. /**
  25348. * Internal, gets the first post proces.
  25349. * @returns the first post process to be run on this camera.
  25350. */
  25351. _getFirstPostProcess(): Nullable<PostProcess>;
  25352. private _cascadePostProcessesToRigCams;
  25353. /**
  25354. * Attach a post process to the camera.
  25355. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25356. * @param postProcess The post process to attach to the camera
  25357. * @param insertAt The position of the post process in case several of them are in use in the scene
  25358. * @returns the position the post process has been inserted at
  25359. */
  25360. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25361. /**
  25362. * Detach a post process to the camera.
  25363. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25364. * @param postProcess The post process to detach from the camera
  25365. */
  25366. detachPostProcess(postProcess: PostProcess): void;
  25367. /**
  25368. * Gets the current world matrix of the camera
  25369. */
  25370. getWorldMatrix(): Matrix;
  25371. /** @hidden */
  25372. _getViewMatrix(): Matrix;
  25373. /**
  25374. * Gets the current view matrix of the camera.
  25375. * @param force forces the camera to recompute the matrix without looking at the cached state
  25376. * @returns the view matrix
  25377. */
  25378. getViewMatrix(force?: boolean): Matrix;
  25379. /**
  25380. * Freeze the projection matrix.
  25381. * It will prevent the cache check of the camera projection compute and can speed up perf
  25382. * if no parameter of the camera are meant to change
  25383. * @param projection Defines manually a projection if necessary
  25384. */
  25385. freezeProjectionMatrix(projection?: Matrix): void;
  25386. /**
  25387. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25388. */
  25389. unfreezeProjectionMatrix(): void;
  25390. /**
  25391. * Gets the current projection matrix of the camera.
  25392. * @param force forces the camera to recompute the matrix without looking at the cached state
  25393. * @returns the projection matrix
  25394. */
  25395. getProjectionMatrix(force?: boolean): Matrix;
  25396. /**
  25397. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25398. * @returns a Matrix
  25399. */
  25400. getTransformationMatrix(): Matrix;
  25401. private _updateFrustumPlanes;
  25402. /**
  25403. * Checks if a cullable object (mesh...) is in the camera frustum
  25404. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25405. * @param target The object to check
  25406. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25407. * @returns true if the object is in frustum otherwise false
  25408. */
  25409. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25410. /**
  25411. * Checks if a cullable object (mesh...) is in the camera frustum
  25412. * Unlike isInFrustum this cheks the full bounding box
  25413. * @param target The object to check
  25414. * @returns true if the object is in frustum otherwise false
  25415. */
  25416. isCompletelyInFrustum(target: ICullable): boolean;
  25417. /**
  25418. * Gets a ray in the forward direction from the camera.
  25419. * @param length Defines the length of the ray to create
  25420. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25421. * @param origin Defines the start point of the ray which defaults to the camera position
  25422. * @returns the forward ray
  25423. */
  25424. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25425. /**
  25426. * Releases resources associated with this node.
  25427. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25428. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25429. */
  25430. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25431. /** @hidden */
  25432. _isLeftCamera: boolean;
  25433. /**
  25434. * Gets the left camera of a rig setup in case of Rigged Camera
  25435. */
  25436. readonly isLeftCamera: boolean;
  25437. /** @hidden */
  25438. _isRightCamera: boolean;
  25439. /**
  25440. * Gets the right camera of a rig setup in case of Rigged Camera
  25441. */
  25442. readonly isRightCamera: boolean;
  25443. /**
  25444. * Gets the left camera of a rig setup in case of Rigged Camera
  25445. */
  25446. readonly leftCamera: Nullable<FreeCamera>;
  25447. /**
  25448. * Gets the right camera of a rig setup in case of Rigged Camera
  25449. */
  25450. readonly rightCamera: Nullable<FreeCamera>;
  25451. /**
  25452. * Gets the left camera target of a rig setup in case of Rigged Camera
  25453. * @returns the target position
  25454. */
  25455. getLeftTarget(): Nullable<Vector3>;
  25456. /**
  25457. * Gets the right camera target of a rig setup in case of Rigged Camera
  25458. * @returns the target position
  25459. */
  25460. getRightTarget(): Nullable<Vector3>;
  25461. /**
  25462. * @hidden
  25463. */
  25464. setCameraRigMode(mode: number, rigParams: any): void;
  25465. /** @hidden */
  25466. static _setStereoscopicRigMode(camera: Camera): void;
  25467. /** @hidden */
  25468. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25469. /** @hidden */
  25470. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25471. /** @hidden */
  25472. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25473. /** @hidden */
  25474. _getVRProjectionMatrix(): Matrix;
  25475. protected _updateCameraRotationMatrix(): void;
  25476. protected _updateWebVRCameraRotationMatrix(): void;
  25477. /**
  25478. * This function MUST be overwritten by the different WebVR cameras available.
  25479. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25480. * @hidden
  25481. */
  25482. _getWebVRProjectionMatrix(): Matrix;
  25483. /**
  25484. * This function MUST be overwritten by the different WebVR cameras available.
  25485. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25486. * @hidden
  25487. */
  25488. _getWebVRViewMatrix(): Matrix;
  25489. /** @hidden */
  25490. setCameraRigParameter(name: string, value: any): void;
  25491. /**
  25492. * needs to be overridden by children so sub has required properties to be copied
  25493. * @hidden
  25494. */
  25495. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25496. /**
  25497. * May need to be overridden by children
  25498. * @hidden
  25499. */
  25500. _updateRigCameras(): void;
  25501. /** @hidden */
  25502. _setupInputs(): void;
  25503. /**
  25504. * Serialiaze the camera setup to a json represention
  25505. * @returns the JSON representation
  25506. */
  25507. serialize(): any;
  25508. /**
  25509. * Clones the current camera.
  25510. * @param name The cloned camera name
  25511. * @returns the cloned camera
  25512. */
  25513. clone(name: string): Camera;
  25514. /**
  25515. * Gets the direction of the camera relative to a given local axis.
  25516. * @param localAxis Defines the reference axis to provide a relative direction.
  25517. * @return the direction
  25518. */
  25519. getDirection(localAxis: Vector3): Vector3;
  25520. /**
  25521. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25522. * @param localAxis Defines the reference axis to provide a relative direction.
  25523. * @param result Defines the vector to store the result in
  25524. */
  25525. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25526. /**
  25527. * Gets a camera constructor for a given camera type
  25528. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25529. * @param name The name of the camera the result will be able to instantiate
  25530. * @param scene The scene the result will construct the camera in
  25531. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25532. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25533. * @returns a factory method to construc the camera
  25534. */
  25535. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25536. /**
  25537. * Compute the world matrix of the camera.
  25538. * @returns the camera workd matrix
  25539. */
  25540. computeWorldMatrix(): Matrix;
  25541. /**
  25542. * Parse a JSON and creates the camera from the parsed information
  25543. * @param parsedCamera The JSON to parse
  25544. * @param scene The scene to instantiate the camera in
  25545. * @returns the newly constructed camera
  25546. */
  25547. static Parse(parsedCamera: any, scene: Scene): Camera;
  25548. }
  25549. }
  25550. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25551. import { Nullable } from "babylonjs/types";
  25552. import { Scene } from "babylonjs/scene";
  25553. import { Vector4 } from "babylonjs/Maths/math.vector";
  25554. import { Mesh } from "babylonjs/Meshes/mesh";
  25555. /**
  25556. * Class containing static functions to help procedurally build meshes
  25557. */
  25558. export class DiscBuilder {
  25559. /**
  25560. * Creates a plane polygonal mesh. By default, this is a disc
  25561. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25562. * * 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
  25563. * * 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
  25564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25567. * @param name defines the name of the mesh
  25568. * @param options defines the options used to create the mesh
  25569. * @param scene defines the hosting scene
  25570. * @returns the plane polygonal mesh
  25571. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25572. */
  25573. static CreateDisc(name: string, options: {
  25574. radius?: number;
  25575. tessellation?: number;
  25576. arc?: number;
  25577. updatable?: boolean;
  25578. sideOrientation?: number;
  25579. frontUVs?: Vector4;
  25580. backUVs?: Vector4;
  25581. }, scene?: Nullable<Scene>): Mesh;
  25582. }
  25583. }
  25584. declare module "babylonjs/Particles/solidParticleSystem" {
  25585. import { Vector3 } from "babylonjs/Maths/math.vector";
  25586. import { Mesh } from "babylonjs/Meshes/mesh";
  25587. import { Scene, IDisposable } from "babylonjs/scene";
  25588. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25589. /**
  25590. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25591. *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.
  25592. * The SPS is also a particle system. It provides some methods to manage the particles.
  25593. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25594. *
  25595. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  25596. */
  25597. export class SolidParticleSystem implements IDisposable {
  25598. /**
  25599. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25600. * Example : var p = SPS.particles[i];
  25601. */
  25602. particles: SolidParticle[];
  25603. /**
  25604. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25605. */
  25606. nbParticles: number;
  25607. /**
  25608. * If the particles must ever face the camera (default false). Useful for planar particles.
  25609. */
  25610. billboard: boolean;
  25611. /**
  25612. * Recompute normals when adding a shape
  25613. */
  25614. recomputeNormals: boolean;
  25615. /**
  25616. * This a counter ofr your own usage. It's not set by any SPS functions.
  25617. */
  25618. counter: number;
  25619. /**
  25620. * The SPS name. This name is also given to the underlying mesh.
  25621. */
  25622. name: string;
  25623. /**
  25624. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25625. */
  25626. mesh: Mesh;
  25627. /**
  25628. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25629. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  25630. */
  25631. vars: any;
  25632. /**
  25633. * This array is populated when the SPS is set as 'pickable'.
  25634. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25635. * Each element of this array is an object `{idx: int, faceId: int}`.
  25636. * `idx` is the picked particle index in the `SPS.particles` array
  25637. * `faceId` is the picked face index counted within this particle.
  25638. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  25639. */
  25640. pickedParticles: {
  25641. idx: number;
  25642. faceId: number;
  25643. }[];
  25644. /**
  25645. * This array is populated when `enableDepthSort` is set to true.
  25646. * Each element of this array is an instance of the class DepthSortedParticle.
  25647. */
  25648. depthSortedParticles: DepthSortedParticle[];
  25649. /**
  25650. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25651. * @hidden
  25652. */
  25653. _bSphereOnly: boolean;
  25654. /**
  25655. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25656. * @hidden
  25657. */
  25658. _bSphereRadiusFactor: number;
  25659. private _scene;
  25660. private _positions;
  25661. private _indices;
  25662. private _normals;
  25663. private _colors;
  25664. private _uvs;
  25665. private _indices32;
  25666. private _positions32;
  25667. private _normals32;
  25668. private _fixedNormal32;
  25669. private _colors32;
  25670. private _uvs32;
  25671. private _index;
  25672. private _updatable;
  25673. private _pickable;
  25674. private _isVisibilityBoxLocked;
  25675. private _alwaysVisible;
  25676. private _depthSort;
  25677. private _shapeCounter;
  25678. private _copy;
  25679. private _color;
  25680. private _computeParticleColor;
  25681. private _computeParticleTexture;
  25682. private _computeParticleRotation;
  25683. private _computeParticleVertex;
  25684. private _computeBoundingBox;
  25685. private _depthSortParticles;
  25686. private _camera;
  25687. private _mustUnrotateFixedNormals;
  25688. private _particlesIntersect;
  25689. private _needs32Bits;
  25690. /**
  25691. * Creates a SPS (Solid Particle System) object.
  25692. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25693. * @param scene (Scene) is the scene in which the SPS is added.
  25694. * @param options defines the options of the sps e.g.
  25695. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25696. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25697. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25698. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25699. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25700. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25701. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25702. */
  25703. constructor(name: string, scene: Scene, options?: {
  25704. updatable?: boolean;
  25705. isPickable?: boolean;
  25706. enableDepthSort?: boolean;
  25707. particleIntersection?: boolean;
  25708. boundingSphereOnly?: boolean;
  25709. bSphereRadiusFactor?: number;
  25710. });
  25711. /**
  25712. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25713. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25714. * @returns the created mesh
  25715. */
  25716. buildMesh(): Mesh;
  25717. /**
  25718. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25719. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25720. * Thus the particles generated from `digest()` have their property `position` set yet.
  25721. * @param mesh ( Mesh ) is the mesh to be digested
  25722. * @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
  25723. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25724. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25725. * @returns the current SPS
  25726. */
  25727. digest(mesh: Mesh, options?: {
  25728. facetNb?: number;
  25729. number?: number;
  25730. delta?: number;
  25731. }): SolidParticleSystem;
  25732. private _unrotateFixedNormals;
  25733. private _resetCopy;
  25734. private _meshBuilder;
  25735. private _posToShape;
  25736. private _uvsToShapeUV;
  25737. private _addParticle;
  25738. /**
  25739. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25740. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25741. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25742. * @param nb (positive integer) the number of particles to be created from this model
  25743. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25744. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25745. * @returns the number of shapes in the system
  25746. */
  25747. addShape(mesh: Mesh, nb: number, options?: {
  25748. positionFunction?: any;
  25749. vertexFunction?: any;
  25750. }): number;
  25751. private _rebuildParticle;
  25752. /**
  25753. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25754. * @returns the SPS.
  25755. */
  25756. rebuildMesh(): SolidParticleSystem;
  25757. /**
  25758. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25759. * This method calls `updateParticle()` for each particle of the SPS.
  25760. * For an animated SPS, it is usually called within the render loop.
  25761. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25762. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25763. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25764. * @returns the SPS.
  25765. */
  25766. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25767. /**
  25768. * Disposes the SPS.
  25769. */
  25770. dispose(): void;
  25771. /**
  25772. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25774. * @returns the SPS.
  25775. */
  25776. refreshVisibleSize(): SolidParticleSystem;
  25777. /**
  25778. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25779. * @param size the size (float) of the visibility box
  25780. * note : this doesn't lock the SPS mesh bounding box.
  25781. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25782. */
  25783. setVisibilityBox(size: number): void;
  25784. /**
  25785. * Gets whether the SPS as always visible or not
  25786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25787. */
  25788. /**
  25789. * Sets the SPS as always visible or not
  25790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25791. */
  25792. isAlwaysVisible: boolean;
  25793. /**
  25794. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25796. */
  25797. /**
  25798. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25800. */
  25801. isVisibilityBoxLocked: boolean;
  25802. /**
  25803. * Tells to `setParticles()` to compute the particle rotations or not.
  25804. * Default value : true. The SPS is faster when it's set to false.
  25805. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25806. */
  25807. /**
  25808. * Gets if `setParticles()` computes the particle rotations or not.
  25809. * Default value : true. The SPS is faster when it's set to false.
  25810. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25811. */
  25812. computeParticleRotation: boolean;
  25813. /**
  25814. * Tells to `setParticles()` to compute the particle colors or not.
  25815. * Default value : true. The SPS is faster when it's set to false.
  25816. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25817. */
  25818. /**
  25819. * Gets if `setParticles()` computes the particle colors or not.
  25820. * Default value : true. The SPS is faster when it's set to false.
  25821. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25822. */
  25823. computeParticleColor: boolean;
  25824. /**
  25825. * Gets if `setParticles()` computes the particle textures or not.
  25826. * Default value : true. The SPS is faster when it's set to false.
  25827. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25828. */
  25829. computeParticleTexture: boolean;
  25830. /**
  25831. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25832. * Default value : false. The SPS is faster when it's set to false.
  25833. * Note : the particle custom vertex positions aren't stored values.
  25834. */
  25835. /**
  25836. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25837. * Default value : false. The SPS is faster when it's set to false.
  25838. * Note : the particle custom vertex positions aren't stored values.
  25839. */
  25840. computeParticleVertex: boolean;
  25841. /**
  25842. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25843. */
  25844. /**
  25845. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25846. */
  25847. computeBoundingBox: boolean;
  25848. /**
  25849. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25850. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25851. * Default : `true`
  25852. */
  25853. /**
  25854. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25855. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25856. * Default : `true`
  25857. */
  25858. depthSortParticles: boolean;
  25859. /**
  25860. * This function does nothing. It may be overwritten to set all the particle first values.
  25861. * The SPS doesn't call this function, you may have to call it by your own.
  25862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25863. */
  25864. initParticles(): void;
  25865. /**
  25866. * This function does nothing. It may be overwritten to recycle a particle.
  25867. * The SPS doesn't call this function, you may have to call it by your own.
  25868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25869. * @param particle The particle to recycle
  25870. * @returns the recycled particle
  25871. */
  25872. recycleParticle(particle: SolidParticle): SolidParticle;
  25873. /**
  25874. * Updates a particle : this function should be overwritten by the user.
  25875. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25877. * @example : just set a particle position or velocity and recycle conditions
  25878. * @param particle The particle to update
  25879. * @returns the updated particle
  25880. */
  25881. updateParticle(particle: SolidParticle): SolidParticle;
  25882. /**
  25883. * Updates a vertex of a particle : it can be overwritten by the user.
  25884. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25885. * @param particle the current particle
  25886. * @param vertex the current index of the current particle
  25887. * @param pt the index of the current vertex in the particle shape
  25888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  25889. * @example : just set a vertex particle position
  25890. * @returns the updated vertex
  25891. */
  25892. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25893. /**
  25894. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25895. * This does nothing and may be overwritten by the user.
  25896. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25897. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25898. * @param update the boolean update value actually passed to setParticles()
  25899. */
  25900. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25901. /**
  25902. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25903. * This will be passed three parameters.
  25904. * This does nothing and may be overwritten by the user.
  25905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25907. * @param update the boolean update value actually passed to setParticles()
  25908. */
  25909. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25910. }
  25911. }
  25912. declare module "babylonjs/Particles/solidParticle" {
  25913. import { Nullable } from "babylonjs/types";
  25914. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25915. import { Color4 } from "babylonjs/Maths/math.color";
  25916. import { Mesh } from "babylonjs/Meshes/mesh";
  25917. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25918. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25919. import { Plane } from "babylonjs/Maths/math.plane";
  25920. /**
  25921. * Represents one particle of a solid particle system.
  25922. */
  25923. export class SolidParticle {
  25924. /**
  25925. * particle global index
  25926. */
  25927. idx: number;
  25928. /**
  25929. * The color of the particle
  25930. */
  25931. color: Nullable<Color4>;
  25932. /**
  25933. * The world space position of the particle.
  25934. */
  25935. position: Vector3;
  25936. /**
  25937. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25938. */
  25939. rotation: Vector3;
  25940. /**
  25941. * The world space rotation quaternion of the particle.
  25942. */
  25943. rotationQuaternion: Nullable<Quaternion>;
  25944. /**
  25945. * The scaling of the particle.
  25946. */
  25947. scaling: Vector3;
  25948. /**
  25949. * The uvs of the particle.
  25950. */
  25951. uvs: Vector4;
  25952. /**
  25953. * The current speed of the particle.
  25954. */
  25955. velocity: Vector3;
  25956. /**
  25957. * The pivot point in the particle local space.
  25958. */
  25959. pivot: Vector3;
  25960. /**
  25961. * Must the particle be translated from its pivot point in its local space ?
  25962. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25963. * Default : false
  25964. */
  25965. translateFromPivot: boolean;
  25966. /**
  25967. * Is the particle active or not ?
  25968. */
  25969. alive: boolean;
  25970. /**
  25971. * Is the particle visible or not ?
  25972. */
  25973. isVisible: boolean;
  25974. /**
  25975. * Index of this particle in the global "positions" array (Internal use)
  25976. * @hidden
  25977. */
  25978. _pos: number;
  25979. /**
  25980. * @hidden Index of this particle in the global "indices" array (Internal use)
  25981. */
  25982. _ind: number;
  25983. /**
  25984. * @hidden ModelShape of this particle (Internal use)
  25985. */
  25986. _model: ModelShape;
  25987. /**
  25988. * ModelShape id of this particle
  25989. */
  25990. shapeId: number;
  25991. /**
  25992. * Index of the particle in its shape id (Internal use)
  25993. */
  25994. idxInShape: number;
  25995. /**
  25996. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25997. */
  25998. _modelBoundingInfo: BoundingInfo;
  25999. /**
  26000. * @hidden Particle BoundingInfo object (Internal use)
  26001. */
  26002. _boundingInfo: BoundingInfo;
  26003. /**
  26004. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26005. */
  26006. _sps: SolidParticleSystem;
  26007. /**
  26008. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26009. */
  26010. _stillInvisible: boolean;
  26011. /**
  26012. * @hidden Last computed particle rotation matrix
  26013. */
  26014. _rotationMatrix: number[];
  26015. /**
  26016. * Parent particle Id, if any.
  26017. * Default null.
  26018. */
  26019. parentId: Nullable<number>;
  26020. /**
  26021. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26022. * The possible values are :
  26023. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26024. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26025. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26026. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26027. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26028. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26029. * */
  26030. cullingStrategy: number;
  26031. /**
  26032. * @hidden Internal global position in the SPS.
  26033. */
  26034. _globalPosition: Vector3;
  26035. /**
  26036. * Creates a Solid Particle object.
  26037. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26038. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26039. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26040. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26041. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26042. * @param shapeId (integer) is the model shape identifier in the SPS.
  26043. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26044. * @param sps defines the sps it is associated to
  26045. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26046. */
  26047. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26048. /**
  26049. * Legacy support, changed scale to scaling
  26050. */
  26051. /**
  26052. * Legacy support, changed scale to scaling
  26053. */
  26054. scale: Vector3;
  26055. /**
  26056. * Legacy support, changed quaternion to rotationQuaternion
  26057. */
  26058. /**
  26059. * Legacy support, changed quaternion to rotationQuaternion
  26060. */
  26061. quaternion: Nullable<Quaternion>;
  26062. /**
  26063. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26064. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26065. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26066. * @returns true if it intersects
  26067. */
  26068. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26069. /**
  26070. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26071. * A particle is in the frustum if its bounding box intersects the frustum
  26072. * @param frustumPlanes defines the frustum to test
  26073. * @returns true if the particle is in the frustum planes
  26074. */
  26075. isInFrustum(frustumPlanes: Plane[]): boolean;
  26076. /**
  26077. * get the rotation matrix of the particle
  26078. * @hidden
  26079. */
  26080. getRotationMatrix(m: Matrix): void;
  26081. }
  26082. /**
  26083. * Represents the shape of the model used by one particle of a solid particle system.
  26084. * SPS internal tool, don't use it manually.
  26085. */
  26086. export class ModelShape {
  26087. /**
  26088. * The shape id
  26089. * @hidden
  26090. */
  26091. shapeID: number;
  26092. /**
  26093. * flat array of model positions (internal use)
  26094. * @hidden
  26095. */
  26096. _shape: Vector3[];
  26097. /**
  26098. * flat array of model UVs (internal use)
  26099. * @hidden
  26100. */
  26101. _shapeUV: number[];
  26102. /**
  26103. * length of the shape in the model indices array (internal use)
  26104. * @hidden
  26105. */
  26106. _indicesLength: number;
  26107. /**
  26108. * Custom position function (internal use)
  26109. * @hidden
  26110. */
  26111. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26112. /**
  26113. * Custom vertex function (internal use)
  26114. * @hidden
  26115. */
  26116. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26117. /**
  26118. * 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.
  26119. * SPS internal tool, don't use it manually.
  26120. * @hidden
  26121. */
  26122. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26123. }
  26124. /**
  26125. * Represents a Depth Sorted Particle in the solid particle system.
  26126. */
  26127. export class DepthSortedParticle {
  26128. /**
  26129. * Index of the particle in the "indices" array
  26130. */
  26131. ind: number;
  26132. /**
  26133. * Length of the particle shape in the "indices" array
  26134. */
  26135. indicesLength: number;
  26136. /**
  26137. * Squared distance from the particle to the camera
  26138. */
  26139. sqDistance: number;
  26140. }
  26141. }
  26142. declare module "babylonjs/Collisions/meshCollisionData" {
  26143. import { Collider } from "babylonjs/Collisions/collider";
  26144. import { Vector3 } from "babylonjs/Maths/math.vector";
  26145. import { Nullable } from "babylonjs/types";
  26146. import { Observer } from "babylonjs/Misc/observable";
  26147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26148. /**
  26149. * @hidden
  26150. */
  26151. export class _MeshCollisionData {
  26152. _checkCollisions: boolean;
  26153. _collisionMask: number;
  26154. _collisionGroup: number;
  26155. _collider: Nullable<Collider>;
  26156. _oldPositionForCollisions: Vector3;
  26157. _diffPositionForCollisions: Vector3;
  26158. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26159. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26160. }
  26161. }
  26162. declare module "babylonjs/Meshes/abstractMesh" {
  26163. import { Observable } from "babylonjs/Misc/observable";
  26164. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26165. import { Camera } from "babylonjs/Cameras/camera";
  26166. import { Scene, IDisposable } from "babylonjs/scene";
  26167. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26168. import { Node } from "babylonjs/node";
  26169. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26170. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26172. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26173. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26174. import { Material } from "babylonjs/Materials/material";
  26175. import { Light } from "babylonjs/Lights/light";
  26176. import { Skeleton } from "babylonjs/Bones/skeleton";
  26177. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26178. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26179. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26180. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26181. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26182. import { Plane } from "babylonjs/Maths/math.plane";
  26183. import { Ray } from "babylonjs/Culling/ray";
  26184. import { Collider } from "babylonjs/Collisions/collider";
  26185. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26186. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26187. /** @hidden */
  26188. class _FacetDataStorage {
  26189. facetPositions: Vector3[];
  26190. facetNormals: Vector3[];
  26191. facetPartitioning: number[][];
  26192. facetNb: number;
  26193. partitioningSubdivisions: number;
  26194. partitioningBBoxRatio: number;
  26195. facetDataEnabled: boolean;
  26196. facetParameters: any;
  26197. bbSize: Vector3;
  26198. subDiv: {
  26199. max: number;
  26200. X: number;
  26201. Y: number;
  26202. Z: number;
  26203. };
  26204. facetDepthSort: boolean;
  26205. facetDepthSortEnabled: boolean;
  26206. depthSortedIndices: IndicesArray;
  26207. depthSortedFacets: {
  26208. ind: number;
  26209. sqDistance: number;
  26210. }[];
  26211. facetDepthSortFunction: (f1: {
  26212. ind: number;
  26213. sqDistance: number;
  26214. }, f2: {
  26215. ind: number;
  26216. sqDistance: number;
  26217. }) => number;
  26218. facetDepthSortFrom: Vector3;
  26219. facetDepthSortOrigin: Vector3;
  26220. invertedMatrix: Matrix;
  26221. }
  26222. /**
  26223. * @hidden
  26224. **/
  26225. class _InternalAbstractMeshDataInfo {
  26226. _hasVertexAlpha: boolean;
  26227. _useVertexColors: boolean;
  26228. _numBoneInfluencers: number;
  26229. _applyFog: boolean;
  26230. _receiveShadows: boolean;
  26231. _facetData: _FacetDataStorage;
  26232. _visibility: number;
  26233. _skeleton: Nullable<Skeleton>;
  26234. _layerMask: number;
  26235. _computeBonesUsingShaders: boolean;
  26236. _isActive: boolean;
  26237. _onlyForInstances: boolean;
  26238. _isActiveIntermediate: boolean;
  26239. _onlyForInstancesIntermediate: boolean;
  26240. }
  26241. /**
  26242. * Class used to store all common mesh properties
  26243. */
  26244. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26245. /** No occlusion */
  26246. static OCCLUSION_TYPE_NONE: number;
  26247. /** Occlusion set to optimisitic */
  26248. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26249. /** Occlusion set to strict */
  26250. static OCCLUSION_TYPE_STRICT: number;
  26251. /** Use an accurante occlusion algorithm */
  26252. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26253. /** Use a conservative occlusion algorithm */
  26254. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26255. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26256. * Test order :
  26257. * Is the bounding sphere outside the frustum ?
  26258. * If not, are the bounding box vertices outside the frustum ?
  26259. * It not, then the cullable object is in the frustum.
  26260. */
  26261. static readonly CULLINGSTRATEGY_STANDARD: number;
  26262. /** Culling strategy : Bounding Sphere Only.
  26263. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26264. * It's also less accurate than the standard because some not visible objects can still be selected.
  26265. * Test : is the bounding sphere outside the frustum ?
  26266. * If not, then the cullable object is in the frustum.
  26267. */
  26268. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26269. /** Culling strategy : Optimistic Inclusion.
  26270. * This in an inclusion test first, then the standard exclusion test.
  26271. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26272. * 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.
  26273. * Anyway, it's as accurate as the standard strategy.
  26274. * Test :
  26275. * Is the cullable object bounding sphere center in the frustum ?
  26276. * If not, apply the default culling strategy.
  26277. */
  26278. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26279. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26280. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26281. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26282. * 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.
  26283. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26284. * Test :
  26285. * Is the cullable object bounding sphere center in the frustum ?
  26286. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26287. */
  26288. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26289. /**
  26290. * No billboard
  26291. */
  26292. static readonly BILLBOARDMODE_NONE: number;
  26293. /** Billboard on X axis */
  26294. static readonly BILLBOARDMODE_X: number;
  26295. /** Billboard on Y axis */
  26296. static readonly BILLBOARDMODE_Y: number;
  26297. /** Billboard on Z axis */
  26298. static readonly BILLBOARDMODE_Z: number;
  26299. /** Billboard on all axes */
  26300. static readonly BILLBOARDMODE_ALL: number;
  26301. /** @hidden */
  26302. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26303. /**
  26304. * The culling strategy to use to check whether the mesh must be rendered or not.
  26305. * This value can be changed at any time and will be used on the next render mesh selection.
  26306. * The possible values are :
  26307. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26308. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26310. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26311. * Please read each static variable documentation to get details about the culling process.
  26312. * */
  26313. cullingStrategy: number;
  26314. /**
  26315. * Gets the number of facets in the mesh
  26316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26317. */
  26318. readonly facetNb: number;
  26319. /**
  26320. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26322. */
  26323. partitioningSubdivisions: number;
  26324. /**
  26325. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26326. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26328. */
  26329. partitioningBBoxRatio: number;
  26330. /**
  26331. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26332. * Works only for updatable meshes.
  26333. * Doesn't work with multi-materials
  26334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26335. */
  26336. mustDepthSortFacets: boolean;
  26337. /**
  26338. * The location (Vector3) where the facet depth sort must be computed from.
  26339. * By default, the active camera position.
  26340. * Used only when facet depth sort is enabled
  26341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26342. */
  26343. facetDepthSortFrom: Vector3;
  26344. /**
  26345. * gets a boolean indicating if facetData is enabled
  26346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26347. */
  26348. readonly isFacetDataEnabled: boolean;
  26349. /** @hidden */
  26350. _updateNonUniformScalingState(value: boolean): boolean;
  26351. /**
  26352. * An event triggered when this mesh collides with another one
  26353. */
  26354. onCollideObservable: Observable<AbstractMesh>;
  26355. /** Set a function to call when this mesh collides with another one */
  26356. onCollide: () => void;
  26357. /**
  26358. * An event triggered when the collision's position changes
  26359. */
  26360. onCollisionPositionChangeObservable: Observable<Vector3>;
  26361. /** Set a function to call when the collision's position changes */
  26362. onCollisionPositionChange: () => void;
  26363. /**
  26364. * An event triggered when material is changed
  26365. */
  26366. onMaterialChangedObservable: Observable<AbstractMesh>;
  26367. /**
  26368. * Gets or sets the orientation for POV movement & rotation
  26369. */
  26370. definedFacingForward: boolean;
  26371. /** @hidden */
  26372. _occlusionQuery: Nullable<WebGLQuery>;
  26373. /** @hidden */
  26374. _renderingGroup: Nullable<RenderingGroup>;
  26375. /**
  26376. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26377. */
  26378. /**
  26379. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26380. */
  26381. visibility: number;
  26382. /** Gets or sets the alpha index used to sort transparent meshes
  26383. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26384. */
  26385. alphaIndex: number;
  26386. /**
  26387. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26388. */
  26389. isVisible: boolean;
  26390. /**
  26391. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26392. */
  26393. isPickable: boolean;
  26394. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26395. showSubMeshesBoundingBox: boolean;
  26396. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26397. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26398. */
  26399. isBlocker: boolean;
  26400. /**
  26401. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26402. */
  26403. enablePointerMoveEvents: boolean;
  26404. /**
  26405. * Specifies the rendering group id for this mesh (0 by default)
  26406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26407. */
  26408. renderingGroupId: number;
  26409. private _material;
  26410. /** Gets or sets current material */
  26411. material: Nullable<Material>;
  26412. /**
  26413. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26414. * @see http://doc.babylonjs.com/babylon101/shadows
  26415. */
  26416. receiveShadows: boolean;
  26417. /** Defines color to use when rendering outline */
  26418. outlineColor: Color3;
  26419. /** Define width to use when rendering outline */
  26420. outlineWidth: number;
  26421. /** Defines color to use when rendering overlay */
  26422. overlayColor: Color3;
  26423. /** Defines alpha to use when rendering overlay */
  26424. overlayAlpha: number;
  26425. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26426. hasVertexAlpha: boolean;
  26427. /** 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) */
  26428. useVertexColors: boolean;
  26429. /**
  26430. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26431. */
  26432. computeBonesUsingShaders: boolean;
  26433. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26434. numBoneInfluencers: number;
  26435. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26436. applyFog: boolean;
  26437. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26438. useOctreeForRenderingSelection: boolean;
  26439. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26440. useOctreeForPicking: boolean;
  26441. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26442. useOctreeForCollisions: boolean;
  26443. /**
  26444. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26445. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26446. */
  26447. layerMask: number;
  26448. /**
  26449. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26450. */
  26451. alwaysSelectAsActiveMesh: boolean;
  26452. /**
  26453. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26454. */
  26455. doNotSyncBoundingInfo: boolean;
  26456. /**
  26457. * Gets or sets the current action manager
  26458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26459. */
  26460. actionManager: Nullable<AbstractActionManager>;
  26461. private _meshCollisionData;
  26462. /**
  26463. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26464. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26465. */
  26466. ellipsoid: Vector3;
  26467. /**
  26468. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26470. */
  26471. ellipsoidOffset: Vector3;
  26472. /**
  26473. * Gets or sets a collision mask used to mask collisions (default is -1).
  26474. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26475. */
  26476. collisionMask: number;
  26477. /**
  26478. * Gets or sets the current collision group mask (-1 by default).
  26479. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26480. */
  26481. collisionGroup: number;
  26482. /**
  26483. * Defines edge width used when edgesRenderer is enabled
  26484. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26485. */
  26486. edgesWidth: number;
  26487. /**
  26488. * Defines edge color used when edgesRenderer is enabled
  26489. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26490. */
  26491. edgesColor: Color4;
  26492. /** @hidden */
  26493. _edgesRenderer: Nullable<IEdgesRenderer>;
  26494. /** @hidden */
  26495. _masterMesh: Nullable<AbstractMesh>;
  26496. /** @hidden */
  26497. _boundingInfo: Nullable<BoundingInfo>;
  26498. /** @hidden */
  26499. _renderId: number;
  26500. /**
  26501. * Gets or sets the list of subMeshes
  26502. * @see http://doc.babylonjs.com/how_to/multi_materials
  26503. */
  26504. subMeshes: SubMesh[];
  26505. /** @hidden */
  26506. _intersectionsInProgress: AbstractMesh[];
  26507. /** @hidden */
  26508. _unIndexed: boolean;
  26509. /** @hidden */
  26510. _lightSources: Light[];
  26511. /** Gets the list of lights affecting that mesh */
  26512. readonly lightSources: Light[];
  26513. /** @hidden */
  26514. readonly _positions: Nullable<Vector3[]>;
  26515. /** @hidden */
  26516. _waitingData: {
  26517. lods: Nullable<any>;
  26518. actions: Nullable<any>;
  26519. freezeWorldMatrix: Nullable<boolean>;
  26520. };
  26521. /** @hidden */
  26522. _bonesTransformMatrices: Nullable<Float32Array>;
  26523. /** @hidden */
  26524. _transformMatrixTexture: Nullable<RawTexture>;
  26525. /**
  26526. * Gets or sets a skeleton to apply skining transformations
  26527. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26528. */
  26529. skeleton: Nullable<Skeleton>;
  26530. /**
  26531. * An event triggered when the mesh is rebuilt.
  26532. */
  26533. onRebuildObservable: Observable<AbstractMesh>;
  26534. /**
  26535. * Creates a new AbstractMesh
  26536. * @param name defines the name of the mesh
  26537. * @param scene defines the hosting scene
  26538. */
  26539. constructor(name: string, scene?: Nullable<Scene>);
  26540. /**
  26541. * Returns the string "AbstractMesh"
  26542. * @returns "AbstractMesh"
  26543. */
  26544. getClassName(): string;
  26545. /**
  26546. * Gets a string representation of the current mesh
  26547. * @param fullDetails defines a boolean indicating if full details must be included
  26548. * @returns a string representation of the current mesh
  26549. */
  26550. toString(fullDetails?: boolean): string;
  26551. /**
  26552. * @hidden
  26553. */
  26554. protected _getEffectiveParent(): Nullable<Node>;
  26555. /** @hidden */
  26556. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26557. /** @hidden */
  26558. _rebuild(): void;
  26559. /** @hidden */
  26560. _resyncLightSources(): void;
  26561. /** @hidden */
  26562. _resyncLighSource(light: Light): void;
  26563. /** @hidden */
  26564. _unBindEffect(): void;
  26565. /** @hidden */
  26566. _removeLightSource(light: Light): void;
  26567. private _markSubMeshesAsDirty;
  26568. /** @hidden */
  26569. _markSubMeshesAsLightDirty(): void;
  26570. /** @hidden */
  26571. _markSubMeshesAsAttributesDirty(): void;
  26572. /** @hidden */
  26573. _markSubMeshesAsMiscDirty(): void;
  26574. /**
  26575. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26576. */
  26577. scaling: Vector3;
  26578. /**
  26579. * Returns true if the mesh is blocked. Implemented by child classes
  26580. */
  26581. readonly isBlocked: boolean;
  26582. /**
  26583. * Returns the mesh itself by default. Implemented by child classes
  26584. * @param camera defines the camera to use to pick the right LOD level
  26585. * @returns the currentAbstractMesh
  26586. */
  26587. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26588. /**
  26589. * Returns 0 by default. Implemented by child classes
  26590. * @returns an integer
  26591. */
  26592. getTotalVertices(): number;
  26593. /**
  26594. * Returns a positive integer : the total number of indices in this mesh geometry.
  26595. * @returns the numner of indices or zero if the mesh has no geometry.
  26596. */
  26597. getTotalIndices(): number;
  26598. /**
  26599. * Returns null by default. Implemented by child classes
  26600. * @returns null
  26601. */
  26602. getIndices(): Nullable<IndicesArray>;
  26603. /**
  26604. * Returns the array of the requested vertex data kind. Implemented by child classes
  26605. * @param kind defines the vertex data kind to use
  26606. * @returns null
  26607. */
  26608. getVerticesData(kind: string): Nullable<FloatArray>;
  26609. /**
  26610. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26611. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26612. * Note that a new underlying VertexBuffer object is created each call.
  26613. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26614. * @param kind defines vertex data kind:
  26615. * * VertexBuffer.PositionKind
  26616. * * VertexBuffer.UVKind
  26617. * * VertexBuffer.UV2Kind
  26618. * * VertexBuffer.UV3Kind
  26619. * * VertexBuffer.UV4Kind
  26620. * * VertexBuffer.UV5Kind
  26621. * * VertexBuffer.UV6Kind
  26622. * * VertexBuffer.ColorKind
  26623. * * VertexBuffer.MatricesIndicesKind
  26624. * * VertexBuffer.MatricesIndicesExtraKind
  26625. * * VertexBuffer.MatricesWeightsKind
  26626. * * VertexBuffer.MatricesWeightsExtraKind
  26627. * @param data defines the data source
  26628. * @param updatable defines if the data must be flagged as updatable (or static)
  26629. * @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
  26630. * @returns the current mesh
  26631. */
  26632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26633. /**
  26634. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26635. * If the mesh has no geometry, it is simply returned as it is.
  26636. * @param kind defines vertex data kind:
  26637. * * VertexBuffer.PositionKind
  26638. * * VertexBuffer.UVKind
  26639. * * VertexBuffer.UV2Kind
  26640. * * VertexBuffer.UV3Kind
  26641. * * VertexBuffer.UV4Kind
  26642. * * VertexBuffer.UV5Kind
  26643. * * VertexBuffer.UV6Kind
  26644. * * VertexBuffer.ColorKind
  26645. * * VertexBuffer.MatricesIndicesKind
  26646. * * VertexBuffer.MatricesIndicesExtraKind
  26647. * * VertexBuffer.MatricesWeightsKind
  26648. * * VertexBuffer.MatricesWeightsExtraKind
  26649. * @param data defines the data source
  26650. * @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
  26651. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26652. * @returns the current mesh
  26653. */
  26654. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26655. /**
  26656. * Sets the mesh indices,
  26657. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26658. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26659. * @param totalVertices Defines the total number of vertices
  26660. * @returns the current mesh
  26661. */
  26662. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26663. /**
  26664. * Gets a boolean indicating if specific vertex data is present
  26665. * @param kind defines the vertex data kind to use
  26666. * @returns true is data kind is present
  26667. */
  26668. isVerticesDataPresent(kind: string): boolean;
  26669. /**
  26670. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26671. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26672. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26673. * @returns a BoundingInfo
  26674. */
  26675. getBoundingInfo(): BoundingInfo;
  26676. /**
  26677. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26678. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26679. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26680. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26681. * @returns the current mesh
  26682. */
  26683. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26684. /**
  26685. * Overwrite the current bounding info
  26686. * @param boundingInfo defines the new bounding info
  26687. * @returns the current mesh
  26688. */
  26689. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26690. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26691. readonly useBones: boolean;
  26692. /** @hidden */
  26693. _preActivate(): void;
  26694. /** @hidden */
  26695. _preActivateForIntermediateRendering(renderId: number): void;
  26696. /** @hidden */
  26697. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26698. /** @hidden */
  26699. _postActivate(): void;
  26700. /** @hidden */
  26701. _freeze(): void;
  26702. /** @hidden */
  26703. _unFreeze(): void;
  26704. /**
  26705. * Gets the current world matrix
  26706. * @returns a Matrix
  26707. */
  26708. getWorldMatrix(): Matrix;
  26709. /** @hidden */
  26710. _getWorldMatrixDeterminant(): number;
  26711. /**
  26712. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26713. */
  26714. readonly isAnInstance: boolean;
  26715. /**
  26716. * Perform relative position change from the point of view of behind the front of the mesh.
  26717. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26718. * Supports definition of mesh facing forward or backward
  26719. * @param amountRight defines the distance on the right axis
  26720. * @param amountUp defines the distance on the up axis
  26721. * @param amountForward defines the distance on the forward axis
  26722. * @returns the current mesh
  26723. */
  26724. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26725. /**
  26726. * Calculate relative position change from the point of view of behind the front of the mesh.
  26727. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26728. * Supports definition of mesh facing forward or backward
  26729. * @param amountRight defines the distance on the right axis
  26730. * @param amountUp defines the distance on the up axis
  26731. * @param amountForward defines the distance on the forward axis
  26732. * @returns the new displacement vector
  26733. */
  26734. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26735. /**
  26736. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26737. * Supports definition of mesh facing forward or backward
  26738. * @param flipBack defines the flip
  26739. * @param twirlClockwise defines the twirl
  26740. * @param tiltRight defines the tilt
  26741. * @returns the current mesh
  26742. */
  26743. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26744. /**
  26745. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26746. * Supports definition of mesh facing forward or backward.
  26747. * @param flipBack defines the flip
  26748. * @param twirlClockwise defines the twirl
  26749. * @param tiltRight defines the tilt
  26750. * @returns the new rotation vector
  26751. */
  26752. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26753. /**
  26754. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26755. * This means the mesh underlying bounding box and sphere are recomputed.
  26756. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26757. * @returns the current mesh
  26758. */
  26759. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26760. /** @hidden */
  26761. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26762. /** @hidden */
  26763. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26764. /** @hidden */
  26765. _updateBoundingInfo(): AbstractMesh;
  26766. /** @hidden */
  26767. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26768. /** @hidden */
  26769. protected _afterComputeWorldMatrix(): void;
  26770. /** @hidden */
  26771. readonly _effectiveMesh: AbstractMesh;
  26772. /**
  26773. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26774. * A mesh is in the frustum if its bounding box intersects the frustum
  26775. * @param frustumPlanes defines the frustum to test
  26776. * @returns true if the mesh is in the frustum planes
  26777. */
  26778. isInFrustum(frustumPlanes: Plane[]): boolean;
  26779. /**
  26780. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26781. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26782. * @param frustumPlanes defines the frustum to test
  26783. * @returns true if the mesh is completely in the frustum planes
  26784. */
  26785. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26786. /**
  26787. * True if the mesh intersects another mesh or a SolidParticle object
  26788. * @param mesh defines a target mesh or SolidParticle to test
  26789. * @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)
  26790. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26791. * @returns true if there is an intersection
  26792. */
  26793. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26794. /**
  26795. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26796. * @param point defines the point to test
  26797. * @returns true if there is an intersection
  26798. */
  26799. intersectsPoint(point: Vector3): boolean;
  26800. /**
  26801. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26803. */
  26804. checkCollisions: boolean;
  26805. /**
  26806. * Gets Collider object used to compute collisions (not physics)
  26807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26808. */
  26809. readonly collider: Nullable<Collider>;
  26810. /**
  26811. * Move the mesh using collision engine
  26812. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26813. * @param displacement defines the requested displacement vector
  26814. * @returns the current mesh
  26815. */
  26816. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26817. private _onCollisionPositionChange;
  26818. /** @hidden */
  26819. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26820. /** @hidden */
  26821. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26822. /** @hidden */
  26823. _checkCollision(collider: Collider): AbstractMesh;
  26824. /** @hidden */
  26825. _generatePointsArray(): boolean;
  26826. /**
  26827. * Checks if the passed Ray intersects with the mesh
  26828. * @param ray defines the ray to use
  26829. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26830. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26831. * @returns the picking info
  26832. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26833. */
  26834. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26835. /**
  26836. * Clones the current mesh
  26837. * @param name defines the mesh name
  26838. * @param newParent defines the new mesh parent
  26839. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26840. * @returns the new mesh
  26841. */
  26842. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26843. /**
  26844. * Disposes all the submeshes of the current meshnp
  26845. * @returns the current mesh
  26846. */
  26847. releaseSubMeshes(): AbstractMesh;
  26848. /**
  26849. * Releases resources associated with this abstract mesh.
  26850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26852. */
  26853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26854. /**
  26855. * Adds the passed mesh as a child to the current mesh
  26856. * @param mesh defines the child mesh
  26857. * @returns the current mesh
  26858. */
  26859. addChild(mesh: AbstractMesh): AbstractMesh;
  26860. /**
  26861. * Removes the passed mesh from the current mesh children list
  26862. * @param mesh defines the child mesh
  26863. * @returns the current mesh
  26864. */
  26865. removeChild(mesh: AbstractMesh): AbstractMesh;
  26866. /** @hidden */
  26867. private _initFacetData;
  26868. /**
  26869. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26870. * This method can be called within the render loop.
  26871. * 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
  26872. * @returns the current mesh
  26873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26874. */
  26875. updateFacetData(): AbstractMesh;
  26876. /**
  26877. * Returns the facetLocalNormals array.
  26878. * The normals are expressed in the mesh local spac
  26879. * @returns an array of Vector3
  26880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26881. */
  26882. getFacetLocalNormals(): Vector3[];
  26883. /**
  26884. * Returns the facetLocalPositions array.
  26885. * The facet positions are expressed in the mesh local space
  26886. * @returns an array of Vector3
  26887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26888. */
  26889. getFacetLocalPositions(): Vector3[];
  26890. /**
  26891. * Returns the facetLocalPartioning array
  26892. * @returns an array of array of numbers
  26893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26894. */
  26895. getFacetLocalPartitioning(): number[][];
  26896. /**
  26897. * Returns the i-th facet position in the world system.
  26898. * This method allocates a new Vector3 per call
  26899. * @param i defines the facet index
  26900. * @returns a new Vector3
  26901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26902. */
  26903. getFacetPosition(i: number): Vector3;
  26904. /**
  26905. * Sets the reference Vector3 with the i-th facet position in the world system
  26906. * @param i defines the facet index
  26907. * @param ref defines the target vector
  26908. * @returns the current mesh
  26909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26910. */
  26911. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26912. /**
  26913. * Returns the i-th facet normal in the world system.
  26914. * This method allocates a new Vector3 per call
  26915. * @param i defines the facet index
  26916. * @returns a new Vector3
  26917. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26918. */
  26919. getFacetNormal(i: number): Vector3;
  26920. /**
  26921. * Sets the reference Vector3 with the i-th facet normal in the world system
  26922. * @param i defines the facet index
  26923. * @param ref defines the target vector
  26924. * @returns the current mesh
  26925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26926. */
  26927. getFacetNormalToRef(i: number, ref: Vector3): this;
  26928. /**
  26929. * 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)
  26930. * @param x defines x coordinate
  26931. * @param y defines y coordinate
  26932. * @param z defines z coordinate
  26933. * @returns the array of facet indexes
  26934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26935. */
  26936. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26937. /**
  26938. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26939. * @param projected sets as the (x,y,z) world projection on the facet
  26940. * @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
  26941. * @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
  26942. * @param x defines x coordinate
  26943. * @param y defines y coordinate
  26944. * @param z defines z coordinate
  26945. * @returns the face index if found (or null instead)
  26946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26947. */
  26948. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26949. /**
  26950. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26951. * @param projected sets as the (x,y,z) local projection on the facet
  26952. * @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
  26953. * @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
  26954. * @param x defines x coordinate
  26955. * @param y defines y coordinate
  26956. * @param z defines z coordinate
  26957. * @returns the face index if found (or null instead)
  26958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26959. */
  26960. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26961. /**
  26962. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26963. * @returns the parameters
  26964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26965. */
  26966. getFacetDataParameters(): any;
  26967. /**
  26968. * Disables the feature FacetData and frees the related memory
  26969. * @returns the current mesh
  26970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26971. */
  26972. disableFacetData(): AbstractMesh;
  26973. /**
  26974. * Updates the AbstractMesh indices array
  26975. * @param indices defines the data source
  26976. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26977. * @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)
  26978. * @returns the current mesh
  26979. */
  26980. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26981. /**
  26982. * Creates new normals data for the mesh
  26983. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26984. * @returns the current mesh
  26985. */
  26986. createNormals(updatable: boolean): AbstractMesh;
  26987. /**
  26988. * Align the mesh with a normal
  26989. * @param normal defines the normal to use
  26990. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26991. * @returns the current mesh
  26992. */
  26993. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26994. /** @hidden */
  26995. _checkOcclusionQuery(): boolean;
  26996. /**
  26997. * Disables the mesh edge rendering mode
  26998. * @returns the currentAbstractMesh
  26999. */
  27000. disableEdgesRendering(): AbstractMesh;
  27001. /**
  27002. * Enables the edge rendering mode on the mesh.
  27003. * This mode makes the mesh edges visible
  27004. * @param epsilon defines the maximal distance between two angles to detect a face
  27005. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27006. * @returns the currentAbstractMesh
  27007. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27008. */
  27009. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27010. }
  27011. }
  27012. declare module "babylonjs/Actions/actionEvent" {
  27013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27014. import { Nullable } from "babylonjs/types";
  27015. import { Sprite } from "babylonjs/Sprites/sprite";
  27016. import { Scene } from "babylonjs/scene";
  27017. import { Vector2 } from "babylonjs/Maths/math.vector";
  27018. /**
  27019. * Interface used to define ActionEvent
  27020. */
  27021. export interface IActionEvent {
  27022. /** The mesh or sprite that triggered the action */
  27023. source: any;
  27024. /** The X mouse cursor position at the time of the event */
  27025. pointerX: number;
  27026. /** The Y mouse cursor position at the time of the event */
  27027. pointerY: number;
  27028. /** The mesh that is currently pointed at (can be null) */
  27029. meshUnderPointer: Nullable<AbstractMesh>;
  27030. /** the original (browser) event that triggered the ActionEvent */
  27031. sourceEvent?: any;
  27032. /** additional data for the event */
  27033. additionalData?: any;
  27034. }
  27035. /**
  27036. * ActionEvent is the event being sent when an action is triggered.
  27037. */
  27038. export class ActionEvent implements IActionEvent {
  27039. /** The mesh or sprite that triggered the action */
  27040. source: any;
  27041. /** The X mouse cursor position at the time of the event */
  27042. pointerX: number;
  27043. /** The Y mouse cursor position at the time of the event */
  27044. pointerY: number;
  27045. /** The mesh that is currently pointed at (can be null) */
  27046. meshUnderPointer: Nullable<AbstractMesh>;
  27047. /** the original (browser) event that triggered the ActionEvent */
  27048. sourceEvent?: any;
  27049. /** additional data for the event */
  27050. additionalData?: any;
  27051. /**
  27052. * Creates a new ActionEvent
  27053. * @param source The mesh or sprite that triggered the action
  27054. * @param pointerX The X mouse cursor position at the time of the event
  27055. * @param pointerY The Y mouse cursor position at the time of the event
  27056. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27057. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27058. * @param additionalData additional data for the event
  27059. */
  27060. constructor(
  27061. /** The mesh or sprite that triggered the action */
  27062. source: any,
  27063. /** The X mouse cursor position at the time of the event */
  27064. pointerX: number,
  27065. /** The Y mouse cursor position at the time of the event */
  27066. pointerY: number,
  27067. /** The mesh that is currently pointed at (can be null) */
  27068. meshUnderPointer: Nullable<AbstractMesh>,
  27069. /** the original (browser) event that triggered the ActionEvent */
  27070. sourceEvent?: any,
  27071. /** additional data for the event */
  27072. additionalData?: any);
  27073. /**
  27074. * Helper function to auto-create an ActionEvent from a source mesh.
  27075. * @param source The source mesh that triggered the event
  27076. * @param evt The original (browser) event
  27077. * @param additionalData additional data for the event
  27078. * @returns the new ActionEvent
  27079. */
  27080. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27081. /**
  27082. * Helper function to auto-create an ActionEvent from a source sprite
  27083. * @param source The source sprite that triggered the event
  27084. * @param scene Scene associated with the sprite
  27085. * @param evt The original (browser) event
  27086. * @param additionalData additional data for the event
  27087. * @returns the new ActionEvent
  27088. */
  27089. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27090. /**
  27091. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27092. * @param scene the scene where the event occurred
  27093. * @param evt The original (browser) event
  27094. * @returns the new ActionEvent
  27095. */
  27096. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27097. /**
  27098. * Helper function to auto-create an ActionEvent from a primitive
  27099. * @param prim defines the target primitive
  27100. * @param pointerPos defines the pointer position
  27101. * @param evt The original (browser) event
  27102. * @param additionalData additional data for the event
  27103. * @returns the new ActionEvent
  27104. */
  27105. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27106. }
  27107. }
  27108. declare module "babylonjs/Actions/abstractActionManager" {
  27109. import { IDisposable } from "babylonjs/scene";
  27110. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27111. import { IAction } from "babylonjs/Actions/action";
  27112. import { Nullable } from "babylonjs/types";
  27113. /**
  27114. * Abstract class used to decouple action Manager from scene and meshes.
  27115. * Do not instantiate.
  27116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27117. */
  27118. export abstract class AbstractActionManager implements IDisposable {
  27119. /** Gets the list of active triggers */
  27120. static Triggers: {
  27121. [key: string]: number;
  27122. };
  27123. /** Gets the cursor to use when hovering items */
  27124. hoverCursor: string;
  27125. /** Gets the list of actions */
  27126. actions: IAction[];
  27127. /**
  27128. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27129. */
  27130. isRecursive: boolean;
  27131. /**
  27132. * Releases all associated resources
  27133. */
  27134. abstract dispose(): void;
  27135. /**
  27136. * Does this action manager has pointer triggers
  27137. */
  27138. abstract readonly hasPointerTriggers: boolean;
  27139. /**
  27140. * Does this action manager has pick triggers
  27141. */
  27142. abstract readonly hasPickTriggers: boolean;
  27143. /**
  27144. * Process a specific trigger
  27145. * @param trigger defines the trigger to process
  27146. * @param evt defines the event details to be processed
  27147. */
  27148. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27149. /**
  27150. * Does this action manager handles actions of any of the given triggers
  27151. * @param triggers defines the triggers to be tested
  27152. * @return a boolean indicating whether one (or more) of the triggers is handled
  27153. */
  27154. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27155. /**
  27156. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27157. * speed.
  27158. * @param triggerA defines the trigger to be tested
  27159. * @param triggerB defines the trigger to be tested
  27160. * @return a boolean indicating whether one (or more) of the triggers is handled
  27161. */
  27162. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27163. /**
  27164. * Does this action manager handles actions of a given trigger
  27165. * @param trigger defines the trigger to be tested
  27166. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27167. * @return whether the trigger is handled
  27168. */
  27169. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27170. /**
  27171. * Serialize this manager to a JSON object
  27172. * @param name defines the property name to store this manager
  27173. * @returns a JSON representation of this manager
  27174. */
  27175. abstract serialize(name: string): any;
  27176. /**
  27177. * Registers an action to this action manager
  27178. * @param action defines the action to be registered
  27179. * @return the action amended (prepared) after registration
  27180. */
  27181. abstract registerAction(action: IAction): Nullable<IAction>;
  27182. /**
  27183. * Unregisters an action to this action manager
  27184. * @param action defines the action to be unregistered
  27185. * @return a boolean indicating whether the action has been unregistered
  27186. */
  27187. abstract unregisterAction(action: IAction): Boolean;
  27188. /**
  27189. * Does exist one action manager with at least one trigger
  27190. **/
  27191. static readonly HasTriggers: boolean;
  27192. /**
  27193. * Does exist one action manager with at least one pick trigger
  27194. **/
  27195. static readonly HasPickTriggers: boolean;
  27196. /**
  27197. * Does exist one action manager that handles actions of a given trigger
  27198. * @param trigger defines the trigger to be tested
  27199. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27200. **/
  27201. static HasSpecificTrigger(trigger: number): boolean;
  27202. }
  27203. }
  27204. declare module "babylonjs/node" {
  27205. import { Scene } from "babylonjs/scene";
  27206. import { Nullable } from "babylonjs/types";
  27207. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27208. import { Engine } from "babylonjs/Engines/engine";
  27209. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27210. import { Observable } from "babylonjs/Misc/observable";
  27211. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27212. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27213. import { Animatable } from "babylonjs/Animations/animatable";
  27214. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27215. import { Animation } from "babylonjs/Animations/animation";
  27216. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27218. /**
  27219. * Defines how a node can be built from a string name.
  27220. */
  27221. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27222. /**
  27223. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27224. */
  27225. export class Node implements IBehaviorAware<Node> {
  27226. /** @hidden */
  27227. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27228. private static _NodeConstructors;
  27229. /**
  27230. * Add a new node constructor
  27231. * @param type defines the type name of the node to construct
  27232. * @param constructorFunc defines the constructor function
  27233. */
  27234. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27235. /**
  27236. * Returns a node constructor based on type name
  27237. * @param type defines the type name
  27238. * @param name defines the new node name
  27239. * @param scene defines the hosting scene
  27240. * @param options defines optional options to transmit to constructors
  27241. * @returns the new constructor or null
  27242. */
  27243. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27244. /**
  27245. * Gets or sets the name of the node
  27246. */
  27247. name: string;
  27248. /**
  27249. * Gets or sets the id of the node
  27250. */
  27251. id: string;
  27252. /**
  27253. * Gets or sets the unique id of the node
  27254. */
  27255. uniqueId: number;
  27256. /**
  27257. * Gets or sets a string used to store user defined state for the node
  27258. */
  27259. state: string;
  27260. /**
  27261. * Gets or sets an object used to store user defined information for the node
  27262. */
  27263. metadata: any;
  27264. /**
  27265. * For internal use only. Please do not use.
  27266. */
  27267. reservedDataStore: any;
  27268. /**
  27269. * List of inspectable custom properties (used by the Inspector)
  27270. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27271. */
  27272. inspectableCustomProperties: IInspectable[];
  27273. /**
  27274. * Gets or sets a boolean used to define if the node must be serialized
  27275. */
  27276. doNotSerialize: boolean;
  27277. /** @hidden */
  27278. _isDisposed: boolean;
  27279. /**
  27280. * Gets a list of Animations associated with the node
  27281. */
  27282. animations: import("babylonjs/Animations/animation").Animation[];
  27283. protected _ranges: {
  27284. [name: string]: Nullable<AnimationRange>;
  27285. };
  27286. /**
  27287. * Callback raised when the node is ready to be used
  27288. */
  27289. onReady: Nullable<(node: Node) => void>;
  27290. private _isEnabled;
  27291. private _isParentEnabled;
  27292. private _isReady;
  27293. /** @hidden */
  27294. _currentRenderId: number;
  27295. private _parentUpdateId;
  27296. /** @hidden */
  27297. _childUpdateId: number;
  27298. /** @hidden */
  27299. _waitingParentId: Nullable<string>;
  27300. /** @hidden */
  27301. _scene: Scene;
  27302. /** @hidden */
  27303. _cache: any;
  27304. private _parentNode;
  27305. private _children;
  27306. /** @hidden */
  27307. _worldMatrix: Matrix;
  27308. /** @hidden */
  27309. _worldMatrixDeterminant: number;
  27310. /** @hidden */
  27311. _worldMatrixDeterminantIsDirty: boolean;
  27312. /** @hidden */
  27313. private _sceneRootNodesIndex;
  27314. /**
  27315. * Gets a boolean indicating if the node has been disposed
  27316. * @returns true if the node was disposed
  27317. */
  27318. isDisposed(): boolean;
  27319. /**
  27320. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27321. * @see https://doc.babylonjs.com/how_to/parenting
  27322. */
  27323. parent: Nullable<Node>;
  27324. private addToSceneRootNodes;
  27325. private removeFromSceneRootNodes;
  27326. private _animationPropertiesOverride;
  27327. /**
  27328. * Gets or sets the animation properties override
  27329. */
  27330. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27331. /**
  27332. * Gets a string idenfifying the name of the class
  27333. * @returns "Node" string
  27334. */
  27335. getClassName(): string;
  27336. /** @hidden */
  27337. readonly _isNode: boolean;
  27338. /**
  27339. * An event triggered when the mesh is disposed
  27340. */
  27341. onDisposeObservable: Observable<Node>;
  27342. private _onDisposeObserver;
  27343. /**
  27344. * Sets a callback that will be raised when the node will be disposed
  27345. */
  27346. onDispose: () => void;
  27347. /**
  27348. * Creates a new Node
  27349. * @param name the name and id to be given to this node
  27350. * @param scene the scene this node will be added to
  27351. * @param addToRootNodes the node will be added to scene.rootNodes
  27352. */
  27353. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27354. /**
  27355. * Gets the scene of the node
  27356. * @returns a scene
  27357. */
  27358. getScene(): Scene;
  27359. /**
  27360. * Gets the engine of the node
  27361. * @returns a Engine
  27362. */
  27363. getEngine(): Engine;
  27364. private _behaviors;
  27365. /**
  27366. * Attach a behavior to the node
  27367. * @see http://doc.babylonjs.com/features/behaviour
  27368. * @param behavior defines the behavior to attach
  27369. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27370. * @returns the current Node
  27371. */
  27372. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27373. /**
  27374. * Remove an attached behavior
  27375. * @see http://doc.babylonjs.com/features/behaviour
  27376. * @param behavior defines the behavior to attach
  27377. * @returns the current Node
  27378. */
  27379. removeBehavior(behavior: Behavior<Node>): Node;
  27380. /**
  27381. * Gets the list of attached behaviors
  27382. * @see http://doc.babylonjs.com/features/behaviour
  27383. */
  27384. readonly behaviors: Behavior<Node>[];
  27385. /**
  27386. * Gets an attached behavior by name
  27387. * @param name defines the name of the behavior to look for
  27388. * @see http://doc.babylonjs.com/features/behaviour
  27389. * @returns null if behavior was not found else the requested behavior
  27390. */
  27391. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27392. /**
  27393. * Returns the latest update of the World matrix
  27394. * @returns a Matrix
  27395. */
  27396. getWorldMatrix(): Matrix;
  27397. /** @hidden */
  27398. _getWorldMatrixDeterminant(): number;
  27399. /**
  27400. * Returns directly the latest state of the mesh World matrix.
  27401. * A Matrix is returned.
  27402. */
  27403. readonly worldMatrixFromCache: Matrix;
  27404. /** @hidden */
  27405. _initCache(): void;
  27406. /** @hidden */
  27407. updateCache(force?: boolean): void;
  27408. /** @hidden */
  27409. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27410. /** @hidden */
  27411. _updateCache(ignoreParentClass?: boolean): void;
  27412. /** @hidden */
  27413. _isSynchronized(): boolean;
  27414. /** @hidden */
  27415. _markSyncedWithParent(): void;
  27416. /** @hidden */
  27417. isSynchronizedWithParent(): boolean;
  27418. /** @hidden */
  27419. isSynchronized(): boolean;
  27420. /**
  27421. * Is this node ready to be used/rendered
  27422. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27423. * @return true if the node is ready
  27424. */
  27425. isReady(completeCheck?: boolean): boolean;
  27426. /**
  27427. * Is this node enabled?
  27428. * 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
  27429. * @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
  27430. * @return whether this node (and its parent) is enabled
  27431. */
  27432. isEnabled(checkAncestors?: boolean): boolean;
  27433. /** @hidden */
  27434. protected _syncParentEnabledState(): void;
  27435. /**
  27436. * Set the enabled state of this node
  27437. * @param value defines the new enabled state
  27438. */
  27439. setEnabled(value: boolean): void;
  27440. /**
  27441. * Is this node a descendant of the given node?
  27442. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27443. * @param ancestor defines the parent node to inspect
  27444. * @returns a boolean indicating if this node is a descendant of the given node
  27445. */
  27446. isDescendantOf(ancestor: Node): boolean;
  27447. /** @hidden */
  27448. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27449. /**
  27450. * Will return all nodes that have this node as ascendant
  27451. * @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
  27452. * @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
  27453. * @return all children nodes of all types
  27454. */
  27455. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27456. /**
  27457. * Get all child-meshes of this node
  27458. * @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)
  27459. * @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
  27460. * @returns an array of AbstractMesh
  27461. */
  27462. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27463. /**
  27464. * Get all direct children of this node
  27465. * @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
  27466. * @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)
  27467. * @returns an array of Node
  27468. */
  27469. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27470. /** @hidden */
  27471. _setReady(state: boolean): void;
  27472. /**
  27473. * Get an animation by name
  27474. * @param name defines the name of the animation to look for
  27475. * @returns null if not found else the requested animation
  27476. */
  27477. getAnimationByName(name: string): Nullable<Animation>;
  27478. /**
  27479. * Creates an animation range for this node
  27480. * @param name defines the name of the range
  27481. * @param from defines the starting key
  27482. * @param to defines the end key
  27483. */
  27484. createAnimationRange(name: string, from: number, to: number): void;
  27485. /**
  27486. * Delete a specific animation range
  27487. * @param name defines the name of the range to delete
  27488. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27489. */
  27490. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27491. /**
  27492. * Get an animation range by name
  27493. * @param name defines the name of the animation range to look for
  27494. * @returns null if not found else the requested animation range
  27495. */
  27496. getAnimationRange(name: string): Nullable<AnimationRange>;
  27497. /**
  27498. * Gets the list of all animation ranges defined on this node
  27499. * @returns an array
  27500. */
  27501. getAnimationRanges(): Nullable<AnimationRange>[];
  27502. /**
  27503. * Will start the animation sequence
  27504. * @param name defines the range frames for animation sequence
  27505. * @param loop defines if the animation should loop (false by default)
  27506. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27507. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27508. * @returns the object created for this animation. If range does not exist, it will return null
  27509. */
  27510. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27511. /**
  27512. * Serialize animation ranges into a JSON compatible object
  27513. * @returns serialization object
  27514. */
  27515. serializeAnimationRanges(): any;
  27516. /**
  27517. * Computes the world matrix of the node
  27518. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27519. * @returns the world matrix
  27520. */
  27521. computeWorldMatrix(force?: boolean): Matrix;
  27522. /**
  27523. * Releases resources associated with this node.
  27524. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27525. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27526. */
  27527. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27528. /**
  27529. * Parse animation range data from a serialization object and store them into a given node
  27530. * @param node defines where to store the animation ranges
  27531. * @param parsedNode defines the serialization object to read data from
  27532. * @param scene defines the hosting scene
  27533. */
  27534. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27535. /**
  27536. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27537. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27538. * @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
  27539. * @returns the new bounding vectors
  27540. */
  27541. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27542. min: Vector3;
  27543. max: Vector3;
  27544. };
  27545. }
  27546. }
  27547. declare module "babylonjs/Animations/animation" {
  27548. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27549. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27550. import { Color3 } from "babylonjs/Maths/math.color";
  27551. import { Nullable } from "babylonjs/types";
  27552. import { Scene } from "babylonjs/scene";
  27553. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27554. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27555. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27556. import { Node } from "babylonjs/node";
  27557. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27558. import { Size } from "babylonjs/Maths/math.size";
  27559. import { Animatable } from "babylonjs/Animations/animatable";
  27560. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27561. /**
  27562. * @hidden
  27563. */
  27564. export class _IAnimationState {
  27565. key: number;
  27566. repeatCount: number;
  27567. workValue?: any;
  27568. loopMode?: number;
  27569. offsetValue?: any;
  27570. highLimitValue?: any;
  27571. }
  27572. /**
  27573. * Class used to store any kind of animation
  27574. */
  27575. export class Animation {
  27576. /**Name of the animation */
  27577. name: string;
  27578. /**Property to animate */
  27579. targetProperty: string;
  27580. /**The frames per second of the animation */
  27581. framePerSecond: number;
  27582. /**The data type of the animation */
  27583. dataType: number;
  27584. /**The loop mode of the animation */
  27585. loopMode?: number | undefined;
  27586. /**Specifies if blending should be enabled */
  27587. enableBlending?: boolean | undefined;
  27588. /**
  27589. * Use matrix interpolation instead of using direct key value when animating matrices
  27590. */
  27591. static AllowMatricesInterpolation: boolean;
  27592. /**
  27593. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27594. */
  27595. static AllowMatrixDecomposeForInterpolation: boolean;
  27596. /**
  27597. * Stores the key frames of the animation
  27598. */
  27599. private _keys;
  27600. /**
  27601. * Stores the easing function of the animation
  27602. */
  27603. private _easingFunction;
  27604. /**
  27605. * @hidden Internal use only
  27606. */
  27607. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27608. /**
  27609. * The set of event that will be linked to this animation
  27610. */
  27611. private _events;
  27612. /**
  27613. * Stores an array of target property paths
  27614. */
  27615. targetPropertyPath: string[];
  27616. /**
  27617. * Stores the blending speed of the animation
  27618. */
  27619. blendingSpeed: number;
  27620. /**
  27621. * Stores the animation ranges for the animation
  27622. */
  27623. private _ranges;
  27624. /**
  27625. * @hidden Internal use
  27626. */
  27627. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27628. /**
  27629. * Sets up an animation
  27630. * @param property The property to animate
  27631. * @param animationType The animation type to apply
  27632. * @param framePerSecond The frames per second of the animation
  27633. * @param easingFunction The easing function used in the animation
  27634. * @returns The created animation
  27635. */
  27636. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27637. /**
  27638. * Create and start an animation on a node
  27639. * @param name defines the name of the global animation that will be run on all nodes
  27640. * @param node defines the root node where the animation will take place
  27641. * @param targetProperty defines property to animate
  27642. * @param framePerSecond defines the number of frame per second yo use
  27643. * @param totalFrame defines the number of frames in total
  27644. * @param from defines the initial value
  27645. * @param to defines the final value
  27646. * @param loopMode defines which loop mode you want to use (off by default)
  27647. * @param easingFunction defines the easing function to use (linear by default)
  27648. * @param onAnimationEnd defines the callback to call when animation end
  27649. * @returns the animatable created for this animation
  27650. */
  27651. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27652. /**
  27653. * Create and start an animation on a node and its descendants
  27654. * @param name defines the name of the global animation that will be run on all nodes
  27655. * @param node defines the root node where the animation will take place
  27656. * @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
  27657. * @param targetProperty defines property to animate
  27658. * @param framePerSecond defines the number of frame per second to use
  27659. * @param totalFrame defines the number of frames in total
  27660. * @param from defines the initial value
  27661. * @param to defines the final value
  27662. * @param loopMode defines which loop mode you want to use (off by default)
  27663. * @param easingFunction defines the easing function to use (linear by default)
  27664. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27665. * @returns the list of animatables created for all nodes
  27666. * @example https://www.babylonjs-playground.com/#MH0VLI
  27667. */
  27668. 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[]>;
  27669. /**
  27670. * Creates a new animation, merges it with the existing animations and starts it
  27671. * @param name Name of the animation
  27672. * @param node Node which contains the scene that begins the animations
  27673. * @param targetProperty Specifies which property to animate
  27674. * @param framePerSecond The frames per second of the animation
  27675. * @param totalFrame The total number of frames
  27676. * @param from The frame at the beginning of the animation
  27677. * @param to The frame at the end of the animation
  27678. * @param loopMode Specifies the loop mode of the animation
  27679. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27680. * @param onAnimationEnd Callback to run once the animation is complete
  27681. * @returns Nullable animation
  27682. */
  27683. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27684. /**
  27685. * Transition property of an host to the target Value
  27686. * @param property The property to transition
  27687. * @param targetValue The target Value of the property
  27688. * @param host The object where the property to animate belongs
  27689. * @param scene Scene used to run the animation
  27690. * @param frameRate Framerate (in frame/s) to use
  27691. * @param transition The transition type we want to use
  27692. * @param duration The duration of the animation, in milliseconds
  27693. * @param onAnimationEnd Callback trigger at the end of the animation
  27694. * @returns Nullable animation
  27695. */
  27696. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27697. /**
  27698. * Return the array of runtime animations currently using this animation
  27699. */
  27700. readonly runtimeAnimations: RuntimeAnimation[];
  27701. /**
  27702. * Specifies if any of the runtime animations are currently running
  27703. */
  27704. readonly hasRunningRuntimeAnimations: boolean;
  27705. /**
  27706. * Initializes the animation
  27707. * @param name Name of the animation
  27708. * @param targetProperty Property to animate
  27709. * @param framePerSecond The frames per second of the animation
  27710. * @param dataType The data type of the animation
  27711. * @param loopMode The loop mode of the animation
  27712. * @param enableBlending Specifies if blending should be enabled
  27713. */
  27714. constructor(
  27715. /**Name of the animation */
  27716. name: string,
  27717. /**Property to animate */
  27718. targetProperty: string,
  27719. /**The frames per second of the animation */
  27720. framePerSecond: number,
  27721. /**The data type of the animation */
  27722. dataType: number,
  27723. /**The loop mode of the animation */
  27724. loopMode?: number | undefined,
  27725. /**Specifies if blending should be enabled */
  27726. enableBlending?: boolean | undefined);
  27727. /**
  27728. * Converts the animation to a string
  27729. * @param fullDetails support for multiple levels of logging within scene loading
  27730. * @returns String form of the animation
  27731. */
  27732. toString(fullDetails?: boolean): string;
  27733. /**
  27734. * Add an event to this animation
  27735. * @param event Event to add
  27736. */
  27737. addEvent(event: AnimationEvent): void;
  27738. /**
  27739. * Remove all events found at the given frame
  27740. * @param frame The frame to remove events from
  27741. */
  27742. removeEvents(frame: number): void;
  27743. /**
  27744. * Retrieves all the events from the animation
  27745. * @returns Events from the animation
  27746. */
  27747. getEvents(): AnimationEvent[];
  27748. /**
  27749. * Creates an animation range
  27750. * @param name Name of the animation range
  27751. * @param from Starting frame of the animation range
  27752. * @param to Ending frame of the animation
  27753. */
  27754. createRange(name: string, from: number, to: number): void;
  27755. /**
  27756. * Deletes an animation range by name
  27757. * @param name Name of the animation range to delete
  27758. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27759. */
  27760. deleteRange(name: string, deleteFrames?: boolean): void;
  27761. /**
  27762. * Gets the animation range by name, or null if not defined
  27763. * @param name Name of the animation range
  27764. * @returns Nullable animation range
  27765. */
  27766. getRange(name: string): Nullable<AnimationRange>;
  27767. /**
  27768. * Gets the key frames from the animation
  27769. * @returns The key frames of the animation
  27770. */
  27771. getKeys(): Array<IAnimationKey>;
  27772. /**
  27773. * Gets the highest frame rate of the animation
  27774. * @returns Highest frame rate of the animation
  27775. */
  27776. getHighestFrame(): number;
  27777. /**
  27778. * Gets the easing function of the animation
  27779. * @returns Easing function of the animation
  27780. */
  27781. getEasingFunction(): IEasingFunction;
  27782. /**
  27783. * Sets the easing function of the animation
  27784. * @param easingFunction A custom mathematical formula for animation
  27785. */
  27786. setEasingFunction(easingFunction: EasingFunction): void;
  27787. /**
  27788. * Interpolates a scalar linearly
  27789. * @param startValue Start value of the animation curve
  27790. * @param endValue End value of the animation curve
  27791. * @param gradient Scalar amount to interpolate
  27792. * @returns Interpolated scalar value
  27793. */
  27794. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27795. /**
  27796. * Interpolates a scalar cubically
  27797. * @param startValue Start value of the animation curve
  27798. * @param outTangent End tangent of the animation
  27799. * @param endValue End value of the animation curve
  27800. * @param inTangent Start tangent of the animation curve
  27801. * @param gradient Scalar amount to interpolate
  27802. * @returns Interpolated scalar value
  27803. */
  27804. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27805. /**
  27806. * Interpolates a quaternion using a spherical linear interpolation
  27807. * @param startValue Start value of the animation curve
  27808. * @param endValue End value of the animation curve
  27809. * @param gradient Scalar amount to interpolate
  27810. * @returns Interpolated quaternion value
  27811. */
  27812. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27813. /**
  27814. * Interpolates a quaternion cubically
  27815. * @param startValue Start value of the animation curve
  27816. * @param outTangent End tangent of the animation curve
  27817. * @param endValue End value of the animation curve
  27818. * @param inTangent Start tangent of the animation curve
  27819. * @param gradient Scalar amount to interpolate
  27820. * @returns Interpolated quaternion value
  27821. */
  27822. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27823. /**
  27824. * Interpolates a Vector3 linearl
  27825. * @param startValue Start value of the animation curve
  27826. * @param endValue End value of the animation curve
  27827. * @param gradient Scalar amount to interpolate
  27828. * @returns Interpolated scalar value
  27829. */
  27830. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27831. /**
  27832. * Interpolates a Vector3 cubically
  27833. * @param startValue Start value of the animation curve
  27834. * @param outTangent End tangent of the animation
  27835. * @param endValue End value of the animation curve
  27836. * @param inTangent Start tangent of the animation curve
  27837. * @param gradient Scalar amount to interpolate
  27838. * @returns InterpolatedVector3 value
  27839. */
  27840. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27841. /**
  27842. * Interpolates a Vector2 linearly
  27843. * @param startValue Start value of the animation curve
  27844. * @param endValue End value of the animation curve
  27845. * @param gradient Scalar amount to interpolate
  27846. * @returns Interpolated Vector2 value
  27847. */
  27848. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27849. /**
  27850. * Interpolates a Vector2 cubically
  27851. * @param startValue Start value of the animation curve
  27852. * @param outTangent End tangent of the animation
  27853. * @param endValue End value of the animation curve
  27854. * @param inTangent Start tangent of the animation curve
  27855. * @param gradient Scalar amount to interpolate
  27856. * @returns Interpolated Vector2 value
  27857. */
  27858. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27859. /**
  27860. * Interpolates a size linearly
  27861. * @param startValue Start value of the animation curve
  27862. * @param endValue End value of the animation curve
  27863. * @param gradient Scalar amount to interpolate
  27864. * @returns Interpolated Size value
  27865. */
  27866. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27867. /**
  27868. * Interpolates a Color3 linearly
  27869. * @param startValue Start value of the animation curve
  27870. * @param endValue End value of the animation curve
  27871. * @param gradient Scalar amount to interpolate
  27872. * @returns Interpolated Color3 value
  27873. */
  27874. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27875. /**
  27876. * @hidden Internal use only
  27877. */
  27878. _getKeyValue(value: any): any;
  27879. /**
  27880. * @hidden Internal use only
  27881. */
  27882. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27883. /**
  27884. * Defines the function to use to interpolate matrices
  27885. * @param startValue defines the start matrix
  27886. * @param endValue defines the end matrix
  27887. * @param gradient defines the gradient between both matrices
  27888. * @param result defines an optional target matrix where to store the interpolation
  27889. * @returns the interpolated matrix
  27890. */
  27891. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27892. /**
  27893. * Makes a copy of the animation
  27894. * @returns Cloned animation
  27895. */
  27896. clone(): Animation;
  27897. /**
  27898. * Sets the key frames of the animation
  27899. * @param values The animation key frames to set
  27900. */
  27901. setKeys(values: Array<IAnimationKey>): void;
  27902. /**
  27903. * Serializes the animation to an object
  27904. * @returns Serialized object
  27905. */
  27906. serialize(): any;
  27907. /**
  27908. * Float animation type
  27909. */
  27910. private static _ANIMATIONTYPE_FLOAT;
  27911. /**
  27912. * Vector3 animation type
  27913. */
  27914. private static _ANIMATIONTYPE_VECTOR3;
  27915. /**
  27916. * Quaternion animation type
  27917. */
  27918. private static _ANIMATIONTYPE_QUATERNION;
  27919. /**
  27920. * Matrix animation type
  27921. */
  27922. private static _ANIMATIONTYPE_MATRIX;
  27923. /**
  27924. * Color3 animation type
  27925. */
  27926. private static _ANIMATIONTYPE_COLOR3;
  27927. /**
  27928. * Vector2 animation type
  27929. */
  27930. private static _ANIMATIONTYPE_VECTOR2;
  27931. /**
  27932. * Size animation type
  27933. */
  27934. private static _ANIMATIONTYPE_SIZE;
  27935. /**
  27936. * Relative Loop Mode
  27937. */
  27938. private static _ANIMATIONLOOPMODE_RELATIVE;
  27939. /**
  27940. * Cycle Loop Mode
  27941. */
  27942. private static _ANIMATIONLOOPMODE_CYCLE;
  27943. /**
  27944. * Constant Loop Mode
  27945. */
  27946. private static _ANIMATIONLOOPMODE_CONSTANT;
  27947. /**
  27948. * Get the float animation type
  27949. */
  27950. static readonly ANIMATIONTYPE_FLOAT: number;
  27951. /**
  27952. * Get the Vector3 animation type
  27953. */
  27954. static readonly ANIMATIONTYPE_VECTOR3: number;
  27955. /**
  27956. * Get the Vector2 animation type
  27957. */
  27958. static readonly ANIMATIONTYPE_VECTOR2: number;
  27959. /**
  27960. * Get the Size animation type
  27961. */
  27962. static readonly ANIMATIONTYPE_SIZE: number;
  27963. /**
  27964. * Get the Quaternion animation type
  27965. */
  27966. static readonly ANIMATIONTYPE_QUATERNION: number;
  27967. /**
  27968. * Get the Matrix animation type
  27969. */
  27970. static readonly ANIMATIONTYPE_MATRIX: number;
  27971. /**
  27972. * Get the Color3 animation type
  27973. */
  27974. static readonly ANIMATIONTYPE_COLOR3: number;
  27975. /**
  27976. * Get the Relative Loop Mode
  27977. */
  27978. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27979. /**
  27980. * Get the Cycle Loop Mode
  27981. */
  27982. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27983. /**
  27984. * Get the Constant Loop Mode
  27985. */
  27986. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27987. /** @hidden */
  27988. static _UniversalLerp(left: any, right: any, amount: number): any;
  27989. /**
  27990. * Parses an animation object and creates an animation
  27991. * @param parsedAnimation Parsed animation object
  27992. * @returns Animation object
  27993. */
  27994. static Parse(parsedAnimation: any): Animation;
  27995. /**
  27996. * Appends the serialized animations from the source animations
  27997. * @param source Source containing the animations
  27998. * @param destination Target to store the animations
  27999. */
  28000. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28001. }
  28002. }
  28003. declare module "babylonjs/Animations/animatable.interface" {
  28004. import { Nullable } from "babylonjs/types";
  28005. import { Animation } from "babylonjs/Animations/animation";
  28006. /**
  28007. * Interface containing an array of animations
  28008. */
  28009. export interface IAnimatable {
  28010. /**
  28011. * Array of animations
  28012. */
  28013. animations: Nullable<Array<Animation>>;
  28014. }
  28015. }
  28016. declare module "babylonjs/Materials/fresnelParameters" {
  28017. import { Color3 } from "babylonjs/Maths/math.color";
  28018. /**
  28019. * This represents all the required information to add a fresnel effect on a material:
  28020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28021. */
  28022. export class FresnelParameters {
  28023. private _isEnabled;
  28024. /**
  28025. * Define if the fresnel effect is enable or not.
  28026. */
  28027. isEnabled: boolean;
  28028. /**
  28029. * Define the color used on edges (grazing angle)
  28030. */
  28031. leftColor: Color3;
  28032. /**
  28033. * Define the color used on center
  28034. */
  28035. rightColor: Color3;
  28036. /**
  28037. * Define bias applied to computed fresnel term
  28038. */
  28039. bias: number;
  28040. /**
  28041. * Defined the power exponent applied to fresnel term
  28042. */
  28043. power: number;
  28044. /**
  28045. * Clones the current fresnel and its valuues
  28046. * @returns a clone fresnel configuration
  28047. */
  28048. clone(): FresnelParameters;
  28049. /**
  28050. * Serializes the current fresnel parameters to a JSON representation.
  28051. * @return the JSON serialization
  28052. */
  28053. serialize(): any;
  28054. /**
  28055. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28056. * @param parsedFresnelParameters Define the JSON representation
  28057. * @returns the parsed parameters
  28058. */
  28059. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28060. }
  28061. }
  28062. declare module "babylonjs/Misc/decorators" {
  28063. import { Nullable } from "babylonjs/types";
  28064. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28065. import { Scene } from "babylonjs/scene";
  28066. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28067. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28068. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28069. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28070. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28071. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28072. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28073. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28074. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28075. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28076. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28077. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28078. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28079. /**
  28080. * Decorator used to define property that can be serialized as reference to a camera
  28081. * @param sourceName defines the name of the property to decorate
  28082. */
  28083. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28084. /**
  28085. * Class used to help serialization objects
  28086. */
  28087. export class SerializationHelper {
  28088. /** @hidden */
  28089. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28090. /** @hidden */
  28091. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28092. /** @hidden */
  28093. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28094. /** @hidden */
  28095. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28096. /**
  28097. * Appends the serialized animations from the source animations
  28098. * @param source Source containing the animations
  28099. * @param destination Target to store the animations
  28100. */
  28101. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28102. /**
  28103. * Static function used to serialized a specific entity
  28104. * @param entity defines the entity to serialize
  28105. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28106. * @returns a JSON compatible object representing the serialization of the entity
  28107. */
  28108. static Serialize<T>(entity: T, serializationObject?: any): any;
  28109. /**
  28110. * Creates a new entity from a serialization data object
  28111. * @param creationFunction defines a function used to instanciated the new entity
  28112. * @param source defines the source serialization data
  28113. * @param scene defines the hosting scene
  28114. * @param rootUrl defines the root url for resources
  28115. * @returns a new entity
  28116. */
  28117. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28118. /**
  28119. * Clones an object
  28120. * @param creationFunction defines the function used to instanciate the new object
  28121. * @param source defines the source object
  28122. * @returns the cloned object
  28123. */
  28124. static Clone<T>(creationFunction: () => T, source: T): T;
  28125. /**
  28126. * Instanciates a new object based on a source one (some data will be shared between both object)
  28127. * @param creationFunction defines the function used to instanciate the new object
  28128. * @param source defines the source object
  28129. * @returns the new object
  28130. */
  28131. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28132. }
  28133. }
  28134. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28135. import { Nullable } from "babylonjs/types";
  28136. /**
  28137. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28138. */
  28139. export interface CubeMapInfo {
  28140. /**
  28141. * The pixel array for the front face.
  28142. * This is stored in format, left to right, up to down format.
  28143. */
  28144. front: Nullable<ArrayBufferView>;
  28145. /**
  28146. * The pixel array for the back face.
  28147. * This is stored in format, left to right, up to down format.
  28148. */
  28149. back: Nullable<ArrayBufferView>;
  28150. /**
  28151. * The pixel array for the left face.
  28152. * This is stored in format, left to right, up to down format.
  28153. */
  28154. left: Nullable<ArrayBufferView>;
  28155. /**
  28156. * The pixel array for the right face.
  28157. * This is stored in format, left to right, up to down format.
  28158. */
  28159. right: Nullable<ArrayBufferView>;
  28160. /**
  28161. * The pixel array for the up face.
  28162. * This is stored in format, left to right, up to down format.
  28163. */
  28164. up: Nullable<ArrayBufferView>;
  28165. /**
  28166. * The pixel array for the down face.
  28167. * This is stored in format, left to right, up to down format.
  28168. */
  28169. down: Nullable<ArrayBufferView>;
  28170. /**
  28171. * The size of the cubemap stored.
  28172. *
  28173. * Each faces will be size * size pixels.
  28174. */
  28175. size: number;
  28176. /**
  28177. * The format of the texture.
  28178. *
  28179. * RGBA, RGB.
  28180. */
  28181. format: number;
  28182. /**
  28183. * The type of the texture data.
  28184. *
  28185. * UNSIGNED_INT, FLOAT.
  28186. */
  28187. type: number;
  28188. /**
  28189. * Specifies whether the texture is in gamma space.
  28190. */
  28191. gammaSpace: boolean;
  28192. }
  28193. /**
  28194. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28195. */
  28196. export class PanoramaToCubeMapTools {
  28197. private static FACE_FRONT;
  28198. private static FACE_BACK;
  28199. private static FACE_RIGHT;
  28200. private static FACE_LEFT;
  28201. private static FACE_DOWN;
  28202. private static FACE_UP;
  28203. /**
  28204. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28205. *
  28206. * @param float32Array The source data.
  28207. * @param inputWidth The width of the input panorama.
  28208. * @param inputHeight The height of the input panorama.
  28209. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28210. * @return The cubemap data
  28211. */
  28212. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28213. private static CreateCubemapTexture;
  28214. private static CalcProjectionSpherical;
  28215. }
  28216. }
  28217. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28218. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28220. import { Nullable } from "babylonjs/types";
  28221. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28222. /**
  28223. * Helper class dealing with the extraction of spherical polynomial dataArray
  28224. * from a cube map.
  28225. */
  28226. export class CubeMapToSphericalPolynomialTools {
  28227. private static FileFaces;
  28228. /**
  28229. * Converts a texture to the according Spherical Polynomial data.
  28230. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28231. *
  28232. * @param texture The texture to extract the information from.
  28233. * @return The Spherical Polynomial data.
  28234. */
  28235. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28236. /**
  28237. * Converts a cubemap to the according Spherical Polynomial data.
  28238. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28239. *
  28240. * @param cubeInfo The Cube map to extract the information from.
  28241. * @return The Spherical Polynomial data.
  28242. */
  28243. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28244. }
  28245. }
  28246. declare module "babylonjs/Misc/guid" {
  28247. /**
  28248. * Class used to manipulate GUIDs
  28249. */
  28250. export class GUID {
  28251. /**
  28252. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28253. * Be aware Math.random() could cause collisions, but:
  28254. * "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"
  28255. * @returns a pseudo random id
  28256. */
  28257. static RandomId(): string;
  28258. }
  28259. }
  28260. declare module "babylonjs/Materials/Textures/baseTexture" {
  28261. import { Observable } from "babylonjs/Misc/observable";
  28262. import { Nullable } from "babylonjs/types";
  28263. import { Scene } from "babylonjs/scene";
  28264. import { Matrix } from "babylonjs/Maths/math.vector";
  28265. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28266. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28267. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28268. import { ISize } from "babylonjs/Maths/math.size";
  28269. /**
  28270. * Base class of all the textures in babylon.
  28271. * It groups all the common properties the materials, post process, lights... might need
  28272. * in order to make a correct use of the texture.
  28273. */
  28274. export class BaseTexture implements IAnimatable {
  28275. /**
  28276. * Default anisotropic filtering level for the application.
  28277. * It is set to 4 as a good tradeoff between perf and quality.
  28278. */
  28279. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28280. /**
  28281. * Gets or sets the unique id of the texture
  28282. */
  28283. uniqueId: number;
  28284. /**
  28285. * Define the name of the texture.
  28286. */
  28287. name: string;
  28288. /**
  28289. * Gets or sets an object used to store user defined information.
  28290. */
  28291. metadata: any;
  28292. /**
  28293. * For internal use only. Please do not use.
  28294. */
  28295. reservedDataStore: any;
  28296. private _hasAlpha;
  28297. /**
  28298. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28299. */
  28300. hasAlpha: boolean;
  28301. /**
  28302. * Defines if the alpha value should be determined via the rgb values.
  28303. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28304. */
  28305. getAlphaFromRGB: boolean;
  28306. /**
  28307. * Intensity or strength of the texture.
  28308. * It is commonly used by materials to fine tune the intensity of the texture
  28309. */
  28310. level: number;
  28311. /**
  28312. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28313. * This is part of the texture as textures usually maps to one uv set.
  28314. */
  28315. coordinatesIndex: number;
  28316. private _coordinatesMode;
  28317. /**
  28318. * How a texture is mapped.
  28319. *
  28320. * | Value | Type | Description |
  28321. * | ----- | ----------------------------------- | ----------- |
  28322. * | 0 | EXPLICIT_MODE | |
  28323. * | 1 | SPHERICAL_MODE | |
  28324. * | 2 | PLANAR_MODE | |
  28325. * | 3 | CUBIC_MODE | |
  28326. * | 4 | PROJECTION_MODE | |
  28327. * | 5 | SKYBOX_MODE | |
  28328. * | 6 | INVCUBIC_MODE | |
  28329. * | 7 | EQUIRECTANGULAR_MODE | |
  28330. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28331. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28332. */
  28333. coordinatesMode: number;
  28334. /**
  28335. * | Value | Type | Description |
  28336. * | ----- | ------------------ | ----------- |
  28337. * | 0 | CLAMP_ADDRESSMODE | |
  28338. * | 1 | WRAP_ADDRESSMODE | |
  28339. * | 2 | MIRROR_ADDRESSMODE | |
  28340. */
  28341. wrapU: number;
  28342. /**
  28343. * | Value | Type | Description |
  28344. * | ----- | ------------------ | ----------- |
  28345. * | 0 | CLAMP_ADDRESSMODE | |
  28346. * | 1 | WRAP_ADDRESSMODE | |
  28347. * | 2 | MIRROR_ADDRESSMODE | |
  28348. */
  28349. wrapV: number;
  28350. /**
  28351. * | Value | Type | Description |
  28352. * | ----- | ------------------ | ----------- |
  28353. * | 0 | CLAMP_ADDRESSMODE | |
  28354. * | 1 | WRAP_ADDRESSMODE | |
  28355. * | 2 | MIRROR_ADDRESSMODE | |
  28356. */
  28357. wrapR: number;
  28358. /**
  28359. * With compliant hardware and browser (supporting anisotropic filtering)
  28360. * this defines the level of anisotropic filtering in the texture.
  28361. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28362. */
  28363. anisotropicFilteringLevel: number;
  28364. /**
  28365. * Define if the texture is a cube texture or if false a 2d texture.
  28366. */
  28367. isCube: boolean;
  28368. /**
  28369. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28370. */
  28371. is3D: boolean;
  28372. /**
  28373. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28374. * HDR texture are usually stored in linear space.
  28375. * This only impacts the PBR and Background materials
  28376. */
  28377. gammaSpace: boolean;
  28378. /**
  28379. * Gets whether or not the texture contains RGBD data.
  28380. */
  28381. readonly isRGBD: boolean;
  28382. /**
  28383. * Is Z inverted in the texture (useful in a cube texture).
  28384. */
  28385. invertZ: boolean;
  28386. /**
  28387. * Are mip maps generated for this texture or not.
  28388. */
  28389. readonly noMipmap: boolean;
  28390. /**
  28391. * @hidden
  28392. */
  28393. lodLevelInAlpha: boolean;
  28394. /**
  28395. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28396. */
  28397. lodGenerationOffset: number;
  28398. /**
  28399. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28400. */
  28401. lodGenerationScale: number;
  28402. /**
  28403. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28404. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28405. * average roughness values.
  28406. */
  28407. linearSpecularLOD: boolean;
  28408. /**
  28409. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28410. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28411. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28412. */
  28413. irradianceTexture: Nullable<BaseTexture>;
  28414. /**
  28415. * Define if the texture is a render target.
  28416. */
  28417. isRenderTarget: boolean;
  28418. /**
  28419. * Define the unique id of the texture in the scene.
  28420. */
  28421. readonly uid: string;
  28422. /**
  28423. * Return a string representation of the texture.
  28424. * @returns the texture as a string
  28425. */
  28426. toString(): string;
  28427. /**
  28428. * Get the class name of the texture.
  28429. * @returns "BaseTexture"
  28430. */
  28431. getClassName(): string;
  28432. /**
  28433. * Define the list of animation attached to the texture.
  28434. */
  28435. animations: import("babylonjs/Animations/animation").Animation[];
  28436. /**
  28437. * An event triggered when the texture is disposed.
  28438. */
  28439. onDisposeObservable: Observable<BaseTexture>;
  28440. private _onDisposeObserver;
  28441. /**
  28442. * Callback triggered when the texture has been disposed.
  28443. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28444. */
  28445. onDispose: () => void;
  28446. /**
  28447. * Define the current state of the loading sequence when in delayed load mode.
  28448. */
  28449. delayLoadState: number;
  28450. private _scene;
  28451. /** @hidden */
  28452. _texture: Nullable<InternalTexture>;
  28453. private _uid;
  28454. /**
  28455. * Define if the texture is preventinga material to render or not.
  28456. * If not and the texture is not ready, the engine will use a default black texture instead.
  28457. */
  28458. readonly isBlocking: boolean;
  28459. /**
  28460. * Instantiates a new BaseTexture.
  28461. * Base class of all the textures in babylon.
  28462. * It groups all the common properties the materials, post process, lights... might need
  28463. * in order to make a correct use of the texture.
  28464. * @param scene Define the scene the texture blongs to
  28465. */
  28466. constructor(scene: Nullable<Scene>);
  28467. /**
  28468. * Get the scene the texture belongs to.
  28469. * @returns the scene or null if undefined
  28470. */
  28471. getScene(): Nullable<Scene>;
  28472. /**
  28473. * Get the texture transform matrix used to offset tile the texture for istance.
  28474. * @returns the transformation matrix
  28475. */
  28476. getTextureMatrix(): Matrix;
  28477. /**
  28478. * Get the texture reflection matrix used to rotate/transform the reflection.
  28479. * @returns the reflection matrix
  28480. */
  28481. getReflectionTextureMatrix(): Matrix;
  28482. /**
  28483. * Get the underlying lower level texture from Babylon.
  28484. * @returns the insternal texture
  28485. */
  28486. getInternalTexture(): Nullable<InternalTexture>;
  28487. /**
  28488. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28489. * @returns true if ready or not blocking
  28490. */
  28491. isReadyOrNotBlocking(): boolean;
  28492. /**
  28493. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28494. * @returns true if fully ready
  28495. */
  28496. isReady(): boolean;
  28497. private _cachedSize;
  28498. /**
  28499. * Get the size of the texture.
  28500. * @returns the texture size.
  28501. */
  28502. getSize(): ISize;
  28503. /**
  28504. * Get the base size of the texture.
  28505. * It can be different from the size if the texture has been resized for POT for instance
  28506. * @returns the base size
  28507. */
  28508. getBaseSize(): ISize;
  28509. /**
  28510. * Update the sampling mode of the texture.
  28511. * Default is Trilinear mode.
  28512. *
  28513. * | Value | Type | Description |
  28514. * | ----- | ------------------ | ----------- |
  28515. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28516. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28517. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28518. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28519. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28520. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28521. * | 7 | NEAREST_LINEAR | |
  28522. * | 8 | NEAREST_NEAREST | |
  28523. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28524. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28525. * | 11 | LINEAR_LINEAR | |
  28526. * | 12 | LINEAR_NEAREST | |
  28527. *
  28528. * > _mag_: magnification filter (close to the viewer)
  28529. * > _min_: minification filter (far from the viewer)
  28530. * > _mip_: filter used between mip map levels
  28531. *@param samplingMode Define the new sampling mode of the texture
  28532. */
  28533. updateSamplingMode(samplingMode: number): void;
  28534. /**
  28535. * Scales the texture if is `canRescale()`
  28536. * @param ratio the resize factor we want to use to rescale
  28537. */
  28538. scale(ratio: number): void;
  28539. /**
  28540. * Get if the texture can rescale.
  28541. */
  28542. readonly canRescale: boolean;
  28543. /** @hidden */
  28544. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28545. /** @hidden */
  28546. _rebuild(): void;
  28547. /**
  28548. * Triggers the load sequence in delayed load mode.
  28549. */
  28550. delayLoad(): void;
  28551. /**
  28552. * Clones the texture.
  28553. * @returns the cloned texture
  28554. */
  28555. clone(): Nullable<BaseTexture>;
  28556. /**
  28557. * Get the texture underlying type (INT, FLOAT...)
  28558. */
  28559. readonly textureType: number;
  28560. /**
  28561. * Get the texture underlying format (RGB, RGBA...)
  28562. */
  28563. readonly textureFormat: number;
  28564. /**
  28565. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28566. * This will returns an RGBA array buffer containing either in values (0-255) or
  28567. * float values (0-1) depending of the underlying buffer type.
  28568. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28569. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28570. * @param buffer defines a user defined buffer to fill with data (can be null)
  28571. * @returns The Array buffer containing the pixels data.
  28572. */
  28573. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28574. /**
  28575. * Release and destroy the underlying lower level texture aka internalTexture.
  28576. */
  28577. releaseInternalTexture(): void;
  28578. /**
  28579. * Get the polynomial representation of the texture data.
  28580. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28581. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28582. */
  28583. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28584. /** @hidden */
  28585. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28586. /** @hidden */
  28587. readonly _lodTextureMid: Nullable<BaseTexture>;
  28588. /** @hidden */
  28589. readonly _lodTextureLow: Nullable<BaseTexture>;
  28590. /**
  28591. * Dispose the texture and release its associated resources.
  28592. */
  28593. dispose(): void;
  28594. /**
  28595. * Serialize the texture into a JSON representation that can be parsed later on.
  28596. * @returns the JSON representation of the texture
  28597. */
  28598. serialize(): any;
  28599. /**
  28600. * Helper function to be called back once a list of texture contains only ready textures.
  28601. * @param textures Define the list of textures to wait for
  28602. * @param callback Define the callback triggered once the entire list will be ready
  28603. */
  28604. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28605. }
  28606. }
  28607. declare module "babylonjs/Materials/Textures/internalTexture" {
  28608. import { Observable } from "babylonjs/Misc/observable";
  28609. import { Nullable, int } from "babylonjs/types";
  28610. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28611. import { Engine } from "babylonjs/Engines/engine";
  28612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28613. /**
  28614. * Class used to store data associated with WebGL texture data for the engine
  28615. * This class should not be used directly
  28616. */
  28617. export class InternalTexture {
  28618. /** @hidden */
  28619. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28620. /**
  28621. * The source of the texture data is unknown
  28622. */
  28623. static DATASOURCE_UNKNOWN: number;
  28624. /**
  28625. * Texture data comes from an URL
  28626. */
  28627. static DATASOURCE_URL: number;
  28628. /**
  28629. * Texture data is only used for temporary storage
  28630. */
  28631. static DATASOURCE_TEMP: number;
  28632. /**
  28633. * Texture data comes from raw data (ArrayBuffer)
  28634. */
  28635. static DATASOURCE_RAW: number;
  28636. /**
  28637. * Texture content is dynamic (video or dynamic texture)
  28638. */
  28639. static DATASOURCE_DYNAMIC: number;
  28640. /**
  28641. * Texture content is generated by rendering to it
  28642. */
  28643. static DATASOURCE_RENDERTARGET: number;
  28644. /**
  28645. * Texture content is part of a multi render target process
  28646. */
  28647. static DATASOURCE_MULTIRENDERTARGET: number;
  28648. /**
  28649. * Texture data comes from a cube data file
  28650. */
  28651. static DATASOURCE_CUBE: number;
  28652. /**
  28653. * Texture data comes from a raw cube data
  28654. */
  28655. static DATASOURCE_CUBERAW: number;
  28656. /**
  28657. * Texture data come from a prefiltered cube data file
  28658. */
  28659. static DATASOURCE_CUBEPREFILTERED: number;
  28660. /**
  28661. * Texture content is raw 3D data
  28662. */
  28663. static DATASOURCE_RAW3D: number;
  28664. /**
  28665. * Texture content is a depth texture
  28666. */
  28667. static DATASOURCE_DEPTHTEXTURE: number;
  28668. /**
  28669. * Texture data comes from a raw cube data encoded with RGBD
  28670. */
  28671. static DATASOURCE_CUBERAW_RGBD: number;
  28672. /**
  28673. * Defines if the texture is ready
  28674. */
  28675. isReady: boolean;
  28676. /**
  28677. * Defines if the texture is a cube texture
  28678. */
  28679. isCube: boolean;
  28680. /**
  28681. * Defines if the texture contains 3D data
  28682. */
  28683. is3D: boolean;
  28684. /**
  28685. * Defines if the texture contains multiview data
  28686. */
  28687. isMultiview: boolean;
  28688. /**
  28689. * Gets the URL used to load this texture
  28690. */
  28691. url: string;
  28692. /**
  28693. * Gets the sampling mode of the texture
  28694. */
  28695. samplingMode: number;
  28696. /**
  28697. * Gets a boolean indicating if the texture needs mipmaps generation
  28698. */
  28699. generateMipMaps: boolean;
  28700. /**
  28701. * Gets the number of samples used by the texture (WebGL2+ only)
  28702. */
  28703. samples: number;
  28704. /**
  28705. * Gets the type of the texture (int, float...)
  28706. */
  28707. type: number;
  28708. /**
  28709. * Gets the format of the texture (RGB, RGBA...)
  28710. */
  28711. format: number;
  28712. /**
  28713. * Observable called when the texture is loaded
  28714. */
  28715. onLoadedObservable: Observable<InternalTexture>;
  28716. /**
  28717. * Gets the width of the texture
  28718. */
  28719. width: number;
  28720. /**
  28721. * Gets the height of the texture
  28722. */
  28723. height: number;
  28724. /**
  28725. * Gets the depth of the texture
  28726. */
  28727. depth: number;
  28728. /**
  28729. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28730. */
  28731. baseWidth: number;
  28732. /**
  28733. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28734. */
  28735. baseHeight: number;
  28736. /**
  28737. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28738. */
  28739. baseDepth: number;
  28740. /**
  28741. * Gets a boolean indicating if the texture is inverted on Y axis
  28742. */
  28743. invertY: boolean;
  28744. /** @hidden */
  28745. _invertVScale: boolean;
  28746. /** @hidden */
  28747. _associatedChannel: number;
  28748. /** @hidden */
  28749. _dataSource: number;
  28750. /** @hidden */
  28751. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28752. /** @hidden */
  28753. _bufferView: Nullable<ArrayBufferView>;
  28754. /** @hidden */
  28755. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28756. /** @hidden */
  28757. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28758. /** @hidden */
  28759. _size: number;
  28760. /** @hidden */
  28761. _extension: string;
  28762. /** @hidden */
  28763. _files: Nullable<string[]>;
  28764. /** @hidden */
  28765. _workingCanvas: Nullable<HTMLCanvasElement>;
  28766. /** @hidden */
  28767. _workingContext: Nullable<CanvasRenderingContext2D>;
  28768. /** @hidden */
  28769. _framebuffer: Nullable<WebGLFramebuffer>;
  28770. /** @hidden */
  28771. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28772. /** @hidden */
  28773. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28774. /** @hidden */
  28775. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28776. /** @hidden */
  28777. _attachments: Nullable<number[]>;
  28778. /** @hidden */
  28779. _cachedCoordinatesMode: Nullable<number>;
  28780. /** @hidden */
  28781. _cachedWrapU: Nullable<number>;
  28782. /** @hidden */
  28783. _cachedWrapV: Nullable<number>;
  28784. /** @hidden */
  28785. _cachedWrapR: Nullable<number>;
  28786. /** @hidden */
  28787. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28788. /** @hidden */
  28789. _isDisabled: boolean;
  28790. /** @hidden */
  28791. _compression: Nullable<string>;
  28792. /** @hidden */
  28793. _generateStencilBuffer: boolean;
  28794. /** @hidden */
  28795. _generateDepthBuffer: boolean;
  28796. /** @hidden */
  28797. _comparisonFunction: number;
  28798. /** @hidden */
  28799. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28800. /** @hidden */
  28801. _lodGenerationScale: number;
  28802. /** @hidden */
  28803. _lodGenerationOffset: number;
  28804. /** @hidden */
  28805. _colorTextureArray: Nullable<WebGLTexture>;
  28806. /** @hidden */
  28807. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28808. /** @hidden */
  28809. _lodTextureHigh: Nullable<BaseTexture>;
  28810. /** @hidden */
  28811. _lodTextureMid: Nullable<BaseTexture>;
  28812. /** @hidden */
  28813. _lodTextureLow: Nullable<BaseTexture>;
  28814. /** @hidden */
  28815. _isRGBD: boolean;
  28816. /** @hidden */
  28817. _linearSpecularLOD: boolean;
  28818. /** @hidden */
  28819. _irradianceTexture: Nullable<BaseTexture>;
  28820. /** @hidden */
  28821. _webGLTexture: Nullable<WebGLTexture>;
  28822. /** @hidden */
  28823. _references: number;
  28824. private _engine;
  28825. /**
  28826. * Gets the Engine the texture belongs to.
  28827. * @returns The babylon engine
  28828. */
  28829. getEngine(): Engine;
  28830. /**
  28831. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28832. */
  28833. readonly dataSource: number;
  28834. /**
  28835. * Creates a new InternalTexture
  28836. * @param engine defines the engine to use
  28837. * @param dataSource defines the type of data that will be used
  28838. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28839. */
  28840. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28841. /**
  28842. * Increments the number of references (ie. the number of Texture that point to it)
  28843. */
  28844. incrementReferences(): void;
  28845. /**
  28846. * Change the size of the texture (not the size of the content)
  28847. * @param width defines the new width
  28848. * @param height defines the new height
  28849. * @param depth defines the new depth (1 by default)
  28850. */
  28851. updateSize(width: int, height: int, depth?: int): void;
  28852. /** @hidden */
  28853. _rebuild(): void;
  28854. /** @hidden */
  28855. _swapAndDie(target: InternalTexture): void;
  28856. /**
  28857. * Dispose the current allocated resources
  28858. */
  28859. dispose(): void;
  28860. }
  28861. }
  28862. declare module "babylonjs/Materials/effect" {
  28863. import { Observable } from "babylonjs/Misc/observable";
  28864. import { Nullable } from "babylonjs/types";
  28865. import { IDisposable } from "babylonjs/scene";
  28866. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28867. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28868. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28869. import { Engine } from "babylonjs/Engines/engine";
  28870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28872. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28873. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28875. /**
  28876. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28877. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28878. */
  28879. export class EffectFallbacks {
  28880. private _defines;
  28881. private _currentRank;
  28882. private _maxRank;
  28883. private _mesh;
  28884. /**
  28885. * Removes the fallback from the bound mesh.
  28886. */
  28887. unBindMesh(): void;
  28888. /**
  28889. * Adds a fallback on the specified property.
  28890. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28891. * @param define The name of the define in the shader
  28892. */
  28893. addFallback(rank: number, define: string): void;
  28894. /**
  28895. * Sets the mesh to use CPU skinning when needing to fallback.
  28896. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28897. * @param mesh The mesh to use the fallbacks.
  28898. */
  28899. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28900. /**
  28901. * Checks to see if more fallbacks are still availible.
  28902. */
  28903. readonly isMoreFallbacks: boolean;
  28904. /**
  28905. * Removes the defines that should be removed when falling back.
  28906. * @param currentDefines defines the current define statements for the shader.
  28907. * @param effect defines the current effect we try to compile
  28908. * @returns The resulting defines with defines of the current rank removed.
  28909. */
  28910. reduce(currentDefines: string, effect: Effect): string;
  28911. }
  28912. /**
  28913. * Options to be used when creating an effect.
  28914. */
  28915. export class EffectCreationOptions {
  28916. /**
  28917. * Atrributes that will be used in the shader.
  28918. */
  28919. attributes: string[];
  28920. /**
  28921. * Uniform varible names that will be set in the shader.
  28922. */
  28923. uniformsNames: string[];
  28924. /**
  28925. * Uniform buffer varible names that will be set in the shader.
  28926. */
  28927. uniformBuffersNames: string[];
  28928. /**
  28929. * Sampler texture variable names that will be set in the shader.
  28930. */
  28931. samplers: string[];
  28932. /**
  28933. * Define statements that will be set in the shader.
  28934. */
  28935. defines: any;
  28936. /**
  28937. * Possible fallbacks for this effect to improve performance when needed.
  28938. */
  28939. fallbacks: Nullable<EffectFallbacks>;
  28940. /**
  28941. * Callback that will be called when the shader is compiled.
  28942. */
  28943. onCompiled: Nullable<(effect: Effect) => void>;
  28944. /**
  28945. * Callback that will be called if an error occurs during shader compilation.
  28946. */
  28947. onError: Nullable<(effect: Effect, errors: string) => void>;
  28948. /**
  28949. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28950. */
  28951. indexParameters: any;
  28952. /**
  28953. * Max number of lights that can be used in the shader.
  28954. */
  28955. maxSimultaneousLights: number;
  28956. /**
  28957. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28958. */
  28959. transformFeedbackVaryings: Nullable<string[]>;
  28960. }
  28961. /**
  28962. * Effect containing vertex and fragment shader that can be executed on an object.
  28963. */
  28964. export class Effect implements IDisposable {
  28965. /**
  28966. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28967. */
  28968. static ShadersRepository: string;
  28969. /**
  28970. * Name of the effect.
  28971. */
  28972. name: any;
  28973. /**
  28974. * String container all the define statements that should be set on the shader.
  28975. */
  28976. defines: string;
  28977. /**
  28978. * Callback that will be called when the shader is compiled.
  28979. */
  28980. onCompiled: Nullable<(effect: Effect) => void>;
  28981. /**
  28982. * Callback that will be called if an error occurs during shader compilation.
  28983. */
  28984. onError: Nullable<(effect: Effect, errors: string) => void>;
  28985. /**
  28986. * Callback that will be called when effect is bound.
  28987. */
  28988. onBind: Nullable<(effect: Effect) => void>;
  28989. /**
  28990. * Unique ID of the effect.
  28991. */
  28992. uniqueId: number;
  28993. /**
  28994. * Observable that will be called when the shader is compiled.
  28995. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28996. */
  28997. onCompileObservable: Observable<Effect>;
  28998. /**
  28999. * Observable that will be called if an error occurs during shader compilation.
  29000. */
  29001. onErrorObservable: Observable<Effect>;
  29002. /** @hidden */
  29003. _onBindObservable: Nullable<Observable<Effect>>;
  29004. /**
  29005. * Observable that will be called when effect is bound.
  29006. */
  29007. readonly onBindObservable: Observable<Effect>;
  29008. /** @hidden */
  29009. _bonesComputationForcedToCPU: boolean;
  29010. private static _uniqueIdSeed;
  29011. private _engine;
  29012. private _uniformBuffersNames;
  29013. private _uniformsNames;
  29014. private _samplerList;
  29015. private _samplers;
  29016. private _isReady;
  29017. private _compilationError;
  29018. private _attributesNames;
  29019. private _attributes;
  29020. private _uniforms;
  29021. /**
  29022. * Key for the effect.
  29023. * @hidden
  29024. */
  29025. _key: string;
  29026. private _indexParameters;
  29027. private _fallbacks;
  29028. private _vertexSourceCode;
  29029. private _fragmentSourceCode;
  29030. private _vertexSourceCodeOverride;
  29031. private _fragmentSourceCodeOverride;
  29032. private _transformFeedbackVaryings;
  29033. /**
  29034. * Compiled shader to webGL program.
  29035. * @hidden
  29036. */
  29037. _pipelineContext: Nullable<IPipelineContext>;
  29038. private _valueCache;
  29039. private static _baseCache;
  29040. /**
  29041. * Instantiates an effect.
  29042. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29043. * @param baseName Name of the effect.
  29044. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29045. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29046. * @param samplers List of sampler variables that will be passed to the shader.
  29047. * @param engine Engine to be used to render the effect
  29048. * @param defines Define statements to be added to the shader.
  29049. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29050. * @param onCompiled Callback that will be called when the shader is compiled.
  29051. * @param onError Callback that will be called if an error occurs during shader compilation.
  29052. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29053. */
  29054. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29055. private _useFinalCode;
  29056. /**
  29057. * Unique key for this effect
  29058. */
  29059. readonly key: string;
  29060. /**
  29061. * If the effect has been compiled and prepared.
  29062. * @returns if the effect is compiled and prepared.
  29063. */
  29064. isReady(): boolean;
  29065. /**
  29066. * The engine the effect was initialized with.
  29067. * @returns the engine.
  29068. */
  29069. getEngine(): Engine;
  29070. /**
  29071. * The pipeline context for this effect
  29072. * @returns the associated pipeline context
  29073. */
  29074. getPipelineContext(): Nullable<IPipelineContext>;
  29075. /**
  29076. * The set of names of attribute variables for the shader.
  29077. * @returns An array of attribute names.
  29078. */
  29079. getAttributesNames(): string[];
  29080. /**
  29081. * Returns the attribute at the given index.
  29082. * @param index The index of the attribute.
  29083. * @returns The location of the attribute.
  29084. */
  29085. getAttributeLocation(index: number): number;
  29086. /**
  29087. * Returns the attribute based on the name of the variable.
  29088. * @param name of the attribute to look up.
  29089. * @returns the attribute location.
  29090. */
  29091. getAttributeLocationByName(name: string): number;
  29092. /**
  29093. * The number of attributes.
  29094. * @returns the numnber of attributes.
  29095. */
  29096. getAttributesCount(): number;
  29097. /**
  29098. * Gets the index of a uniform variable.
  29099. * @param uniformName of the uniform to look up.
  29100. * @returns the index.
  29101. */
  29102. getUniformIndex(uniformName: string): number;
  29103. /**
  29104. * Returns the attribute based on the name of the variable.
  29105. * @param uniformName of the uniform to look up.
  29106. * @returns the location of the uniform.
  29107. */
  29108. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29109. /**
  29110. * Returns an array of sampler variable names
  29111. * @returns The array of sampler variable neames.
  29112. */
  29113. getSamplers(): string[];
  29114. /**
  29115. * The error from the last compilation.
  29116. * @returns the error string.
  29117. */
  29118. getCompilationError(): string;
  29119. /**
  29120. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29121. * @param func The callback to be used.
  29122. */
  29123. executeWhenCompiled(func: (effect: Effect) => void): void;
  29124. private _checkIsReady;
  29125. /** @hidden */
  29126. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29127. /** @hidden */
  29128. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29129. /** @hidden */
  29130. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29131. /**
  29132. * Recompiles the webGL program
  29133. * @param vertexSourceCode The source code for the vertex shader.
  29134. * @param fragmentSourceCode The source code for the fragment shader.
  29135. * @param onCompiled Callback called when completed.
  29136. * @param onError Callback called on error.
  29137. * @hidden
  29138. */
  29139. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29140. /**
  29141. * Prepares the effect
  29142. * @hidden
  29143. */
  29144. _prepareEffect(): void;
  29145. /**
  29146. * Checks if the effect is supported. (Must be called after compilation)
  29147. */
  29148. readonly isSupported: boolean;
  29149. /**
  29150. * Binds a texture to the engine to be used as output of the shader.
  29151. * @param channel Name of the output variable.
  29152. * @param texture Texture to bind.
  29153. * @hidden
  29154. */
  29155. _bindTexture(channel: string, texture: InternalTexture): void;
  29156. /**
  29157. * Sets a texture on the engine to be used in the shader.
  29158. * @param channel Name of the sampler variable.
  29159. * @param texture Texture to set.
  29160. */
  29161. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29162. /**
  29163. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29164. * @param channel Name of the sampler variable.
  29165. * @param texture Texture to set.
  29166. */
  29167. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29168. /**
  29169. * Sets an array of textures on the engine to be used in the shader.
  29170. * @param channel Name of the variable.
  29171. * @param textures Textures to set.
  29172. */
  29173. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29174. /**
  29175. * 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)
  29176. * @param channel Name of the sampler variable.
  29177. * @param postProcess Post process to get the input texture from.
  29178. */
  29179. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29180. /**
  29181. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29182. * 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)
  29183. * @param channel Name of the sampler variable.
  29184. * @param postProcess Post process to get the output texture from.
  29185. */
  29186. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29187. /** @hidden */
  29188. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29189. /** @hidden */
  29190. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29191. /** @hidden */
  29192. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29193. /** @hidden */
  29194. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29195. /**
  29196. * Binds a buffer to a uniform.
  29197. * @param buffer Buffer to bind.
  29198. * @param name Name of the uniform variable to bind to.
  29199. */
  29200. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29201. /**
  29202. * Binds block to a uniform.
  29203. * @param blockName Name of the block to bind.
  29204. * @param index Index to bind.
  29205. */
  29206. bindUniformBlock(blockName: string, index: number): void;
  29207. /**
  29208. * Sets an interger value on a uniform variable.
  29209. * @param uniformName Name of the variable.
  29210. * @param value Value to be set.
  29211. * @returns this effect.
  29212. */
  29213. setInt(uniformName: string, value: number): Effect;
  29214. /**
  29215. * Sets an int array on a uniform variable.
  29216. * @param uniformName Name of the variable.
  29217. * @param array array to be set.
  29218. * @returns this effect.
  29219. */
  29220. setIntArray(uniformName: string, array: Int32Array): Effect;
  29221. /**
  29222. * 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)
  29223. * @param uniformName Name of the variable.
  29224. * @param array array to be set.
  29225. * @returns this effect.
  29226. */
  29227. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29228. /**
  29229. * 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)
  29230. * @param uniformName Name of the variable.
  29231. * @param array array to be set.
  29232. * @returns this effect.
  29233. */
  29234. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29235. /**
  29236. * 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)
  29237. * @param uniformName Name of the variable.
  29238. * @param array array to be set.
  29239. * @returns this effect.
  29240. */
  29241. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29242. /**
  29243. * Sets an float array on a uniform variable.
  29244. * @param uniformName Name of the variable.
  29245. * @param array array to be set.
  29246. * @returns this effect.
  29247. */
  29248. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29249. /**
  29250. * 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)
  29251. * @param uniformName Name of the variable.
  29252. * @param array array to be set.
  29253. * @returns this effect.
  29254. */
  29255. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29256. /**
  29257. * 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)
  29258. * @param uniformName Name of the variable.
  29259. * @param array array to be set.
  29260. * @returns this effect.
  29261. */
  29262. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29263. /**
  29264. * 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)
  29265. * @param uniformName Name of the variable.
  29266. * @param array array to be set.
  29267. * @returns this effect.
  29268. */
  29269. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29270. /**
  29271. * Sets an array on a uniform variable.
  29272. * @param uniformName Name of the variable.
  29273. * @param array array to be set.
  29274. * @returns this effect.
  29275. */
  29276. setArray(uniformName: string, array: number[]): Effect;
  29277. /**
  29278. * 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)
  29279. * @param uniformName Name of the variable.
  29280. * @param array array to be set.
  29281. * @returns this effect.
  29282. */
  29283. setArray2(uniformName: string, array: number[]): Effect;
  29284. /**
  29285. * 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)
  29286. * @param uniformName Name of the variable.
  29287. * @param array array to be set.
  29288. * @returns this effect.
  29289. */
  29290. setArray3(uniformName: string, array: number[]): Effect;
  29291. /**
  29292. * 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)
  29293. * @param uniformName Name of the variable.
  29294. * @param array array to be set.
  29295. * @returns this effect.
  29296. */
  29297. setArray4(uniformName: string, array: number[]): Effect;
  29298. /**
  29299. * Sets matrices on a uniform variable.
  29300. * @param uniformName Name of the variable.
  29301. * @param matrices matrices to be set.
  29302. * @returns this effect.
  29303. */
  29304. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29305. /**
  29306. * Sets matrix on a uniform variable.
  29307. * @param uniformName Name of the variable.
  29308. * @param matrix matrix to be set.
  29309. * @returns this effect.
  29310. */
  29311. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29312. /**
  29313. * 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)
  29314. * @param uniformName Name of the variable.
  29315. * @param matrix matrix to be set.
  29316. * @returns this effect.
  29317. */
  29318. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29319. /**
  29320. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29321. * @param uniformName Name of the variable.
  29322. * @param matrix matrix to be set.
  29323. * @returns this effect.
  29324. */
  29325. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29326. /**
  29327. * Sets a float on a uniform variable.
  29328. * @param uniformName Name of the variable.
  29329. * @param value value to be set.
  29330. * @returns this effect.
  29331. */
  29332. setFloat(uniformName: string, value: number): Effect;
  29333. /**
  29334. * Sets a boolean on a uniform variable.
  29335. * @param uniformName Name of the variable.
  29336. * @param bool value to be set.
  29337. * @returns this effect.
  29338. */
  29339. setBool(uniformName: string, bool: boolean): Effect;
  29340. /**
  29341. * Sets a Vector2 on a uniform variable.
  29342. * @param uniformName Name of the variable.
  29343. * @param vector2 vector2 to be set.
  29344. * @returns this effect.
  29345. */
  29346. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29347. /**
  29348. * Sets a float2 on a uniform variable.
  29349. * @param uniformName Name of the variable.
  29350. * @param x First float in float2.
  29351. * @param y Second float in float2.
  29352. * @returns this effect.
  29353. */
  29354. setFloat2(uniformName: string, x: number, y: number): Effect;
  29355. /**
  29356. * Sets a Vector3 on a uniform variable.
  29357. * @param uniformName Name of the variable.
  29358. * @param vector3 Value to be set.
  29359. * @returns this effect.
  29360. */
  29361. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29362. /**
  29363. * Sets a float3 on a uniform variable.
  29364. * @param uniformName Name of the variable.
  29365. * @param x First float in float3.
  29366. * @param y Second float in float3.
  29367. * @param z Third float in float3.
  29368. * @returns this effect.
  29369. */
  29370. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29371. /**
  29372. * Sets a Vector4 on a uniform variable.
  29373. * @param uniformName Name of the variable.
  29374. * @param vector4 Value to be set.
  29375. * @returns this effect.
  29376. */
  29377. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29378. /**
  29379. * Sets a float4 on a uniform variable.
  29380. * @param uniformName Name of the variable.
  29381. * @param x First float in float4.
  29382. * @param y Second float in float4.
  29383. * @param z Third float in float4.
  29384. * @param w Fourth float in float4.
  29385. * @returns this effect.
  29386. */
  29387. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29388. /**
  29389. * Sets a Color3 on a uniform variable.
  29390. * @param uniformName Name of the variable.
  29391. * @param color3 Value to be set.
  29392. * @returns this effect.
  29393. */
  29394. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29395. /**
  29396. * Sets a Color4 on a uniform variable.
  29397. * @param uniformName Name of the variable.
  29398. * @param color3 Value to be set.
  29399. * @param alpha Alpha value to be set.
  29400. * @returns this effect.
  29401. */
  29402. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29403. /**
  29404. * Sets a Color4 on a uniform variable
  29405. * @param uniformName defines the name of the variable
  29406. * @param color4 defines the value to be set
  29407. * @returns this effect.
  29408. */
  29409. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29410. /** Release all associated resources */
  29411. dispose(): void;
  29412. /**
  29413. * This function will add a new shader to the shader store
  29414. * @param name the name of the shader
  29415. * @param pixelShader optional pixel shader content
  29416. * @param vertexShader optional vertex shader content
  29417. */
  29418. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29419. /**
  29420. * Store of each shader (The can be looked up using effect.key)
  29421. */
  29422. static ShadersStore: {
  29423. [key: string]: string;
  29424. };
  29425. /**
  29426. * Store of each included file for a shader (The can be looked up using effect.key)
  29427. */
  29428. static IncludesShadersStore: {
  29429. [key: string]: string;
  29430. };
  29431. /**
  29432. * Resets the cache of effects.
  29433. */
  29434. static ResetCache(): void;
  29435. }
  29436. }
  29437. declare module "babylonjs/Materials/uniformBuffer" {
  29438. import { Nullable, FloatArray } from "babylonjs/types";
  29439. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29440. import { Engine } from "babylonjs/Engines/engine";
  29441. import { Effect } from "babylonjs/Materials/effect";
  29442. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29443. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29444. import { Color3 } from "babylonjs/Maths/math.color";
  29445. /**
  29446. * Uniform buffer objects.
  29447. *
  29448. * Handles blocks of uniform on the GPU.
  29449. *
  29450. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29451. *
  29452. * For more information, please refer to :
  29453. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29454. */
  29455. export class UniformBuffer {
  29456. private _engine;
  29457. private _buffer;
  29458. private _data;
  29459. private _bufferData;
  29460. private _dynamic?;
  29461. private _uniformLocations;
  29462. private _uniformSizes;
  29463. private _uniformLocationPointer;
  29464. private _needSync;
  29465. private _noUBO;
  29466. private _currentEffect;
  29467. private static _MAX_UNIFORM_SIZE;
  29468. private static _tempBuffer;
  29469. /**
  29470. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29471. * This is dynamic to allow compat with webgl 1 and 2.
  29472. * You will need to pass the name of the uniform as well as the value.
  29473. */
  29474. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29475. /**
  29476. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29477. * This is dynamic to allow compat with webgl 1 and 2.
  29478. * You will need to pass the name of the uniform as well as the value.
  29479. */
  29480. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29481. /**
  29482. * Lambda to Update a single float in a uniform buffer.
  29483. * This is dynamic to allow compat with webgl 1 and 2.
  29484. * You will need to pass the name of the uniform as well as the value.
  29485. */
  29486. updateFloat: (name: string, x: number) => void;
  29487. /**
  29488. * Lambda to Update a vec2 of float in a uniform buffer.
  29489. * This is dynamic to allow compat with webgl 1 and 2.
  29490. * You will need to pass the name of the uniform as well as the value.
  29491. */
  29492. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29493. /**
  29494. * Lambda to Update a vec3 of float in a uniform buffer.
  29495. * This is dynamic to allow compat with webgl 1 and 2.
  29496. * You will need to pass the name of the uniform as well as the value.
  29497. */
  29498. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29499. /**
  29500. * Lambda to Update a vec4 of float in a uniform buffer.
  29501. * This is dynamic to allow compat with webgl 1 and 2.
  29502. * You will need to pass the name of the uniform as well as the value.
  29503. */
  29504. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29505. /**
  29506. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29507. * This is dynamic to allow compat with webgl 1 and 2.
  29508. * You will need to pass the name of the uniform as well as the value.
  29509. */
  29510. updateMatrix: (name: string, mat: Matrix) => void;
  29511. /**
  29512. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29513. * This is dynamic to allow compat with webgl 1 and 2.
  29514. * You will need to pass the name of the uniform as well as the value.
  29515. */
  29516. updateVector3: (name: string, vector: Vector3) => void;
  29517. /**
  29518. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29519. * This is dynamic to allow compat with webgl 1 and 2.
  29520. * You will need to pass the name of the uniform as well as the value.
  29521. */
  29522. updateVector4: (name: string, vector: Vector4) => void;
  29523. /**
  29524. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29525. * This is dynamic to allow compat with webgl 1 and 2.
  29526. * You will need to pass the name of the uniform as well as the value.
  29527. */
  29528. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29529. /**
  29530. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29531. * This is dynamic to allow compat with webgl 1 and 2.
  29532. * You will need to pass the name of the uniform as well as the value.
  29533. */
  29534. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29535. /**
  29536. * Instantiates a new Uniform buffer objects.
  29537. *
  29538. * Handles blocks of uniform on the GPU.
  29539. *
  29540. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29541. *
  29542. * For more information, please refer to :
  29543. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29544. * @param engine Define the engine the buffer is associated with
  29545. * @param data Define the data contained in the buffer
  29546. * @param dynamic Define if the buffer is updatable
  29547. */
  29548. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29549. /**
  29550. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29551. * or just falling back on setUniformXXX calls.
  29552. */
  29553. readonly useUbo: boolean;
  29554. /**
  29555. * Indicates if the WebGL underlying uniform buffer is in sync
  29556. * with the javascript cache data.
  29557. */
  29558. readonly isSync: boolean;
  29559. /**
  29560. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29561. * Also, a dynamic UniformBuffer will disable cache verification and always
  29562. * update the underlying WebGL uniform buffer to the GPU.
  29563. * @returns if Dynamic, otherwise false
  29564. */
  29565. isDynamic(): boolean;
  29566. /**
  29567. * The data cache on JS side.
  29568. * @returns the underlying data as a float array
  29569. */
  29570. getData(): Float32Array;
  29571. /**
  29572. * The underlying WebGL Uniform buffer.
  29573. * @returns the webgl buffer
  29574. */
  29575. getBuffer(): Nullable<DataBuffer>;
  29576. /**
  29577. * std140 layout specifies how to align data within an UBO structure.
  29578. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29579. * for specs.
  29580. */
  29581. private _fillAlignment;
  29582. /**
  29583. * Adds an uniform in the buffer.
  29584. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29585. * for the layout to be correct !
  29586. * @param name Name of the uniform, as used in the uniform block in the shader.
  29587. * @param size Data size, or data directly.
  29588. */
  29589. addUniform(name: string, size: number | number[]): void;
  29590. /**
  29591. * Adds a Matrix 4x4 to the uniform buffer.
  29592. * @param name Name of the uniform, as used in the uniform block in the shader.
  29593. * @param mat A 4x4 matrix.
  29594. */
  29595. addMatrix(name: string, mat: Matrix): void;
  29596. /**
  29597. * Adds a vec2 to the uniform buffer.
  29598. * @param name Name of the uniform, as used in the uniform block in the shader.
  29599. * @param x Define the x component value of the vec2
  29600. * @param y Define the y component value of the vec2
  29601. */
  29602. addFloat2(name: string, x: number, y: number): void;
  29603. /**
  29604. * Adds a vec3 to the uniform buffer.
  29605. * @param name Name of the uniform, as used in the uniform block in the shader.
  29606. * @param x Define the x component value of the vec3
  29607. * @param y Define the y component value of the vec3
  29608. * @param z Define the z component value of the vec3
  29609. */
  29610. addFloat3(name: string, x: number, y: number, z: number): void;
  29611. /**
  29612. * Adds a vec3 to the uniform buffer.
  29613. * @param name Name of the uniform, as used in the uniform block in the shader.
  29614. * @param color Define the vec3 from a Color
  29615. */
  29616. addColor3(name: string, color: Color3): void;
  29617. /**
  29618. * Adds a vec4 to the uniform buffer.
  29619. * @param name Name of the uniform, as used in the uniform block in the shader.
  29620. * @param color Define the rgb components from a Color
  29621. * @param alpha Define the a component of the vec4
  29622. */
  29623. addColor4(name: string, color: Color3, alpha: number): void;
  29624. /**
  29625. * Adds a vec3 to the uniform buffer.
  29626. * @param name Name of the uniform, as used in the uniform block in the shader.
  29627. * @param vector Define the vec3 components from a Vector
  29628. */
  29629. addVector3(name: string, vector: Vector3): void;
  29630. /**
  29631. * Adds a Matrix 3x3 to the uniform buffer.
  29632. * @param name Name of the uniform, as used in the uniform block in the shader.
  29633. */
  29634. addMatrix3x3(name: string): void;
  29635. /**
  29636. * Adds a Matrix 2x2 to the uniform buffer.
  29637. * @param name Name of the uniform, as used in the uniform block in the shader.
  29638. */
  29639. addMatrix2x2(name: string): void;
  29640. /**
  29641. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29642. */
  29643. create(): void;
  29644. /** @hidden */
  29645. _rebuild(): void;
  29646. /**
  29647. * Updates the WebGL Uniform Buffer on the GPU.
  29648. * If the `dynamic` flag is set to true, no cache comparison is done.
  29649. * Otherwise, the buffer will be updated only if the cache differs.
  29650. */
  29651. update(): void;
  29652. /**
  29653. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29654. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29655. * @param data Define the flattened data
  29656. * @param size Define the size of the data.
  29657. */
  29658. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29659. private _updateMatrix3x3ForUniform;
  29660. private _updateMatrix3x3ForEffect;
  29661. private _updateMatrix2x2ForEffect;
  29662. private _updateMatrix2x2ForUniform;
  29663. private _updateFloatForEffect;
  29664. private _updateFloatForUniform;
  29665. private _updateFloat2ForEffect;
  29666. private _updateFloat2ForUniform;
  29667. private _updateFloat3ForEffect;
  29668. private _updateFloat3ForUniform;
  29669. private _updateFloat4ForEffect;
  29670. private _updateFloat4ForUniform;
  29671. private _updateMatrixForEffect;
  29672. private _updateMatrixForUniform;
  29673. private _updateVector3ForEffect;
  29674. private _updateVector3ForUniform;
  29675. private _updateVector4ForEffect;
  29676. private _updateVector4ForUniform;
  29677. private _updateColor3ForEffect;
  29678. private _updateColor3ForUniform;
  29679. private _updateColor4ForEffect;
  29680. private _updateColor4ForUniform;
  29681. /**
  29682. * Sets a sampler uniform on the effect.
  29683. * @param name Define the name of the sampler.
  29684. * @param texture Define the texture to set in the sampler
  29685. */
  29686. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29687. /**
  29688. * Directly updates the value of the uniform in the cache AND on the GPU.
  29689. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29690. * @param data Define the flattened data
  29691. */
  29692. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29693. /**
  29694. * Binds this uniform buffer to an effect.
  29695. * @param effect Define the effect to bind the buffer to
  29696. * @param name Name of the uniform block in the shader.
  29697. */
  29698. bindToEffect(effect: Effect, name: string): void;
  29699. /**
  29700. * Disposes the uniform buffer.
  29701. */
  29702. dispose(): void;
  29703. }
  29704. }
  29705. declare module "babylonjs/Audio/analyser" {
  29706. import { Scene } from "babylonjs/scene";
  29707. /**
  29708. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29710. */
  29711. export class Analyser {
  29712. /**
  29713. * Gets or sets the smoothing
  29714. * @ignorenaming
  29715. */
  29716. SMOOTHING: number;
  29717. /**
  29718. * Gets or sets the FFT table size
  29719. * @ignorenaming
  29720. */
  29721. FFT_SIZE: number;
  29722. /**
  29723. * Gets or sets the bar graph amplitude
  29724. * @ignorenaming
  29725. */
  29726. BARGRAPHAMPLITUDE: number;
  29727. /**
  29728. * Gets or sets the position of the debug canvas
  29729. * @ignorenaming
  29730. */
  29731. DEBUGCANVASPOS: {
  29732. x: number;
  29733. y: number;
  29734. };
  29735. /**
  29736. * Gets or sets the debug canvas size
  29737. * @ignorenaming
  29738. */
  29739. DEBUGCANVASSIZE: {
  29740. width: number;
  29741. height: number;
  29742. };
  29743. private _byteFreqs;
  29744. private _byteTime;
  29745. private _floatFreqs;
  29746. private _webAudioAnalyser;
  29747. private _debugCanvas;
  29748. private _debugCanvasContext;
  29749. private _scene;
  29750. private _registerFunc;
  29751. private _audioEngine;
  29752. /**
  29753. * Creates a new analyser
  29754. * @param scene defines hosting scene
  29755. */
  29756. constructor(scene: Scene);
  29757. /**
  29758. * Get the number of data values you will have to play with for the visualization
  29759. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29760. * @returns a number
  29761. */
  29762. getFrequencyBinCount(): number;
  29763. /**
  29764. * Gets the current frequency data as a byte array
  29765. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29766. * @returns a Uint8Array
  29767. */
  29768. getByteFrequencyData(): Uint8Array;
  29769. /**
  29770. * Gets the current waveform as a byte array
  29771. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29772. * @returns a Uint8Array
  29773. */
  29774. getByteTimeDomainData(): Uint8Array;
  29775. /**
  29776. * Gets the current frequency data as a float array
  29777. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29778. * @returns a Float32Array
  29779. */
  29780. getFloatFrequencyData(): Float32Array;
  29781. /**
  29782. * Renders the debug canvas
  29783. */
  29784. drawDebugCanvas(): void;
  29785. /**
  29786. * Stops rendering the debug canvas and removes it
  29787. */
  29788. stopDebugCanvas(): void;
  29789. /**
  29790. * Connects two audio nodes
  29791. * @param inputAudioNode defines first node to connect
  29792. * @param outputAudioNode defines second node to connect
  29793. */
  29794. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29795. /**
  29796. * Releases all associated resources
  29797. */
  29798. dispose(): void;
  29799. }
  29800. }
  29801. declare module "babylonjs/Audio/audioEngine" {
  29802. import { IDisposable } from "babylonjs/scene";
  29803. import { Analyser } from "babylonjs/Audio/analyser";
  29804. import { Nullable } from "babylonjs/types";
  29805. import { Observable } from "babylonjs/Misc/observable";
  29806. /**
  29807. * This represents an audio engine and it is responsible
  29808. * to play, synchronize and analyse sounds throughout the application.
  29809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29810. */
  29811. export interface IAudioEngine extends IDisposable {
  29812. /**
  29813. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29814. */
  29815. readonly canUseWebAudio: boolean;
  29816. /**
  29817. * Gets the current AudioContext if available.
  29818. */
  29819. readonly audioContext: Nullable<AudioContext>;
  29820. /**
  29821. * The master gain node defines the global audio volume of your audio engine.
  29822. */
  29823. readonly masterGain: GainNode;
  29824. /**
  29825. * Gets whether or not mp3 are supported by your browser.
  29826. */
  29827. readonly isMP3supported: boolean;
  29828. /**
  29829. * Gets whether or not ogg are supported by your browser.
  29830. */
  29831. readonly isOGGsupported: boolean;
  29832. /**
  29833. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29834. * @ignoreNaming
  29835. */
  29836. WarnedWebAudioUnsupported: boolean;
  29837. /**
  29838. * Defines if the audio engine relies on a custom unlocked button.
  29839. * In this case, the embedded button will not be displayed.
  29840. */
  29841. useCustomUnlockedButton: boolean;
  29842. /**
  29843. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29844. */
  29845. readonly unlocked: boolean;
  29846. /**
  29847. * Event raised when audio has been unlocked on the browser.
  29848. */
  29849. onAudioUnlockedObservable: Observable<AudioEngine>;
  29850. /**
  29851. * Event raised when audio has been locked on the browser.
  29852. */
  29853. onAudioLockedObservable: Observable<AudioEngine>;
  29854. /**
  29855. * Flags the audio engine in Locked state.
  29856. * This happens due to new browser policies preventing audio to autoplay.
  29857. */
  29858. lock(): void;
  29859. /**
  29860. * Unlocks the audio engine once a user action has been done on the dom.
  29861. * This is helpful to resume play once browser policies have been satisfied.
  29862. */
  29863. unlock(): void;
  29864. }
  29865. /**
  29866. * This represents the default audio engine used in babylon.
  29867. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29869. */
  29870. export class AudioEngine implements IAudioEngine {
  29871. private _audioContext;
  29872. private _audioContextInitialized;
  29873. private _muteButton;
  29874. private _hostElement;
  29875. /**
  29876. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29877. */
  29878. canUseWebAudio: boolean;
  29879. /**
  29880. * The master gain node defines the global audio volume of your audio engine.
  29881. */
  29882. masterGain: GainNode;
  29883. /**
  29884. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29885. * @ignoreNaming
  29886. */
  29887. WarnedWebAudioUnsupported: boolean;
  29888. /**
  29889. * Gets whether or not mp3 are supported by your browser.
  29890. */
  29891. isMP3supported: boolean;
  29892. /**
  29893. * Gets whether or not ogg are supported by your browser.
  29894. */
  29895. isOGGsupported: boolean;
  29896. /**
  29897. * Gets whether audio has been unlocked on the device.
  29898. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29899. * a user interaction has happened.
  29900. */
  29901. unlocked: boolean;
  29902. /**
  29903. * Defines if the audio engine relies on a custom unlocked button.
  29904. * In this case, the embedded button will not be displayed.
  29905. */
  29906. useCustomUnlockedButton: boolean;
  29907. /**
  29908. * Event raised when audio has been unlocked on the browser.
  29909. */
  29910. onAudioUnlockedObservable: Observable<AudioEngine>;
  29911. /**
  29912. * Event raised when audio has been locked on the browser.
  29913. */
  29914. onAudioLockedObservable: Observable<AudioEngine>;
  29915. /**
  29916. * Gets the current AudioContext if available.
  29917. */
  29918. readonly audioContext: Nullable<AudioContext>;
  29919. private _connectedAnalyser;
  29920. /**
  29921. * Instantiates a new audio engine.
  29922. *
  29923. * There should be only one per page as some browsers restrict the number
  29924. * of audio contexts you can create.
  29925. * @param hostElement defines the host element where to display the mute icon if necessary
  29926. */
  29927. constructor(hostElement?: Nullable<HTMLElement>);
  29928. /**
  29929. * Flags the audio engine in Locked state.
  29930. * This happens due to new browser policies preventing audio to autoplay.
  29931. */
  29932. lock(): void;
  29933. /**
  29934. * Unlocks the audio engine once a user action has been done on the dom.
  29935. * This is helpful to resume play once browser policies have been satisfied.
  29936. */
  29937. unlock(): void;
  29938. private _resumeAudioContext;
  29939. private _initializeAudioContext;
  29940. private _tryToRun;
  29941. private _triggerRunningState;
  29942. private _triggerSuspendedState;
  29943. private _displayMuteButton;
  29944. private _moveButtonToTopLeft;
  29945. private _onResize;
  29946. private _hideMuteButton;
  29947. /**
  29948. * Destroy and release the resources associated with the audio ccontext.
  29949. */
  29950. dispose(): void;
  29951. /**
  29952. * Gets the global volume sets on the master gain.
  29953. * @returns the global volume if set or -1 otherwise
  29954. */
  29955. getGlobalVolume(): number;
  29956. /**
  29957. * Sets the global volume of your experience (sets on the master gain).
  29958. * @param newVolume Defines the new global volume of the application
  29959. */
  29960. setGlobalVolume(newVolume: number): void;
  29961. /**
  29962. * Connect the audio engine to an audio analyser allowing some amazing
  29963. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29965. * @param analyser The analyser to connect to the engine
  29966. */
  29967. connectToAnalyser(analyser: Analyser): void;
  29968. }
  29969. }
  29970. declare module "babylonjs/Loading/loadingScreen" {
  29971. /**
  29972. * Interface used to present a loading screen while loading a scene
  29973. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29974. */
  29975. export interface ILoadingScreen {
  29976. /**
  29977. * Function called to display the loading screen
  29978. */
  29979. displayLoadingUI: () => void;
  29980. /**
  29981. * Function called to hide the loading screen
  29982. */
  29983. hideLoadingUI: () => void;
  29984. /**
  29985. * Gets or sets the color to use for the background
  29986. */
  29987. loadingUIBackgroundColor: string;
  29988. /**
  29989. * Gets or sets the text to display while loading
  29990. */
  29991. loadingUIText: string;
  29992. }
  29993. /**
  29994. * Class used for the default loading screen
  29995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29996. */
  29997. export class DefaultLoadingScreen implements ILoadingScreen {
  29998. private _renderingCanvas;
  29999. private _loadingText;
  30000. private _loadingDivBackgroundColor;
  30001. private _loadingDiv;
  30002. private _loadingTextDiv;
  30003. /** Gets or sets the logo url to use for the default loading screen */
  30004. static DefaultLogoUrl: string;
  30005. /** Gets or sets the spinner url to use for the default loading screen */
  30006. static DefaultSpinnerUrl: string;
  30007. /**
  30008. * Creates a new default loading screen
  30009. * @param _renderingCanvas defines the canvas used to render the scene
  30010. * @param _loadingText defines the default text to display
  30011. * @param _loadingDivBackgroundColor defines the default background color
  30012. */
  30013. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30014. /**
  30015. * Function called to display the loading screen
  30016. */
  30017. displayLoadingUI(): void;
  30018. /**
  30019. * Function called to hide the loading screen
  30020. */
  30021. hideLoadingUI(): void;
  30022. /**
  30023. * Gets or sets the text to display while loading
  30024. */
  30025. loadingUIText: string;
  30026. /**
  30027. * Gets or sets the color to use for the background
  30028. */
  30029. loadingUIBackgroundColor: string;
  30030. private _resizeLoadingUI;
  30031. }
  30032. }
  30033. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30034. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30035. import { Engine } from "babylonjs/Engines/engine";
  30036. import { Nullable } from "babylonjs/types";
  30037. /** @hidden */
  30038. export class WebGLPipelineContext implements IPipelineContext {
  30039. engine: Engine;
  30040. program: Nullable<WebGLProgram>;
  30041. context?: WebGLRenderingContext;
  30042. vertexShader?: WebGLShader;
  30043. fragmentShader?: WebGLShader;
  30044. isParallelCompiled: boolean;
  30045. onCompiled?: () => void;
  30046. transformFeedback?: WebGLTransformFeedback | null;
  30047. readonly isAsync: boolean;
  30048. readonly isReady: boolean;
  30049. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30050. }
  30051. }
  30052. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30053. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30054. /** @hidden */
  30055. export class WebGLDataBuffer extends DataBuffer {
  30056. private _buffer;
  30057. constructor(resource: WebGLBuffer);
  30058. readonly underlyingResource: any;
  30059. }
  30060. }
  30061. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30062. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30063. /** @hidden */
  30064. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30065. attributeProcessor(attribute: string): string;
  30066. varyingProcessor(varying: string, isFragment: boolean): string;
  30067. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30068. }
  30069. }
  30070. declare module "babylonjs/Misc/perfCounter" {
  30071. /**
  30072. * This class is used to track a performance counter which is number based.
  30073. * The user has access to many properties which give statistics of different nature.
  30074. *
  30075. * The implementer can track two kinds of Performance Counter: time and count.
  30076. * 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.
  30077. * 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.
  30078. */
  30079. export class PerfCounter {
  30080. /**
  30081. * Gets or sets a global boolean to turn on and off all the counters
  30082. */
  30083. static Enabled: boolean;
  30084. /**
  30085. * Returns the smallest value ever
  30086. */
  30087. readonly min: number;
  30088. /**
  30089. * Returns the biggest value ever
  30090. */
  30091. readonly max: number;
  30092. /**
  30093. * Returns the average value since the performance counter is running
  30094. */
  30095. readonly average: number;
  30096. /**
  30097. * Returns the average value of the last second the counter was monitored
  30098. */
  30099. readonly lastSecAverage: number;
  30100. /**
  30101. * Returns the current value
  30102. */
  30103. readonly current: number;
  30104. /**
  30105. * Gets the accumulated total
  30106. */
  30107. readonly total: number;
  30108. /**
  30109. * Gets the total value count
  30110. */
  30111. readonly count: number;
  30112. /**
  30113. * Creates a new counter
  30114. */
  30115. constructor();
  30116. /**
  30117. * Call this method to start monitoring a new frame.
  30118. * 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.
  30119. */
  30120. fetchNewFrame(): void;
  30121. /**
  30122. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30123. * @param newCount the count value to add to the monitored count
  30124. * @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.
  30125. */
  30126. addCount(newCount: number, fetchResult: boolean): void;
  30127. /**
  30128. * Start monitoring this performance counter
  30129. */
  30130. beginMonitoring(): void;
  30131. /**
  30132. * Compute the time lapsed since the previous beginMonitoring() call.
  30133. * @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
  30134. */
  30135. endMonitoring(newFrame?: boolean): void;
  30136. private _fetchResult;
  30137. private _startMonitoringTime;
  30138. private _min;
  30139. private _max;
  30140. private _average;
  30141. private _current;
  30142. private _totalValueCount;
  30143. private _totalAccumulated;
  30144. private _lastSecAverage;
  30145. private _lastSecAccumulated;
  30146. private _lastSecTime;
  30147. private _lastSecValueCount;
  30148. }
  30149. }
  30150. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30151. /**
  30152. * Interface for any object that can request an animation frame
  30153. */
  30154. export interface ICustomAnimationFrameRequester {
  30155. /**
  30156. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30157. */
  30158. renderFunction?: Function;
  30159. /**
  30160. * Called to request the next frame to render to
  30161. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30162. */
  30163. requestAnimationFrame: Function;
  30164. /**
  30165. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30166. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30167. */
  30168. requestID?: number;
  30169. }
  30170. }
  30171. declare module "babylonjs/Materials/Textures/videoTexture" {
  30172. import { Observable } from "babylonjs/Misc/observable";
  30173. import { Nullable } from "babylonjs/types";
  30174. import { Scene } from "babylonjs/scene";
  30175. import { Texture } from "babylonjs/Materials/Textures/texture";
  30176. /**
  30177. * Settings for finer control over video usage
  30178. */
  30179. export interface VideoTextureSettings {
  30180. /**
  30181. * Applies `autoplay` to video, if specified
  30182. */
  30183. autoPlay?: boolean;
  30184. /**
  30185. * Applies `loop` to video, if specified
  30186. */
  30187. loop?: boolean;
  30188. /**
  30189. * Automatically updates internal texture from video at every frame in the render loop
  30190. */
  30191. autoUpdateTexture: boolean;
  30192. /**
  30193. * Image src displayed during the video loading or until the user interacts with the video.
  30194. */
  30195. poster?: string;
  30196. }
  30197. /**
  30198. * If you want to display a video in your scene, this is the special texture for that.
  30199. * This special texture works similar to other textures, with the exception of a few parameters.
  30200. * @see https://doc.babylonjs.com/how_to/video_texture
  30201. */
  30202. export class VideoTexture extends Texture {
  30203. /**
  30204. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30205. */
  30206. readonly autoUpdateTexture: boolean;
  30207. /**
  30208. * The video instance used by the texture internally
  30209. */
  30210. readonly video: HTMLVideoElement;
  30211. private _onUserActionRequestedObservable;
  30212. /**
  30213. * Event triggerd when a dom action is required by the user to play the video.
  30214. * This happens due to recent changes in browser policies preventing video to auto start.
  30215. */
  30216. readonly onUserActionRequestedObservable: Observable<Texture>;
  30217. private _generateMipMaps;
  30218. private _engine;
  30219. private _stillImageCaptured;
  30220. private _displayingPosterTexture;
  30221. private _settings;
  30222. private _createInternalTextureOnEvent;
  30223. /**
  30224. * Creates a video texture.
  30225. * If you want to display a video in your scene, this is the special texture for that.
  30226. * This special texture works similar to other textures, with the exception of a few parameters.
  30227. * @see https://doc.babylonjs.com/how_to/video_texture
  30228. * @param name optional name, will detect from video source, if not defined
  30229. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30230. * @param scene is obviously the current scene.
  30231. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30232. * @param invertY is false by default but can be used to invert video on Y axis
  30233. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30234. * @param settings allows finer control over video usage
  30235. */
  30236. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30237. private _getName;
  30238. private _getVideo;
  30239. private _createInternalTexture;
  30240. private reset;
  30241. /**
  30242. * @hidden Internal method to initiate `update`.
  30243. */
  30244. _rebuild(): void;
  30245. /**
  30246. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30247. */
  30248. update(): void;
  30249. /**
  30250. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30251. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30252. */
  30253. updateTexture(isVisible: boolean): void;
  30254. protected _updateInternalTexture: () => void;
  30255. /**
  30256. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30257. * @param url New url.
  30258. */
  30259. updateURL(url: string): void;
  30260. /**
  30261. * Dispose the texture and release its associated resources.
  30262. */
  30263. dispose(): void;
  30264. /**
  30265. * Creates a video texture straight from a stream.
  30266. * @param scene Define the scene the texture should be created in
  30267. * @param stream Define the stream the texture should be created from
  30268. * @returns The created video texture as a promise
  30269. */
  30270. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30271. /**
  30272. * Creates a video texture straight from your WebCam video feed.
  30273. * @param scene Define the scene the texture should be created in
  30274. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30275. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30276. * @returns The created video texture as a promise
  30277. */
  30278. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30279. minWidth: number;
  30280. maxWidth: number;
  30281. minHeight: number;
  30282. maxHeight: number;
  30283. deviceId: string;
  30284. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30285. /**
  30286. * Creates a video texture straight from your WebCam video feed.
  30287. * @param scene Define the scene the texture should be created in
  30288. * @param onReady Define a callback to triggered once the texture will be ready
  30289. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30290. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30291. */
  30292. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30293. minWidth: number;
  30294. maxWidth: number;
  30295. minHeight: number;
  30296. maxHeight: number;
  30297. deviceId: string;
  30298. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30299. }
  30300. }
  30301. declare module "babylonjs/Engines/engine" {
  30302. import { Observable } from "babylonjs/Misc/observable";
  30303. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30304. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30305. import { Scene } from "babylonjs/scene";
  30306. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30307. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30308. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30309. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30312. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30313. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30314. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30315. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30316. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30317. import { WebRequest } from "babylonjs/Misc/webRequest";
  30318. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30319. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30320. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30321. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30322. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30323. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30324. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30325. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30326. import { Material } from "babylonjs/Materials/material";
  30327. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30328. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30329. /**
  30330. * Defines the interface used by objects containing a viewport (like a camera)
  30331. */
  30332. interface IViewportOwnerLike {
  30333. /**
  30334. * Gets or sets the viewport
  30335. */
  30336. viewport: IViewportLike;
  30337. }
  30338. /**
  30339. * Interface for attribute information associated with buffer instanciation
  30340. */
  30341. export class InstancingAttributeInfo {
  30342. /**
  30343. * Index/offset of the attribute in the vertex shader
  30344. */
  30345. index: number;
  30346. /**
  30347. * size of the attribute, 1, 2, 3 or 4
  30348. */
  30349. attributeSize: number;
  30350. /**
  30351. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30352. * default is FLOAT
  30353. */
  30354. attribyteType: number;
  30355. /**
  30356. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30357. */
  30358. normalized: boolean;
  30359. /**
  30360. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30361. */
  30362. offset: number;
  30363. /**
  30364. * Name of the GLSL attribute, for debugging purpose only
  30365. */
  30366. attributeName: string;
  30367. }
  30368. /**
  30369. * Define options used to create a depth texture
  30370. */
  30371. export class DepthTextureCreationOptions {
  30372. /** Specifies whether or not a stencil should be allocated in the texture */
  30373. generateStencil?: boolean;
  30374. /** Specifies whether or not bilinear filtering is enable on the texture */
  30375. bilinearFiltering?: boolean;
  30376. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30377. comparisonFunction?: number;
  30378. /** Specifies if the created texture is a cube texture */
  30379. isCube?: boolean;
  30380. }
  30381. /**
  30382. * Class used to describe the capabilities of the engine relatively to the current browser
  30383. */
  30384. export class EngineCapabilities {
  30385. /** Maximum textures units per fragment shader */
  30386. maxTexturesImageUnits: number;
  30387. /** Maximum texture units per vertex shader */
  30388. maxVertexTextureImageUnits: number;
  30389. /** Maximum textures units in the entire pipeline */
  30390. maxCombinedTexturesImageUnits: number;
  30391. /** Maximum texture size */
  30392. maxTextureSize: number;
  30393. /** Maximum cube texture size */
  30394. maxCubemapTextureSize: number;
  30395. /** Maximum render texture size */
  30396. maxRenderTextureSize: number;
  30397. /** Maximum number of vertex attributes */
  30398. maxVertexAttribs: number;
  30399. /** Maximum number of varyings */
  30400. maxVaryingVectors: number;
  30401. /** Maximum number of uniforms per vertex shader */
  30402. maxVertexUniformVectors: number;
  30403. /** Maximum number of uniforms per fragment shader */
  30404. maxFragmentUniformVectors: number;
  30405. /** Defines if standard derivates (dx/dy) are supported */
  30406. standardDerivatives: boolean;
  30407. /** Defines if s3tc texture compression is supported */
  30408. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30409. /** Defines if pvrtc texture compression is supported */
  30410. pvrtc: any;
  30411. /** Defines if etc1 texture compression is supported */
  30412. etc1: any;
  30413. /** Defines if etc2 texture compression is supported */
  30414. etc2: any;
  30415. /** Defines if astc texture compression is supported */
  30416. astc: any;
  30417. /** Defines if float textures are supported */
  30418. textureFloat: boolean;
  30419. /** Defines if vertex array objects are supported */
  30420. vertexArrayObject: boolean;
  30421. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30422. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30423. /** Gets the maximum level of anisotropy supported */
  30424. maxAnisotropy: number;
  30425. /** Defines if instancing is supported */
  30426. instancedArrays: boolean;
  30427. /** Defines if 32 bits indices are supported */
  30428. uintIndices: boolean;
  30429. /** Defines if high precision shaders are supported */
  30430. highPrecisionShaderSupported: boolean;
  30431. /** Defines if depth reading in the fragment shader is supported */
  30432. fragmentDepthSupported: boolean;
  30433. /** Defines if float texture linear filtering is supported*/
  30434. textureFloatLinearFiltering: boolean;
  30435. /** Defines if rendering to float textures is supported */
  30436. textureFloatRender: boolean;
  30437. /** Defines if half float textures are supported*/
  30438. textureHalfFloat: boolean;
  30439. /** Defines if half float texture linear filtering is supported*/
  30440. textureHalfFloatLinearFiltering: boolean;
  30441. /** Defines if rendering to half float textures is supported */
  30442. textureHalfFloatRender: boolean;
  30443. /** Defines if textureLOD shader command is supported */
  30444. textureLOD: boolean;
  30445. /** Defines if draw buffers extension is supported */
  30446. drawBuffersExtension: boolean;
  30447. /** Defines if depth textures are supported */
  30448. depthTextureExtension: boolean;
  30449. /** Defines if float color buffer are supported */
  30450. colorBufferFloat: boolean;
  30451. /** Gets disjoint timer query extension (null if not supported) */
  30452. timerQuery: EXT_disjoint_timer_query;
  30453. /** Defines if timestamp can be used with timer query */
  30454. canUseTimestampForTimerQuery: boolean;
  30455. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30456. multiview: any;
  30457. /** Function used to let the system compiles shaders in background */
  30458. parallelShaderCompile: {
  30459. COMPLETION_STATUS_KHR: number;
  30460. };
  30461. }
  30462. /** Interface defining initialization parameters for Engine class */
  30463. export interface EngineOptions extends WebGLContextAttributes {
  30464. /**
  30465. * Defines if the engine should no exceed a specified device ratio
  30466. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30467. */
  30468. limitDeviceRatio?: number;
  30469. /**
  30470. * Defines if webvr should be enabled automatically
  30471. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30472. */
  30473. autoEnableWebVR?: boolean;
  30474. /**
  30475. * Defines if webgl2 should be turned off even if supported
  30476. * @see http://doc.babylonjs.com/features/webgl2
  30477. */
  30478. disableWebGL2Support?: boolean;
  30479. /**
  30480. * Defines if webaudio should be initialized as well
  30481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30482. */
  30483. audioEngine?: boolean;
  30484. /**
  30485. * Defines if animations should run using a deterministic lock step
  30486. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30487. */
  30488. deterministicLockstep?: boolean;
  30489. /** Defines the maximum steps to use with deterministic lock step mode */
  30490. lockstepMaxSteps?: number;
  30491. /**
  30492. * Defines that engine should ignore context lost events
  30493. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30494. */
  30495. doNotHandleContextLost?: boolean;
  30496. /**
  30497. * Defines that engine should ignore modifying touch action attribute and style
  30498. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30499. */
  30500. doNotHandleTouchAction?: boolean;
  30501. /**
  30502. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30503. */
  30504. useHighPrecisionFloats?: boolean;
  30505. }
  30506. /**
  30507. * Defines the interface used by display changed events
  30508. */
  30509. export interface IDisplayChangedEventArgs {
  30510. /** Gets the vrDisplay object (if any) */
  30511. vrDisplay: Nullable<any>;
  30512. /** Gets a boolean indicating if webVR is supported */
  30513. vrSupported: boolean;
  30514. }
  30515. /**
  30516. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30517. */
  30518. export class Engine {
  30519. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30520. static ExceptionList: ({
  30521. key: string;
  30522. capture: string;
  30523. captureConstraint: number;
  30524. targets: string[];
  30525. } | {
  30526. key: string;
  30527. capture: null;
  30528. captureConstraint: null;
  30529. targets: string[];
  30530. })[];
  30531. /** Gets the list of created engines */
  30532. static readonly Instances: Engine[];
  30533. /**
  30534. * Gets the latest created engine
  30535. */
  30536. static readonly LastCreatedEngine: Nullable<Engine>;
  30537. /**
  30538. * Gets the latest created scene
  30539. */
  30540. static readonly LastCreatedScene: Nullable<Scene>;
  30541. /**
  30542. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30543. * @param flag defines which part of the materials must be marked as dirty
  30544. * @param predicate defines a predicate used to filter which materials should be affected
  30545. */
  30546. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30547. /** @hidden */
  30548. static _TextureLoaders: IInternalTextureLoader[];
  30549. /** Defines that alpha blending is disabled */
  30550. static readonly ALPHA_DISABLE: number;
  30551. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30552. static readonly ALPHA_ADD: number;
  30553. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30554. static readonly ALPHA_COMBINE: number;
  30555. /** Defines that alpha blending to DEST - SRC * DEST */
  30556. static readonly ALPHA_SUBTRACT: number;
  30557. /** Defines that alpha blending to SRC * DEST */
  30558. static readonly ALPHA_MULTIPLY: number;
  30559. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30560. static readonly ALPHA_MAXIMIZED: number;
  30561. /** Defines that alpha blending to SRC + DEST */
  30562. static readonly ALPHA_ONEONE: number;
  30563. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30564. static readonly ALPHA_PREMULTIPLIED: number;
  30565. /**
  30566. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30567. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30568. */
  30569. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30570. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30571. static readonly ALPHA_INTERPOLATE: number;
  30572. /**
  30573. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30574. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30575. */
  30576. static readonly ALPHA_SCREENMODE: number;
  30577. /** Defines that the ressource is not delayed*/
  30578. static readonly DELAYLOADSTATE_NONE: number;
  30579. /** Defines that the ressource was successfully delay loaded */
  30580. static readonly DELAYLOADSTATE_LOADED: number;
  30581. /** Defines that the ressource is currently delay loading */
  30582. static readonly DELAYLOADSTATE_LOADING: number;
  30583. /** Defines that the ressource is delayed and has not started loading */
  30584. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30585. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30586. static readonly NEVER: number;
  30587. /** 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 */
  30588. static readonly ALWAYS: number;
  30589. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30590. static readonly LESS: number;
  30591. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30592. static readonly EQUAL: number;
  30593. /** 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 */
  30594. static readonly LEQUAL: number;
  30595. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30596. static readonly GREATER: number;
  30597. /** 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 */
  30598. static readonly GEQUAL: number;
  30599. /** 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 */
  30600. static readonly NOTEQUAL: number;
  30601. /** Passed to stencilOperation to specify that stencil value must be kept */
  30602. static readonly KEEP: number;
  30603. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30604. static readonly REPLACE: number;
  30605. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30606. static readonly INCR: number;
  30607. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30608. static readonly DECR: number;
  30609. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30610. static readonly INVERT: number;
  30611. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30612. static readonly INCR_WRAP: number;
  30613. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30614. static readonly DECR_WRAP: number;
  30615. /** Texture is not repeating outside of 0..1 UVs */
  30616. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30617. /** Texture is repeating outside of 0..1 UVs */
  30618. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30619. /** Texture is repeating and mirrored */
  30620. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30621. /** ALPHA */
  30622. static readonly TEXTUREFORMAT_ALPHA: number;
  30623. /** LUMINANCE */
  30624. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30625. /** LUMINANCE_ALPHA */
  30626. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30627. /** RGB */
  30628. static readonly TEXTUREFORMAT_RGB: number;
  30629. /** RGBA */
  30630. static readonly TEXTUREFORMAT_RGBA: number;
  30631. /** RED */
  30632. static readonly TEXTUREFORMAT_RED: number;
  30633. /** RED (2nd reference) */
  30634. static readonly TEXTUREFORMAT_R: number;
  30635. /** RG */
  30636. static readonly TEXTUREFORMAT_RG: number;
  30637. /** RED_INTEGER */
  30638. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30639. /** RED_INTEGER (2nd reference) */
  30640. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30641. /** RG_INTEGER */
  30642. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30643. /** RGB_INTEGER */
  30644. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30645. /** RGBA_INTEGER */
  30646. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30647. /** UNSIGNED_BYTE */
  30648. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30649. /** UNSIGNED_BYTE (2nd reference) */
  30650. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30651. /** FLOAT */
  30652. static readonly TEXTURETYPE_FLOAT: number;
  30653. /** HALF_FLOAT */
  30654. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30655. /** BYTE */
  30656. static readonly TEXTURETYPE_BYTE: number;
  30657. /** SHORT */
  30658. static readonly TEXTURETYPE_SHORT: number;
  30659. /** UNSIGNED_SHORT */
  30660. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30661. /** INT */
  30662. static readonly TEXTURETYPE_INT: number;
  30663. /** UNSIGNED_INT */
  30664. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30665. /** UNSIGNED_SHORT_4_4_4_4 */
  30666. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30667. /** UNSIGNED_SHORT_5_5_5_1 */
  30668. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30669. /** UNSIGNED_SHORT_5_6_5 */
  30670. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30671. /** UNSIGNED_INT_2_10_10_10_REV */
  30672. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30673. /** UNSIGNED_INT_24_8 */
  30674. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30675. /** UNSIGNED_INT_10F_11F_11F_REV */
  30676. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30677. /** UNSIGNED_INT_5_9_9_9_REV */
  30678. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30679. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30680. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30681. /** nearest is mag = nearest and min = nearest and mip = linear */
  30682. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30683. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30684. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30685. /** Trilinear is mag = linear and min = linear and mip = linear */
  30686. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30687. /** nearest is mag = nearest and min = nearest and mip = linear */
  30688. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30689. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30690. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30691. /** Trilinear is mag = linear and min = linear and mip = linear */
  30692. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30693. /** mag = nearest and min = nearest and mip = nearest */
  30694. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30695. /** mag = nearest and min = linear and mip = nearest */
  30696. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30697. /** mag = nearest and min = linear and mip = linear */
  30698. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30699. /** mag = nearest and min = linear and mip = none */
  30700. static readonly TEXTURE_NEAREST_LINEAR: number;
  30701. /** mag = nearest and min = nearest and mip = none */
  30702. static readonly TEXTURE_NEAREST_NEAREST: number;
  30703. /** mag = linear and min = nearest and mip = nearest */
  30704. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30705. /** mag = linear and min = nearest and mip = linear */
  30706. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30707. /** mag = linear and min = linear and mip = none */
  30708. static readonly TEXTURE_LINEAR_LINEAR: number;
  30709. /** mag = linear and min = nearest and mip = none */
  30710. static readonly TEXTURE_LINEAR_NEAREST: number;
  30711. /** Explicit coordinates mode */
  30712. static readonly TEXTURE_EXPLICIT_MODE: number;
  30713. /** Spherical coordinates mode */
  30714. static readonly TEXTURE_SPHERICAL_MODE: number;
  30715. /** Planar coordinates mode */
  30716. static readonly TEXTURE_PLANAR_MODE: number;
  30717. /** Cubic coordinates mode */
  30718. static readonly TEXTURE_CUBIC_MODE: number;
  30719. /** Projection coordinates mode */
  30720. static readonly TEXTURE_PROJECTION_MODE: number;
  30721. /** Skybox coordinates mode */
  30722. static readonly TEXTURE_SKYBOX_MODE: number;
  30723. /** Inverse Cubic coordinates mode */
  30724. static readonly TEXTURE_INVCUBIC_MODE: number;
  30725. /** Equirectangular coordinates mode */
  30726. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30727. /** Equirectangular Fixed coordinates mode */
  30728. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30729. /** Equirectangular Fixed Mirrored coordinates mode */
  30730. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30731. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30732. static readonly SCALEMODE_FLOOR: number;
  30733. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30734. static readonly SCALEMODE_NEAREST: number;
  30735. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30736. static readonly SCALEMODE_CEILING: number;
  30737. /**
  30738. * Returns the current npm package of the sdk
  30739. */
  30740. static readonly NpmPackage: string;
  30741. /**
  30742. * Returns the current version of the framework
  30743. */
  30744. static readonly Version: string;
  30745. /**
  30746. * Returns a string describing the current engine
  30747. */
  30748. readonly description: string;
  30749. /**
  30750. * Gets or sets the epsilon value used by collision engine
  30751. */
  30752. static CollisionsEpsilon: number;
  30753. /**
  30754. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30755. */
  30756. static ShadersRepository: string;
  30757. /**
  30758. * Method called to create the default loading screen.
  30759. * This can be overriden in your own app.
  30760. * @param canvas The rendering canvas element
  30761. * @returns The loading screen
  30762. */
  30763. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30764. /**
  30765. * Method called to create the default rescale post process on each engine.
  30766. */
  30767. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30768. /** @hidden */
  30769. _shaderProcessor: IShaderProcessor;
  30770. /**
  30771. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30772. */
  30773. forcePOTTextures: boolean;
  30774. /**
  30775. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30776. */
  30777. isFullscreen: boolean;
  30778. /**
  30779. * Gets a boolean indicating if the pointer is currently locked
  30780. */
  30781. isPointerLock: boolean;
  30782. /**
  30783. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30784. */
  30785. cullBackFaces: boolean;
  30786. /**
  30787. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30788. */
  30789. renderEvenInBackground: boolean;
  30790. /**
  30791. * Gets or sets a boolean indicating that cache can be kept between frames
  30792. */
  30793. preventCacheWipeBetweenFrames: boolean;
  30794. /**
  30795. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30796. **/
  30797. enableOfflineSupport: boolean;
  30798. /**
  30799. * 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)
  30800. **/
  30801. disableManifestCheck: boolean;
  30802. /**
  30803. * Gets the list of created scenes
  30804. */
  30805. scenes: Scene[];
  30806. /**
  30807. * Event raised when a new scene is created
  30808. */
  30809. onNewSceneAddedObservable: Observable<Scene>;
  30810. /**
  30811. * Gets the list of created postprocesses
  30812. */
  30813. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30814. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30815. validateShaderPrograms: boolean;
  30816. /**
  30817. * Observable event triggered each time the rendering canvas is resized
  30818. */
  30819. onResizeObservable: Observable<Engine>;
  30820. /**
  30821. * Observable event triggered each time the canvas loses focus
  30822. */
  30823. onCanvasBlurObservable: Observable<Engine>;
  30824. /**
  30825. * Observable event triggered each time the canvas gains focus
  30826. */
  30827. onCanvasFocusObservable: Observable<Engine>;
  30828. /**
  30829. * Observable event triggered each time the canvas receives pointerout event
  30830. */
  30831. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30832. /**
  30833. * Observable event triggered before each texture is initialized
  30834. */
  30835. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30836. /**
  30837. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30838. */
  30839. disableUniformBuffers: boolean;
  30840. /** @hidden */
  30841. _uniformBuffers: UniformBuffer[];
  30842. /**
  30843. * Gets a boolean indicating that the engine supports uniform buffers
  30844. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30845. */
  30846. readonly supportsUniformBuffers: boolean;
  30847. /**
  30848. * Observable raised when the engine begins a new frame
  30849. */
  30850. onBeginFrameObservable: Observable<Engine>;
  30851. /**
  30852. * If set, will be used to request the next animation frame for the render loop
  30853. */
  30854. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30855. /**
  30856. * Observable raised when the engine ends the current frame
  30857. */
  30858. onEndFrameObservable: Observable<Engine>;
  30859. /**
  30860. * Observable raised when the engine is about to compile a shader
  30861. */
  30862. onBeforeShaderCompilationObservable: Observable<Engine>;
  30863. /**
  30864. * Observable raised when the engine has jsut compiled a shader
  30865. */
  30866. onAfterShaderCompilationObservable: Observable<Engine>;
  30867. /** @hidden */
  30868. _gl: WebGLRenderingContext;
  30869. private _renderingCanvas;
  30870. private _windowIsBackground;
  30871. private _webGLVersion;
  30872. protected _highPrecisionShadersAllowed: boolean;
  30873. /** @hidden */
  30874. readonly _shouldUseHighPrecisionShader: boolean;
  30875. /**
  30876. * Gets a boolean indicating that only power of 2 textures are supported
  30877. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30878. */
  30879. readonly needPOTTextures: boolean;
  30880. /** @hidden */
  30881. _badOS: boolean;
  30882. /** @hidden */
  30883. _badDesktopOS: boolean;
  30884. /**
  30885. * Gets the audio engine
  30886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30887. * @ignorenaming
  30888. */
  30889. static audioEngine: IAudioEngine;
  30890. /**
  30891. * Default AudioEngine factory responsible of creating the Audio Engine.
  30892. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30893. */
  30894. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30895. /**
  30896. * Default offline support factory responsible of creating a tool used to store data locally.
  30897. * By default, this will create a Database object if the workload has been embedded.
  30898. */
  30899. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30900. private _onFocus;
  30901. private _onBlur;
  30902. private _onCanvasPointerOut;
  30903. private _onCanvasBlur;
  30904. private _onCanvasFocus;
  30905. private _onFullscreenChange;
  30906. private _onPointerLockChange;
  30907. private _hardwareScalingLevel;
  30908. /** @hidden */
  30909. _caps: EngineCapabilities;
  30910. private _pointerLockRequested;
  30911. private _isStencilEnable;
  30912. private _colorWrite;
  30913. private _loadingScreen;
  30914. /** @hidden */
  30915. _drawCalls: PerfCounter;
  30916. private _glVersion;
  30917. private _glRenderer;
  30918. private _glVendor;
  30919. private _videoTextureSupported;
  30920. private _renderingQueueLaunched;
  30921. private _activeRenderLoops;
  30922. private _deterministicLockstep;
  30923. private _lockstepMaxSteps;
  30924. /**
  30925. * Observable signaled when a context lost event is raised
  30926. */
  30927. onContextLostObservable: Observable<Engine>;
  30928. /**
  30929. * Observable signaled when a context restored event is raised
  30930. */
  30931. onContextRestoredObservable: Observable<Engine>;
  30932. private _onContextLost;
  30933. private _onContextRestored;
  30934. private _contextWasLost;
  30935. /** @hidden */
  30936. _doNotHandleContextLost: boolean;
  30937. /**
  30938. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30940. */
  30941. doNotHandleContextLost: boolean;
  30942. private _performanceMonitor;
  30943. private _fps;
  30944. private _deltaTime;
  30945. /**
  30946. * Turn this value on if you want to pause FPS computation when in background
  30947. */
  30948. disablePerformanceMonitorInBackground: boolean;
  30949. /**
  30950. * Gets the performance monitor attached to this engine
  30951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30952. */
  30953. readonly performanceMonitor: PerformanceMonitor;
  30954. /**
  30955. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30956. */
  30957. disableVertexArrayObjects: boolean;
  30958. /** @hidden */
  30959. protected _depthCullingState: _DepthCullingState;
  30960. /** @hidden */
  30961. protected _stencilState: _StencilState;
  30962. /** @hidden */
  30963. protected _alphaState: _AlphaState;
  30964. /** @hidden */
  30965. protected _alphaMode: number;
  30966. /** @hidden */
  30967. _internalTexturesCache: InternalTexture[];
  30968. /** @hidden */
  30969. protected _activeChannel: number;
  30970. private _currentTextureChannel;
  30971. /** @hidden */
  30972. protected _boundTexturesCache: {
  30973. [key: string]: Nullable<InternalTexture>;
  30974. };
  30975. /** @hidden */
  30976. protected _currentEffect: Nullable<Effect>;
  30977. /** @hidden */
  30978. protected _currentProgram: Nullable<WebGLProgram>;
  30979. private _compiledEffects;
  30980. private _vertexAttribArraysEnabled;
  30981. /** @hidden */
  30982. protected _cachedViewport: Nullable<IViewportLike>;
  30983. private _cachedVertexArrayObject;
  30984. /** @hidden */
  30985. protected _cachedVertexBuffers: any;
  30986. /** @hidden */
  30987. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30988. /** @hidden */
  30989. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30990. /** @hidden */
  30991. _currentRenderTarget: Nullable<InternalTexture>;
  30992. private _uintIndicesCurrentlySet;
  30993. private _currentBoundBuffer;
  30994. /** @hidden */
  30995. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30996. private _currentBufferPointers;
  30997. private _currentInstanceLocations;
  30998. private _currentInstanceBuffers;
  30999. private _textureUnits;
  31000. /** @hidden */
  31001. _workingCanvas: Nullable<HTMLCanvasElement>;
  31002. /** @hidden */
  31003. _workingContext: Nullable<CanvasRenderingContext2D>;
  31004. private _rescalePostProcess;
  31005. private _dummyFramebuffer;
  31006. private _externalData;
  31007. /** @hidden */
  31008. _bindedRenderFunction: any;
  31009. private _vaoRecordInProgress;
  31010. private _mustWipeVertexAttributes;
  31011. private _emptyTexture;
  31012. private _emptyCubeTexture;
  31013. private _emptyTexture3D;
  31014. /** @hidden */
  31015. _frameHandler: number;
  31016. private _nextFreeTextureSlots;
  31017. private _maxSimultaneousTextures;
  31018. private _activeRequests;
  31019. private _texturesSupported;
  31020. /** @hidden */
  31021. _textureFormatInUse: Nullable<string>;
  31022. /**
  31023. * Gets the list of texture formats supported
  31024. */
  31025. readonly texturesSupported: Array<string>;
  31026. /**
  31027. * Gets the list of texture formats in use
  31028. */
  31029. readonly textureFormatInUse: Nullable<string>;
  31030. /**
  31031. * Gets the current viewport
  31032. */
  31033. readonly currentViewport: Nullable<IViewportLike>;
  31034. /**
  31035. * Gets the default empty texture
  31036. */
  31037. readonly emptyTexture: InternalTexture;
  31038. /**
  31039. * Gets the default empty 3D texture
  31040. */
  31041. readonly emptyTexture3D: InternalTexture;
  31042. /**
  31043. * Gets the default empty cube texture
  31044. */
  31045. readonly emptyCubeTexture: InternalTexture;
  31046. /**
  31047. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31048. */
  31049. readonly premultipliedAlpha: boolean;
  31050. /**
  31051. * Creates a new engine
  31052. * @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
  31053. * @param antialias defines enable antialiasing (default: false)
  31054. * @param options defines further options to be sent to the getContext() function
  31055. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31056. */
  31057. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31058. /**
  31059. * Initializes a webVR display and starts listening to display change events
  31060. * The onVRDisplayChangedObservable will be notified upon these changes
  31061. * @returns The onVRDisplayChangedObservable
  31062. */
  31063. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31064. /** @hidden */
  31065. _prepareVRComponent(): void;
  31066. /** @hidden */
  31067. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31068. /** @hidden */
  31069. _submitVRFrame(): void;
  31070. /**
  31071. * Call this function to leave webVR mode
  31072. * Will do nothing if webVR is not supported or if there is no webVR device
  31073. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31074. */
  31075. disableVR(): void;
  31076. /**
  31077. * Gets a boolean indicating that the system is in VR mode and is presenting
  31078. * @returns true if VR mode is engaged
  31079. */
  31080. isVRPresenting(): boolean;
  31081. /** @hidden */
  31082. _requestVRFrame(): void;
  31083. private _disableTouchAction;
  31084. private _rebuildInternalTextures;
  31085. private _rebuildEffects;
  31086. /**
  31087. * Gets a boolean indicating if all created effects are ready
  31088. * @returns true if all effects are ready
  31089. */
  31090. areAllEffectsReady(): boolean;
  31091. private _rebuildBuffers;
  31092. private _initGLContext;
  31093. /**
  31094. * Gets version of the current webGL context
  31095. */
  31096. readonly webGLVersion: number;
  31097. /**
  31098. * Gets a string idenfifying the name of the class
  31099. * @returns "Engine" string
  31100. */
  31101. getClassName(): string;
  31102. /**
  31103. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31104. */
  31105. readonly isStencilEnable: boolean;
  31106. /** @hidden */
  31107. _prepareWorkingCanvas(): void;
  31108. /**
  31109. * Reset the texture cache to empty state
  31110. */
  31111. resetTextureCache(): void;
  31112. /**
  31113. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31114. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31115. * @returns true if engine is in deterministic lock step mode
  31116. */
  31117. isDeterministicLockStep(): boolean;
  31118. /**
  31119. * Gets the max steps when engine is running in deterministic lock step
  31120. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31121. * @returns the max steps
  31122. */
  31123. getLockstepMaxSteps(): number;
  31124. /**
  31125. * Gets an object containing information about the current webGL context
  31126. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31127. */
  31128. getGlInfo(): {
  31129. vendor: string;
  31130. renderer: string;
  31131. version: string;
  31132. };
  31133. /**
  31134. * Gets current aspect ratio
  31135. * @param viewportOwner defines the camera to use to get the aspect ratio
  31136. * @param useScreen defines if screen size must be used (or the current render target if any)
  31137. * @returns a number defining the aspect ratio
  31138. */
  31139. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31140. /**
  31141. * Gets current screen aspect ratio
  31142. * @returns a number defining the aspect ratio
  31143. */
  31144. getScreenAspectRatio(): number;
  31145. /**
  31146. * Gets the current render width
  31147. * @param useScreen defines if screen size must be used (or the current render target if any)
  31148. * @returns a number defining the current render width
  31149. */
  31150. getRenderWidth(useScreen?: boolean): number;
  31151. /**
  31152. * Gets the current render height
  31153. * @param useScreen defines if screen size must be used (or the current render target if any)
  31154. * @returns a number defining the current render height
  31155. */
  31156. getRenderHeight(useScreen?: boolean): number;
  31157. /**
  31158. * Gets the HTML canvas attached with the current webGL context
  31159. * @returns a HTML canvas
  31160. */
  31161. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31162. /**
  31163. * Gets the client rect of the HTML canvas attached with the current webGL context
  31164. * @returns a client rectanglee
  31165. */
  31166. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31167. /**
  31168. * Defines the hardware scaling level.
  31169. * By default the hardware scaling level is computed from the window device ratio.
  31170. * 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.
  31171. * @param level defines the level to use
  31172. */
  31173. setHardwareScalingLevel(level: number): void;
  31174. /**
  31175. * Gets the current hardware scaling level.
  31176. * By default the hardware scaling level is computed from the window device ratio.
  31177. * 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.
  31178. * @returns a number indicating the current hardware scaling level
  31179. */
  31180. getHardwareScalingLevel(): number;
  31181. /**
  31182. * Gets the list of loaded textures
  31183. * @returns an array containing all loaded textures
  31184. */
  31185. getLoadedTexturesCache(): InternalTexture[];
  31186. /**
  31187. * Gets the object containing all engine capabilities
  31188. * @returns the EngineCapabilities object
  31189. */
  31190. getCaps(): EngineCapabilities;
  31191. /**
  31192. * Gets the current depth function
  31193. * @returns a number defining the depth function
  31194. */
  31195. getDepthFunction(): Nullable<number>;
  31196. /**
  31197. * Sets the current depth function
  31198. * @param depthFunc defines the function to use
  31199. */
  31200. setDepthFunction(depthFunc: number): void;
  31201. /**
  31202. * Sets the current depth function to GREATER
  31203. */
  31204. setDepthFunctionToGreater(): void;
  31205. /**
  31206. * Sets the current depth function to GEQUAL
  31207. */
  31208. setDepthFunctionToGreaterOrEqual(): void;
  31209. /**
  31210. * Sets the current depth function to LESS
  31211. */
  31212. setDepthFunctionToLess(): void;
  31213. private _cachedStencilBuffer;
  31214. private _cachedStencilFunction;
  31215. private _cachedStencilMask;
  31216. private _cachedStencilOperationPass;
  31217. private _cachedStencilOperationFail;
  31218. private _cachedStencilOperationDepthFail;
  31219. private _cachedStencilReference;
  31220. /**
  31221. * Caches the the state of the stencil buffer
  31222. */
  31223. cacheStencilState(): void;
  31224. /**
  31225. * Restores the state of the stencil buffer
  31226. */
  31227. restoreStencilState(): void;
  31228. /**
  31229. * Sets the current depth function to LEQUAL
  31230. */
  31231. setDepthFunctionToLessOrEqual(): void;
  31232. /**
  31233. * Gets a boolean indicating if stencil buffer is enabled
  31234. * @returns the current stencil buffer state
  31235. */
  31236. getStencilBuffer(): boolean;
  31237. /**
  31238. * Enable or disable the stencil buffer
  31239. * @param enable defines if the stencil buffer must be enabled or disabled
  31240. */
  31241. setStencilBuffer(enable: boolean): void;
  31242. /**
  31243. * Gets the current stencil mask
  31244. * @returns a number defining the new stencil mask to use
  31245. */
  31246. getStencilMask(): number;
  31247. /**
  31248. * Sets the current stencil mask
  31249. * @param mask defines the new stencil mask to use
  31250. */
  31251. setStencilMask(mask: number): void;
  31252. /**
  31253. * Gets the current stencil function
  31254. * @returns a number defining the stencil function to use
  31255. */
  31256. getStencilFunction(): number;
  31257. /**
  31258. * Gets the current stencil reference value
  31259. * @returns a number defining the stencil reference value to use
  31260. */
  31261. getStencilFunctionReference(): number;
  31262. /**
  31263. * Gets the current stencil mask
  31264. * @returns a number defining the stencil mask to use
  31265. */
  31266. getStencilFunctionMask(): number;
  31267. /**
  31268. * Sets the current stencil function
  31269. * @param stencilFunc defines the new stencil function to use
  31270. */
  31271. setStencilFunction(stencilFunc: number): void;
  31272. /**
  31273. * Sets the current stencil reference
  31274. * @param reference defines the new stencil reference to use
  31275. */
  31276. setStencilFunctionReference(reference: number): void;
  31277. /**
  31278. * Sets the current stencil mask
  31279. * @param mask defines the new stencil mask to use
  31280. */
  31281. setStencilFunctionMask(mask: number): void;
  31282. /**
  31283. * Gets the current stencil operation when stencil fails
  31284. * @returns a number defining stencil operation to use when stencil fails
  31285. */
  31286. getStencilOperationFail(): number;
  31287. /**
  31288. * Gets the current stencil operation when depth fails
  31289. * @returns a number defining stencil operation to use when depth fails
  31290. */
  31291. getStencilOperationDepthFail(): number;
  31292. /**
  31293. * Gets the current stencil operation when stencil passes
  31294. * @returns a number defining stencil operation to use when stencil passes
  31295. */
  31296. getStencilOperationPass(): number;
  31297. /**
  31298. * Sets the stencil operation to use when stencil fails
  31299. * @param operation defines the stencil operation to use when stencil fails
  31300. */
  31301. setStencilOperationFail(operation: number): void;
  31302. /**
  31303. * Sets the stencil operation to use when depth fails
  31304. * @param operation defines the stencil operation to use when depth fails
  31305. */
  31306. setStencilOperationDepthFail(operation: number): void;
  31307. /**
  31308. * Sets the stencil operation to use when stencil passes
  31309. * @param operation defines the stencil operation to use when stencil passes
  31310. */
  31311. setStencilOperationPass(operation: number): void;
  31312. /**
  31313. * Sets a boolean indicating if the dithering state is enabled or disabled
  31314. * @param value defines the dithering state
  31315. */
  31316. setDitheringState(value: boolean): void;
  31317. /**
  31318. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31319. * @param value defines the rasterizer state
  31320. */
  31321. setRasterizerState(value: boolean): void;
  31322. /**
  31323. * stop executing a render loop function and remove it from the execution array
  31324. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31325. */
  31326. stopRenderLoop(renderFunction?: () => void): void;
  31327. /** @hidden */
  31328. _renderLoop(): void;
  31329. /**
  31330. * Register and execute a render loop. The engine can have more than one render function
  31331. * @param renderFunction defines the function to continuously execute
  31332. */
  31333. runRenderLoop(renderFunction: () => void): void;
  31334. /**
  31335. * Toggle full screen mode
  31336. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31337. */
  31338. switchFullscreen(requestPointerLock: boolean): void;
  31339. /**
  31340. * Enters full screen mode
  31341. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31342. */
  31343. enterFullscreen(requestPointerLock: boolean): void;
  31344. /**
  31345. * Exits full screen mode
  31346. */
  31347. exitFullscreen(): void;
  31348. /**
  31349. * Enters Pointerlock mode
  31350. */
  31351. enterPointerlock(): void;
  31352. /**
  31353. * Exits Pointerlock mode
  31354. */
  31355. exitPointerlock(): void;
  31356. /**
  31357. * Clear the current render buffer or the current render target (if any is set up)
  31358. * @param color defines the color to use
  31359. * @param backBuffer defines if the back buffer must be cleared
  31360. * @param depth defines if the depth buffer must be cleared
  31361. * @param stencil defines if the stencil buffer must be cleared
  31362. */
  31363. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31364. /**
  31365. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31366. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31367. * @param y defines the y-coordinate of the corner of the clear rectangle
  31368. * @param width defines the width of the clear rectangle
  31369. * @param height defines the height of the clear rectangle
  31370. * @param clearColor defines the clear color
  31371. */
  31372. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31373. /**
  31374. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31375. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31376. * @param y defines the y-coordinate of the corner of the clear rectangle
  31377. * @param width defines the width of the clear rectangle
  31378. * @param height defines the height of the clear rectangle
  31379. */
  31380. enableScissor(x: number, y: number, width: number, height: number): void;
  31381. /**
  31382. * Disable previously set scissor test rectangle
  31383. */
  31384. disableScissor(): void;
  31385. private _viewportCached;
  31386. /** @hidden */
  31387. _viewport(x: number, y: number, width: number, height: number): void;
  31388. /**
  31389. * Set the WebGL's viewport
  31390. * @param viewport defines the viewport element to be used
  31391. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31392. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31393. */
  31394. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31395. /**
  31396. * Directly set the WebGL Viewport
  31397. * @param x defines the x coordinate of the viewport (in screen space)
  31398. * @param y defines the y coordinate of the viewport (in screen space)
  31399. * @param width defines the width of the viewport (in screen space)
  31400. * @param height defines the height of the viewport (in screen space)
  31401. * @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
  31402. */
  31403. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31404. /**
  31405. * Begin a new frame
  31406. */
  31407. beginFrame(): void;
  31408. /**
  31409. * Enf the current frame
  31410. */
  31411. endFrame(): void;
  31412. /**
  31413. * Resize the view according to the canvas' size
  31414. */
  31415. resize(): void;
  31416. /**
  31417. * Force a specific size of the canvas
  31418. * @param width defines the new canvas' width
  31419. * @param height defines the new canvas' height
  31420. */
  31421. setSize(width: number, height: number): void;
  31422. /**
  31423. * Binds the frame buffer to the specified texture.
  31424. * @param texture The texture to render to or null for the default canvas
  31425. * @param faceIndex The face of the texture to render to in case of cube texture
  31426. * @param requiredWidth The width of the target to render to
  31427. * @param requiredHeight The height of the target to render to
  31428. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31429. * @param depthStencilTexture The depth stencil texture to use to render
  31430. * @param lodLevel defines le lod level to bind to the frame buffer
  31431. */
  31432. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31433. /** @hidden */
  31434. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31435. /**
  31436. * Unbind the current render target texture from the webGL context
  31437. * @param texture defines the render target texture to unbind
  31438. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31439. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31440. */
  31441. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31442. /**
  31443. * Force the mipmap generation for the given render target texture
  31444. * @param texture defines the render target texture to use
  31445. */
  31446. generateMipMapsForCubemap(texture: InternalTexture): void;
  31447. /**
  31448. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31449. */
  31450. flushFramebuffer(): void;
  31451. /**
  31452. * Unbind the current render target and bind the default framebuffer
  31453. */
  31454. restoreDefaultFramebuffer(): void;
  31455. /**
  31456. * Create an uniform buffer
  31457. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31458. * @param elements defines the content of the uniform buffer
  31459. * @returns the webGL uniform buffer
  31460. */
  31461. createUniformBuffer(elements: FloatArray): DataBuffer;
  31462. /**
  31463. * Create a dynamic uniform buffer
  31464. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31465. * @param elements defines the content of the uniform buffer
  31466. * @returns the webGL uniform buffer
  31467. */
  31468. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31469. /**
  31470. * Update an existing uniform buffer
  31471. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31472. * @param uniformBuffer defines the target uniform buffer
  31473. * @param elements defines the content to update
  31474. * @param offset defines the offset in the uniform buffer where update should start
  31475. * @param count defines the size of the data to update
  31476. */
  31477. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31478. private _resetVertexBufferBinding;
  31479. /**
  31480. * Creates a vertex buffer
  31481. * @param data the data for the vertex buffer
  31482. * @returns the new WebGL static buffer
  31483. */
  31484. createVertexBuffer(data: DataArray): DataBuffer;
  31485. /**
  31486. * Creates a dynamic vertex buffer
  31487. * @param data the data for the dynamic vertex buffer
  31488. * @returns the new WebGL dynamic buffer
  31489. */
  31490. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31491. /**
  31492. * Update a dynamic index buffer
  31493. * @param indexBuffer defines the target index buffer
  31494. * @param indices defines the data to update
  31495. * @param offset defines the offset in the target index buffer where update should start
  31496. */
  31497. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31498. /**
  31499. * Updates a dynamic vertex buffer.
  31500. * @param vertexBuffer the vertex buffer to update
  31501. * @param data the data used to update the vertex buffer
  31502. * @param byteOffset the byte offset of the data
  31503. * @param byteLength the byte length of the data
  31504. */
  31505. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31506. private _resetIndexBufferBinding;
  31507. /**
  31508. * Creates a new index buffer
  31509. * @param indices defines the content of the index buffer
  31510. * @param updatable defines if the index buffer must be updatable
  31511. * @returns a new webGL buffer
  31512. */
  31513. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31514. /**
  31515. * Bind a webGL buffer to the webGL context
  31516. * @param buffer defines the buffer to bind
  31517. */
  31518. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31519. /**
  31520. * Bind an uniform buffer to the current webGL context
  31521. * @param buffer defines the buffer to bind
  31522. */
  31523. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31524. /**
  31525. * Bind a buffer to the current webGL context at a given location
  31526. * @param buffer defines the buffer to bind
  31527. * @param location defines the index where to bind the buffer
  31528. */
  31529. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31530. /**
  31531. * Bind a specific block at a given index in a specific shader program
  31532. * @param pipelineContext defines the pipeline context to use
  31533. * @param blockName defines the block name
  31534. * @param index defines the index where to bind the block
  31535. */
  31536. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31537. private bindIndexBuffer;
  31538. private bindBuffer;
  31539. /**
  31540. * update the bound buffer with the given data
  31541. * @param data defines the data to update
  31542. */
  31543. updateArrayBuffer(data: Float32Array): void;
  31544. private _vertexAttribPointer;
  31545. private _bindIndexBufferWithCache;
  31546. private _bindVertexBuffersAttributes;
  31547. /**
  31548. * Records a vertex array object
  31549. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31550. * @param vertexBuffers defines the list of vertex buffers to store
  31551. * @param indexBuffer defines the index buffer to store
  31552. * @param effect defines the effect to store
  31553. * @returns the new vertex array object
  31554. */
  31555. recordVertexArrayObject(vertexBuffers: {
  31556. [key: string]: VertexBuffer;
  31557. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31558. /**
  31559. * Bind a specific vertex array object
  31560. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31561. * @param vertexArrayObject defines the vertex array object to bind
  31562. * @param indexBuffer defines the index buffer to bind
  31563. */
  31564. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31565. /**
  31566. * Bind webGl buffers directly to the webGL context
  31567. * @param vertexBuffer defines the vertex buffer to bind
  31568. * @param indexBuffer defines the index buffer to bind
  31569. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31570. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31571. * @param effect defines the effect associated with the vertex buffer
  31572. */
  31573. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31574. private _unbindVertexArrayObject;
  31575. /**
  31576. * Bind a list of vertex buffers to the webGL context
  31577. * @param vertexBuffers defines the list of vertex buffers to bind
  31578. * @param indexBuffer defines the index buffer to bind
  31579. * @param effect defines the effect associated with the vertex buffers
  31580. */
  31581. bindBuffers(vertexBuffers: {
  31582. [key: string]: Nullable<VertexBuffer>;
  31583. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31584. /**
  31585. * Unbind all instance attributes
  31586. */
  31587. unbindInstanceAttributes(): void;
  31588. /**
  31589. * Release and free the memory of a vertex array object
  31590. * @param vao defines the vertex array object to delete
  31591. */
  31592. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31593. /** @hidden */
  31594. _releaseBuffer(buffer: DataBuffer): boolean;
  31595. /**
  31596. * Creates a webGL buffer to use with instanciation
  31597. * @param capacity defines the size of the buffer
  31598. * @returns the webGL buffer
  31599. */
  31600. createInstancesBuffer(capacity: number): DataBuffer;
  31601. /**
  31602. * Delete a webGL buffer used with instanciation
  31603. * @param buffer defines the webGL buffer to delete
  31604. */
  31605. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31606. /**
  31607. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31608. * @param instancesBuffer defines the webGL buffer to update and bind
  31609. * @param data defines the data to store in the buffer
  31610. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31611. */
  31612. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31613. /**
  31614. * Apply all cached states (depth, culling, stencil and alpha)
  31615. */
  31616. applyStates(): void;
  31617. /**
  31618. * Send a draw order
  31619. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31620. * @param indexStart defines the starting index
  31621. * @param indexCount defines the number of index to draw
  31622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31623. */
  31624. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31625. /**
  31626. * Draw a list of points
  31627. * @param verticesStart defines the index of first vertex to draw
  31628. * @param verticesCount defines the count of vertices to draw
  31629. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31630. */
  31631. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31632. /**
  31633. * Draw a list of unindexed primitives
  31634. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31635. * @param verticesStart defines the index of first vertex to draw
  31636. * @param verticesCount defines the count of vertices to draw
  31637. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31638. */
  31639. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31640. /**
  31641. * Draw a list of indexed primitives
  31642. * @param fillMode defines the primitive to use
  31643. * @param indexStart defines the starting index
  31644. * @param indexCount defines the number of index to draw
  31645. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31646. */
  31647. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31648. /**
  31649. * Draw a list of unindexed primitives
  31650. * @param fillMode defines the primitive to use
  31651. * @param verticesStart defines the index of first vertex to draw
  31652. * @param verticesCount defines the count of vertices to draw
  31653. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31654. */
  31655. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31656. private _drawMode;
  31657. /** @hidden */
  31658. _releaseEffect(effect: Effect): void;
  31659. /** @hidden */
  31660. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31661. /**
  31662. * Create a new effect (used to store vertex/fragment shaders)
  31663. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31664. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31665. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31666. * @param samplers defines an array of string used to represent textures
  31667. * @param defines defines the string containing the defines to use to compile the shaders
  31668. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31669. * @param onCompiled defines a function to call when the effect creation is successful
  31670. * @param onError defines a function to call when the effect creation has failed
  31671. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31672. * @returns the new Effect
  31673. */
  31674. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31675. private _compileShader;
  31676. private _compileRawShader;
  31677. /**
  31678. * Directly creates a webGL program
  31679. * @param pipelineContext defines the pipeline context to attach to
  31680. * @param vertexCode defines the vertex shader code to use
  31681. * @param fragmentCode defines the fragment shader code to use
  31682. * @param context defines the webGL context to use (if not set, the current one will be used)
  31683. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31684. * @returns the new webGL program
  31685. */
  31686. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31687. /**
  31688. * Creates a webGL program
  31689. * @param pipelineContext defines the pipeline context to attach to
  31690. * @param vertexCode defines the vertex shader code to use
  31691. * @param fragmentCode defines the fragment shader code to use
  31692. * @param defines defines the string containing the defines to use to compile the shaders
  31693. * @param context defines the webGL context to use (if not set, the current one will be used)
  31694. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31695. * @returns the new webGL program
  31696. */
  31697. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31698. /**
  31699. * Creates a new pipeline context
  31700. * @returns the new pipeline
  31701. */
  31702. createPipelineContext(): WebGLPipelineContext;
  31703. private _createShaderProgram;
  31704. private _finalizePipelineContext;
  31705. /** @hidden */
  31706. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31707. /** @hidden */
  31708. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31709. /** @hidden */
  31710. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31711. /**
  31712. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31713. * @param pipelineContext defines the pipeline context to use
  31714. * @param uniformsNames defines the list of uniform names
  31715. * @returns an array of webGL uniform locations
  31716. */
  31717. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31718. /**
  31719. * Gets the lsit of active attributes for a given webGL program
  31720. * @param pipelineContext defines the pipeline context to use
  31721. * @param attributesNames defines the list of attribute names to get
  31722. * @returns an array of indices indicating the offset of each attribute
  31723. */
  31724. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31725. /**
  31726. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31727. * @param effect defines the effect to activate
  31728. */
  31729. enableEffect(effect: Nullable<Effect>): void;
  31730. /**
  31731. * Set the value of an uniform to an array of int32
  31732. * @param uniform defines the webGL uniform location where to store the value
  31733. * @param array defines the array of int32 to store
  31734. */
  31735. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31736. /**
  31737. * Set the value of an uniform to an array of int32 (stored as vec2)
  31738. * @param uniform defines the webGL uniform location where to store the value
  31739. * @param array defines the array of int32 to store
  31740. */
  31741. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31742. /**
  31743. * Set the value of an uniform to an array of int32 (stored as vec3)
  31744. * @param uniform defines the webGL uniform location where to store the value
  31745. * @param array defines the array of int32 to store
  31746. */
  31747. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31748. /**
  31749. * Set the value of an uniform to an array of int32 (stored as vec4)
  31750. * @param uniform defines the webGL uniform location where to store the value
  31751. * @param array defines the array of int32 to store
  31752. */
  31753. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31754. /**
  31755. * Set the value of an uniform to an array of float32
  31756. * @param uniform defines the webGL uniform location where to store the value
  31757. * @param array defines the array of float32 to store
  31758. */
  31759. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31760. /**
  31761. * Set the value of an uniform to an array of float32 (stored as vec2)
  31762. * @param uniform defines the webGL uniform location where to store the value
  31763. * @param array defines the array of float32 to store
  31764. */
  31765. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31766. /**
  31767. * Set the value of an uniform to an array of float32 (stored as vec3)
  31768. * @param uniform defines the webGL uniform location where to store the value
  31769. * @param array defines the array of float32 to store
  31770. */
  31771. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31772. /**
  31773. * Set the value of an uniform to an array of float32 (stored as vec4)
  31774. * @param uniform defines the webGL uniform location where to store the value
  31775. * @param array defines the array of float32 to store
  31776. */
  31777. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31778. /**
  31779. * Set the value of an uniform to an array of number
  31780. * @param uniform defines the webGL uniform location where to store the value
  31781. * @param array defines the array of number to store
  31782. */
  31783. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31784. /**
  31785. * Set the value of an uniform to an array of number (stored as vec2)
  31786. * @param uniform defines the webGL uniform location where to store the value
  31787. * @param array defines the array of number to store
  31788. */
  31789. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31790. /**
  31791. * Set the value of an uniform to an array of number (stored as vec3)
  31792. * @param uniform defines the webGL uniform location where to store the value
  31793. * @param array defines the array of number to store
  31794. */
  31795. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31796. /**
  31797. * Set the value of an uniform to an array of number (stored as vec4)
  31798. * @param uniform defines the webGL uniform location where to store the value
  31799. * @param array defines the array of number to store
  31800. */
  31801. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31802. /**
  31803. * Set the value of an uniform to an array of float32 (stored as matrices)
  31804. * @param uniform defines the webGL uniform location where to store the value
  31805. * @param matrices defines the array of float32 to store
  31806. */
  31807. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31808. /**
  31809. * Set the value of an uniform to a matrix (3x3)
  31810. * @param uniform defines the webGL uniform location where to store the value
  31811. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31812. */
  31813. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31814. /**
  31815. * Set the value of an uniform to a matrix (2x2)
  31816. * @param uniform defines the webGL uniform location where to store the value
  31817. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31818. */
  31819. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31820. /**
  31821. * Set the value of an uniform to a number (int)
  31822. * @param uniform defines the webGL uniform location where to store the value
  31823. * @param value defines the int number to store
  31824. */
  31825. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31826. /**
  31827. * Set the value of an uniform to a number (float)
  31828. * @param uniform defines the webGL uniform location where to store the value
  31829. * @param value defines the float number to store
  31830. */
  31831. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31832. /**
  31833. * Set the value of an uniform to a vec2
  31834. * @param uniform defines the webGL uniform location where to store the value
  31835. * @param x defines the 1st component of the value
  31836. * @param y defines the 2nd component of the value
  31837. */
  31838. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31839. /**
  31840. * Set the value of an uniform to a vec3
  31841. * @param uniform defines the webGL uniform location where to store the value
  31842. * @param x defines the 1st component of the value
  31843. * @param y defines the 2nd component of the value
  31844. * @param z defines the 3rd component of the value
  31845. */
  31846. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31847. /**
  31848. * Set the value of an uniform to a boolean
  31849. * @param uniform defines the webGL uniform location where to store the value
  31850. * @param bool defines the boolean to store
  31851. */
  31852. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31853. /**
  31854. * Set the value of an uniform to a vec4
  31855. * @param uniform defines the webGL uniform location where to store the value
  31856. * @param x defines the 1st component of the value
  31857. * @param y defines the 2nd component of the value
  31858. * @param z defines the 3rd component of the value
  31859. * @param w defines the 4th component of the value
  31860. */
  31861. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31862. /**
  31863. * Sets a Color4 on a uniform variable
  31864. * @param uniform defines the uniform location
  31865. * @param color4 defines the value to be set
  31866. */
  31867. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31868. /**
  31869. * Set various states to the webGL context
  31870. * @param culling defines backface culling state
  31871. * @param zOffset defines the value to apply to zOffset (0 by default)
  31872. * @param force defines if states must be applied even if cache is up to date
  31873. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31874. */
  31875. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31876. /**
  31877. * Set the z offset to apply to current rendering
  31878. * @param value defines the offset to apply
  31879. */
  31880. setZOffset(value: number): void;
  31881. /**
  31882. * Gets the current value of the zOffset
  31883. * @returns the current zOffset state
  31884. */
  31885. getZOffset(): number;
  31886. /**
  31887. * Enable or disable depth buffering
  31888. * @param enable defines the state to set
  31889. */
  31890. setDepthBuffer(enable: boolean): void;
  31891. /**
  31892. * Gets a boolean indicating if depth writing is enabled
  31893. * @returns the current depth writing state
  31894. */
  31895. getDepthWrite(): boolean;
  31896. /**
  31897. * Enable or disable depth writing
  31898. * @param enable defines the state to set
  31899. */
  31900. setDepthWrite(enable: boolean): void;
  31901. /**
  31902. * Enable or disable color writing
  31903. * @param enable defines the state to set
  31904. */
  31905. setColorWrite(enable: boolean): void;
  31906. /**
  31907. * Gets a boolean indicating if color writing is enabled
  31908. * @returns the current color writing state
  31909. */
  31910. getColorWrite(): boolean;
  31911. /**
  31912. * Sets alpha constants used by some alpha blending modes
  31913. * @param r defines the red component
  31914. * @param g defines the green component
  31915. * @param b defines the blue component
  31916. * @param a defines the alpha component
  31917. */
  31918. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31919. /**
  31920. * Sets the current alpha mode
  31921. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31922. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31923. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31924. */
  31925. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31926. /**
  31927. * Gets the current alpha mode
  31928. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31929. * @returns the current alpha mode
  31930. */
  31931. getAlphaMode(): number;
  31932. /**
  31933. * Clears the list of texture accessible through engine.
  31934. * This can help preventing texture load conflict due to name collision.
  31935. */
  31936. clearInternalTexturesCache(): void;
  31937. /**
  31938. * Force the entire cache to be cleared
  31939. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31940. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31941. */
  31942. wipeCaches(bruteForce?: boolean): void;
  31943. /**
  31944. * Set the compressed texture format to use, based on the formats you have, and the formats
  31945. * supported by the hardware / browser.
  31946. *
  31947. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31948. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31949. * to API arguments needed to compressed textures. This puts the burden on the container
  31950. * generator to house the arcane code for determining these for current & future formats.
  31951. *
  31952. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31953. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31954. *
  31955. * Note: The result of this call is not taken into account when a texture is base64.
  31956. *
  31957. * @param formatsAvailable defines the list of those format families you have created
  31958. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31959. *
  31960. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31961. * @returns The extension selected.
  31962. */
  31963. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31964. /** @hidden */
  31965. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31966. min: number;
  31967. mag: number;
  31968. };
  31969. /** @hidden */
  31970. _createTexture(): WebGLTexture;
  31971. /**
  31972. * Usually called from Texture.ts.
  31973. * Passed information to create a WebGLTexture
  31974. * @param urlArg defines a value which contains one of the following:
  31975. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31976. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31977. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31978. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31979. * @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)
  31980. * @param scene needed for loading to the correct scene
  31981. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31982. * @param onLoad optional callback to be called upon successful completion
  31983. * @param onError optional callback to be called upon failure
  31984. * @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
  31985. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31986. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31987. * @param forcedExtension defines the extension to use to pick the right loader
  31988. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31989. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31990. */
  31991. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31992. /**
  31993. * @hidden
  31994. * Rescales a texture
  31995. * @param source input texutre
  31996. * @param destination destination texture
  31997. * @param scene scene to use to render the resize
  31998. * @param internalFormat format to use when resizing
  31999. * @param onComplete callback to be called when resize has completed
  32000. */
  32001. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32002. private _unpackFlipYCached;
  32003. /**
  32004. * In case you are sharing the context with other applications, it might
  32005. * be interested to not cache the unpack flip y state to ensure a consistent
  32006. * value would be set.
  32007. */
  32008. enableUnpackFlipYCached: boolean;
  32009. /** @hidden */
  32010. _unpackFlipY(value: boolean): void;
  32011. /** @hidden */
  32012. _getUnpackAlignement(): number;
  32013. /**
  32014. * Creates a dynamic texture
  32015. * @param width defines the width of the texture
  32016. * @param height defines the height of the texture
  32017. * @param generateMipMaps defines if the engine should generate the mip levels
  32018. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32019. * @returns the dynamic texture inside an InternalTexture
  32020. */
  32021. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32022. /**
  32023. * Update the sampling mode of a given texture
  32024. * @param samplingMode defines the required sampling mode
  32025. * @param texture defines the texture to update
  32026. */
  32027. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32028. /**
  32029. * Update the content of a dynamic texture
  32030. * @param texture defines the texture to update
  32031. * @param canvas defines the canvas containing the source
  32032. * @param invertY defines if data must be stored with Y axis inverted
  32033. * @param premulAlpha defines if alpha is stored as premultiplied
  32034. * @param format defines the format of the data
  32035. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32036. */
  32037. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32038. /**
  32039. * Update a video texture
  32040. * @param texture defines the texture to update
  32041. * @param video defines the video element to use
  32042. * @param invertY defines if data must be stored with Y axis inverted
  32043. */
  32044. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32045. /**
  32046. * Updates a depth texture Comparison Mode and Function.
  32047. * If the comparison Function is equal to 0, the mode will be set to none.
  32048. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32049. * @param texture The texture to set the comparison function for
  32050. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32051. */
  32052. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32053. /** @hidden */
  32054. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32055. width: number;
  32056. height: number;
  32057. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32058. /**
  32059. * Creates a depth stencil texture.
  32060. * This is only available in WebGL 2 or with the depth texture extension available.
  32061. * @param size The size of face edge in the texture.
  32062. * @param options The options defining the texture.
  32063. * @returns The texture
  32064. */
  32065. createDepthStencilTexture(size: number | {
  32066. width: number;
  32067. height: number;
  32068. }, options: DepthTextureCreationOptions): InternalTexture;
  32069. /**
  32070. * Creates a depth stencil texture.
  32071. * This is only available in WebGL 2 or with the depth texture extension available.
  32072. * @param size The size of face edge in the texture.
  32073. * @param options The options defining the texture.
  32074. * @returns The texture
  32075. */
  32076. private _createDepthStencilTexture;
  32077. /**
  32078. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32079. * @param renderTarget The render target to set the frame buffer for
  32080. */
  32081. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32082. /**
  32083. * Creates a new render target texture
  32084. * @param size defines the size of the texture
  32085. * @param options defines the options used to create the texture
  32086. * @returns a new render target texture stored in an InternalTexture
  32087. */
  32088. createRenderTargetTexture(size: number | {
  32089. width: number;
  32090. height: number;
  32091. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32092. /** @hidden */
  32093. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32094. /**
  32095. * Updates the sample count of a render target texture
  32096. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32097. * @param texture defines the texture to update
  32098. * @param samples defines the sample count to set
  32099. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32100. */
  32101. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32102. /** @hidden */
  32103. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32104. /** @hidden */
  32105. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32106. /** @hidden */
  32107. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32108. /** @hidden */
  32109. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32110. /**
  32111. * @hidden
  32112. */
  32113. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32114. private _prepareWebGLTextureContinuation;
  32115. private _prepareWebGLTexture;
  32116. /** @hidden */
  32117. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32118. /** @hidden */
  32119. _releaseFramebufferObjects(texture: InternalTexture): void;
  32120. /** @hidden */
  32121. _releaseTexture(texture: InternalTexture): void;
  32122. private setProgram;
  32123. private _boundUniforms;
  32124. /**
  32125. * Binds an effect to the webGL context
  32126. * @param effect defines the effect to bind
  32127. */
  32128. bindSamplers(effect: Effect): void;
  32129. private _activateCurrentTexture;
  32130. /** @hidden */
  32131. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32132. /** @hidden */
  32133. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32134. /**
  32135. * Sets a texture to the webGL context from a postprocess
  32136. * @param channel defines the channel to use
  32137. * @param postProcess defines the source postprocess
  32138. */
  32139. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32140. /**
  32141. * Binds the output of the passed in post process to the texture channel specified
  32142. * @param channel The channel the texture should be bound to
  32143. * @param postProcess The post process which's output should be bound
  32144. */
  32145. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32146. /**
  32147. * Unbind all textures from the webGL context
  32148. */
  32149. unbindAllTextures(): void;
  32150. /**
  32151. * Sets a texture to the according uniform.
  32152. * @param channel The texture channel
  32153. * @param uniform The uniform to set
  32154. * @param texture The texture to apply
  32155. */
  32156. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32157. /**
  32158. * Sets a depth stencil texture from a render target to the according uniform.
  32159. * @param channel The texture channel
  32160. * @param uniform The uniform to set
  32161. * @param texture The render target texture containing the depth stencil texture to apply
  32162. */
  32163. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32164. private _bindSamplerUniformToChannel;
  32165. private _getTextureWrapMode;
  32166. private _setTexture;
  32167. /**
  32168. * Sets an array of texture to the webGL context
  32169. * @param channel defines the channel where the texture array must be set
  32170. * @param uniform defines the associated uniform location
  32171. * @param textures defines the array of textures to bind
  32172. */
  32173. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32174. /** @hidden */
  32175. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32176. private _setTextureParameterFloat;
  32177. private _setTextureParameterInteger;
  32178. /**
  32179. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32180. * @param x defines the x coordinate of the rectangle where pixels must be read
  32181. * @param y defines the y coordinate of the rectangle where pixels must be read
  32182. * @param width defines the width of the rectangle where pixels must be read
  32183. * @param height defines the height of the rectangle where pixels must be read
  32184. * @returns a Uint8Array containing RGBA colors
  32185. */
  32186. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32187. /**
  32188. * Add an externaly attached data from its key.
  32189. * This method call will fail and return false, if such key already exists.
  32190. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32191. * @param key the unique key that identifies the data
  32192. * @param data the data object to associate to the key for this Engine instance
  32193. * @return true if no such key were already present and the data was added successfully, false otherwise
  32194. */
  32195. addExternalData<T>(key: string, data: T): boolean;
  32196. /**
  32197. * Get an externaly attached data from its key
  32198. * @param key the unique key that identifies the data
  32199. * @return the associated data, if present (can be null), or undefined if not present
  32200. */
  32201. getExternalData<T>(key: string): T;
  32202. /**
  32203. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32204. * @param key the unique key that identifies the data
  32205. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32206. * @return the associated data, can be null if the factory returned null.
  32207. */
  32208. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32209. /**
  32210. * Remove an externaly attached data from the Engine instance
  32211. * @param key the unique key that identifies the data
  32212. * @return true if the data was successfully removed, false if it doesn't exist
  32213. */
  32214. removeExternalData(key: string): boolean;
  32215. /**
  32216. * Unbind all vertex attributes from the webGL context
  32217. */
  32218. unbindAllAttributes(): void;
  32219. /**
  32220. * 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
  32221. */
  32222. releaseEffects(): void;
  32223. /**
  32224. * Dispose and release all associated resources
  32225. */
  32226. dispose(): void;
  32227. /**
  32228. * Display the loading screen
  32229. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32230. */
  32231. displayLoadingUI(): void;
  32232. /**
  32233. * Hide the loading screen
  32234. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32235. */
  32236. hideLoadingUI(): void;
  32237. /**
  32238. * Gets the current loading screen object
  32239. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32240. */
  32241. /**
  32242. * Sets the current loading screen object
  32243. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32244. */
  32245. loadingScreen: ILoadingScreen;
  32246. /**
  32247. * Sets the current loading screen text
  32248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32249. */
  32250. loadingUIText: string;
  32251. /**
  32252. * Sets the current loading screen background color
  32253. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32254. */
  32255. loadingUIBackgroundColor: string;
  32256. /**
  32257. * Attach a new callback raised when context lost event is fired
  32258. * @param callback defines the callback to call
  32259. */
  32260. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32261. /**
  32262. * Attach a new callback raised when context restored event is fired
  32263. * @param callback defines the callback to call
  32264. */
  32265. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32266. /**
  32267. * Gets the source code of the vertex shader associated with a specific webGL program
  32268. * @param program defines the program to use
  32269. * @returns a string containing the source code of the vertex shader associated with the program
  32270. */
  32271. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32272. /**
  32273. * Gets the source code of the fragment shader associated with a specific webGL program
  32274. * @param program defines the program to use
  32275. * @returns a string containing the source code of the fragment shader associated with the program
  32276. */
  32277. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32278. /**
  32279. * Get the current error code of the webGL context
  32280. * @returns the error code
  32281. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32282. */
  32283. getError(): number;
  32284. /**
  32285. * Gets the current framerate
  32286. * @returns a number representing the framerate
  32287. */
  32288. getFps(): number;
  32289. /**
  32290. * Gets the time spent between current and previous frame
  32291. * @returns a number representing the delta time in ms
  32292. */
  32293. getDeltaTime(): number;
  32294. private _measureFps;
  32295. /** @hidden */
  32296. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32297. private _canRenderToFloatFramebuffer;
  32298. private _canRenderToHalfFloatFramebuffer;
  32299. private _canRenderToFramebuffer;
  32300. /** @hidden */
  32301. _getWebGLTextureType(type: number): number;
  32302. /** @hidden */
  32303. _getInternalFormat(format: number): number;
  32304. /** @hidden */
  32305. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32306. /** @hidden */
  32307. _getRGBAMultiSampleBufferFormat(type: number): number;
  32308. /** @hidden */
  32309. _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;
  32310. /** @hidden */
  32311. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32312. /**
  32313. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32314. * @returns true if the engine can be created
  32315. * @ignorenaming
  32316. */
  32317. static isSupported(): boolean;
  32318. /**
  32319. * Find the next highest power of two.
  32320. * @param x Number to start search from.
  32321. * @return Next highest power of two.
  32322. */
  32323. static CeilingPOT(x: number): number;
  32324. /**
  32325. * Find the next lowest power of two.
  32326. * @param x Number to start search from.
  32327. * @return Next lowest power of two.
  32328. */
  32329. static FloorPOT(x: number): number;
  32330. /**
  32331. * Find the nearest power of two.
  32332. * @param x Number to start search from.
  32333. * @return Next nearest power of two.
  32334. */
  32335. static NearestPOT(x: number): number;
  32336. /**
  32337. * Get the closest exponent of two
  32338. * @param value defines the value to approximate
  32339. * @param max defines the maximum value to return
  32340. * @param mode defines how to define the closest value
  32341. * @returns closest exponent of two of the given value
  32342. */
  32343. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32344. /**
  32345. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32346. * @param func - the function to be called
  32347. * @param requester - the object that will request the next frame. Falls back to window.
  32348. * @returns frame number
  32349. */
  32350. static QueueNewFrame(func: () => void, requester?: any): number;
  32351. /**
  32352. * Ask the browser to promote the current element to pointerlock mode
  32353. * @param element defines the DOM element to promote
  32354. */
  32355. static _RequestPointerlock(element: HTMLElement): void;
  32356. /**
  32357. * Asks the browser to exit pointerlock mode
  32358. */
  32359. static _ExitPointerlock(): void;
  32360. /**
  32361. * Ask the browser to promote the current element to fullscreen rendering mode
  32362. * @param element defines the DOM element to promote
  32363. */
  32364. static _RequestFullscreen(element: HTMLElement): void;
  32365. /**
  32366. * Asks the browser to exit fullscreen mode
  32367. */
  32368. static _ExitFullscreen(): void;
  32369. }
  32370. }
  32371. declare module "babylonjs/Engines/engineStore" {
  32372. import { Nullable } from "babylonjs/types";
  32373. import { Engine } from "babylonjs/Engines/engine";
  32374. import { Scene } from "babylonjs/scene";
  32375. /**
  32376. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32377. * during the life time of the application.
  32378. */
  32379. export class EngineStore {
  32380. /** Gets the list of created engines */
  32381. static Instances: import("babylonjs/Engines/engine").Engine[];
  32382. /** @hidden */
  32383. static _LastCreatedScene: Nullable<Scene>;
  32384. /**
  32385. * Gets the latest created engine
  32386. */
  32387. static readonly LastCreatedEngine: Nullable<Engine>;
  32388. /**
  32389. * Gets the latest created scene
  32390. */
  32391. static readonly LastCreatedScene: Nullable<Scene>;
  32392. /**
  32393. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32394. * @ignorenaming
  32395. */
  32396. static UseFallbackTexture: boolean;
  32397. /**
  32398. * Texture content used if a texture cannot loaded
  32399. * @ignorenaming
  32400. */
  32401. static FallbackTexture: string;
  32402. }
  32403. }
  32404. declare module "babylonjs/Misc/promise" {
  32405. /**
  32406. * Helper class that provides a small promise polyfill
  32407. */
  32408. export class PromisePolyfill {
  32409. /**
  32410. * Static function used to check if the polyfill is required
  32411. * If this is the case then the function will inject the polyfill to window.Promise
  32412. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32413. */
  32414. static Apply(force?: boolean): void;
  32415. }
  32416. }
  32417. declare module "babylonjs/Misc/tools" {
  32418. import { Nullable, float } from "babylonjs/types";
  32419. import { DomManagement } from "babylonjs/Misc/domManagement";
  32420. import { WebRequest } from "babylonjs/Misc/webRequest";
  32421. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32422. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32423. import { Camera } from "babylonjs/Cameras/camera";
  32424. import { Engine } from "babylonjs/Engines/engine";
  32425. interface IColor4Like {
  32426. r: float;
  32427. g: float;
  32428. b: float;
  32429. a: float;
  32430. }
  32431. /**
  32432. * Class containing a set of static utilities functions
  32433. */
  32434. export class Tools {
  32435. /**
  32436. * Gets or sets the base URL to use to load assets
  32437. */
  32438. static BaseUrl: string;
  32439. /**
  32440. * Enable/Disable Custom HTTP Request Headers globally.
  32441. * default = false
  32442. * @see CustomRequestHeaders
  32443. */
  32444. static UseCustomRequestHeaders: boolean;
  32445. /**
  32446. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32447. * i.e. when loading files, where the server/service expects an Authorization header
  32448. */
  32449. static CustomRequestHeaders: {
  32450. [key: string]: string;
  32451. };
  32452. /**
  32453. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32454. */
  32455. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32456. /**
  32457. * Default behaviour for cors in the application.
  32458. * It can be a string if the expected behavior is identical in the entire app.
  32459. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32460. */
  32461. static CorsBehavior: string | ((url: string | string[]) => string);
  32462. /**
  32463. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32464. * @ignorenaming
  32465. */
  32466. static UseFallbackTexture: boolean;
  32467. /**
  32468. * Use this object to register external classes like custom textures or material
  32469. * to allow the laoders to instantiate them
  32470. */
  32471. static RegisteredExternalClasses: {
  32472. [key: string]: Object;
  32473. };
  32474. /**
  32475. * Texture content used if a texture cannot loaded
  32476. * @ignorenaming
  32477. */
  32478. static fallbackTexture: string;
  32479. /**
  32480. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32481. * @param u defines the coordinate on X axis
  32482. * @param v defines the coordinate on Y axis
  32483. * @param width defines the width of the source data
  32484. * @param height defines the height of the source data
  32485. * @param pixels defines the source byte array
  32486. * @param color defines the output color
  32487. */
  32488. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32489. /**
  32490. * Interpolates between a and b via alpha
  32491. * @param a The lower value (returned when alpha = 0)
  32492. * @param b The upper value (returned when alpha = 1)
  32493. * @param alpha The interpolation-factor
  32494. * @return The mixed value
  32495. */
  32496. static Mix(a: number, b: number, alpha: number): number;
  32497. /**
  32498. * Tries to instantiate a new object from a given class name
  32499. * @param className defines the class name to instantiate
  32500. * @returns the new object or null if the system was not able to do the instantiation
  32501. */
  32502. static Instantiate(className: string): any;
  32503. /**
  32504. * Provides a slice function that will work even on IE
  32505. * @param data defines the array to slice
  32506. * @param start defines the start of the data (optional)
  32507. * @param end defines the end of the data (optional)
  32508. * @returns the new sliced array
  32509. */
  32510. static Slice<T>(data: T, start?: number, end?: number): T;
  32511. /**
  32512. * Polyfill for setImmediate
  32513. * @param action defines the action to execute after the current execution block
  32514. */
  32515. static SetImmediate(action: () => void): void;
  32516. /**
  32517. * Function indicating if a number is an exponent of 2
  32518. * @param value defines the value to test
  32519. * @returns true if the value is an exponent of 2
  32520. */
  32521. static IsExponentOfTwo(value: number): boolean;
  32522. private static _tmpFloatArray;
  32523. /**
  32524. * Returns the nearest 32-bit single precision float representation of a Number
  32525. * @param value A Number. If the parameter is of a different type, it will get converted
  32526. * to a number or to NaN if it cannot be converted
  32527. * @returns number
  32528. */
  32529. static FloatRound(value: number): number;
  32530. /**
  32531. * Extracts the filename from a path
  32532. * @param path defines the path to use
  32533. * @returns the filename
  32534. */
  32535. static GetFilename(path: string): string;
  32536. /**
  32537. * Extracts the "folder" part of a path (everything before the filename).
  32538. * @param uri The URI to extract the info from
  32539. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32540. * @returns The "folder" part of the path
  32541. */
  32542. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32543. /**
  32544. * Extracts text content from a DOM element hierarchy
  32545. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32546. */
  32547. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32548. /**
  32549. * Convert an angle in radians to degrees
  32550. * @param angle defines the angle to convert
  32551. * @returns the angle in degrees
  32552. */
  32553. static ToDegrees(angle: number): number;
  32554. /**
  32555. * Convert an angle in degrees to radians
  32556. * @param angle defines the angle to convert
  32557. * @returns the angle in radians
  32558. */
  32559. static ToRadians(angle: number): number;
  32560. /**
  32561. * Encode a buffer to a base64 string
  32562. * @param buffer defines the buffer to encode
  32563. * @returns the encoded string
  32564. */
  32565. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32566. /**
  32567. * Returns an array if obj is not an array
  32568. * @param obj defines the object to evaluate as an array
  32569. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32570. * @returns either obj directly if obj is an array or a new array containing obj
  32571. */
  32572. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32573. /**
  32574. * Gets the pointer prefix to use
  32575. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32576. */
  32577. static GetPointerPrefix(): string;
  32578. /**
  32579. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32580. * @param url define the url we are trying
  32581. * @param element define the dom element where to configure the cors policy
  32582. */
  32583. static SetCorsBehavior(url: string | string[], element: {
  32584. crossOrigin: string | null;
  32585. }): void;
  32586. /**
  32587. * Removes unwanted characters from an url
  32588. * @param url defines the url to clean
  32589. * @returns the cleaned url
  32590. */
  32591. static CleanUrl(url: string): string;
  32592. /**
  32593. * Gets or sets a function used to pre-process url before using them to load assets
  32594. */
  32595. static PreprocessUrl: (url: string) => string;
  32596. /**
  32597. * Loads an image as an HTMLImageElement.
  32598. * @param input url string, ArrayBuffer, or Blob to load
  32599. * @param onLoad callback called when the image successfully loads
  32600. * @param onError callback called when the image fails to load
  32601. * @param offlineProvider offline provider for caching
  32602. * @returns the HTMLImageElement of the loaded image
  32603. */
  32604. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32605. /**
  32606. * Loads a file
  32607. * @param url url string, ArrayBuffer, or Blob to load
  32608. * @param onSuccess callback called when the file successfully loads
  32609. * @param onProgress callback called while file is loading (if the server supports this mode)
  32610. * @param offlineProvider defines the offline provider for caching
  32611. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32612. * @param onError callback called when the file fails to load
  32613. * @returns a file request object
  32614. */
  32615. 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;
  32616. /**
  32617. * Loads a file from a url
  32618. * @param url the file url to load
  32619. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32620. */
  32621. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32622. /**
  32623. * Load a script (identified by an url). When the url returns, the
  32624. * content of this file is added into a new script element, attached to the DOM (body element)
  32625. * @param scriptUrl defines the url of the script to laod
  32626. * @param onSuccess defines the callback called when the script is loaded
  32627. * @param onError defines the callback to call if an error occurs
  32628. * @param scriptId defines the id of the script element
  32629. */
  32630. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32631. /**
  32632. * Load an asynchronous script (identified by an url). When the url returns, the
  32633. * content of this file is added into a new script element, attached to the DOM (body element)
  32634. * @param scriptUrl defines the url of the script to laod
  32635. * @param scriptId defines the id of the script element
  32636. * @returns a promise request object
  32637. */
  32638. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32639. /**
  32640. * Loads a file from a blob
  32641. * @param fileToLoad defines the blob to use
  32642. * @param callback defines the callback to call when data is loaded
  32643. * @param progressCallback defines the callback to call during loading process
  32644. * @returns a file request object
  32645. */
  32646. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32647. /**
  32648. * Loads a file
  32649. * @param fileToLoad defines the file to load
  32650. * @param callback defines the callback to call when data is loaded
  32651. * @param progressCallBack defines the callback to call during loading process
  32652. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32653. * @returns a file request object
  32654. */
  32655. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32656. /**
  32657. * Creates a data url from a given string content
  32658. * @param content defines the content to convert
  32659. * @returns the new data url link
  32660. */
  32661. static FileAsURL(content: string): string;
  32662. /**
  32663. * Format the given number to a specific decimal format
  32664. * @param value defines the number to format
  32665. * @param decimals defines the number of decimals to use
  32666. * @returns the formatted string
  32667. */
  32668. static Format(value: number, decimals?: number): string;
  32669. /**
  32670. * Tries to copy an object by duplicating every property
  32671. * @param source defines the source object
  32672. * @param destination defines the target object
  32673. * @param doNotCopyList defines a list of properties to avoid
  32674. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32675. */
  32676. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32677. /**
  32678. * Gets a boolean indicating if the given object has no own property
  32679. * @param obj defines the object to test
  32680. * @returns true if object has no own property
  32681. */
  32682. static IsEmpty(obj: any): boolean;
  32683. /**
  32684. * Function used to register events at window level
  32685. * @param events defines the events to register
  32686. */
  32687. static RegisterTopRootEvents(events: {
  32688. name: string;
  32689. handler: Nullable<(e: FocusEvent) => any>;
  32690. }[]): void;
  32691. /**
  32692. * Function used to unregister events from window level
  32693. * @param events defines the events to unregister
  32694. */
  32695. static UnregisterTopRootEvents(events: {
  32696. name: string;
  32697. handler: Nullable<(e: FocusEvent) => any>;
  32698. }[]): void;
  32699. /**
  32700. * @ignore
  32701. */
  32702. static _ScreenshotCanvas: HTMLCanvasElement;
  32703. /**
  32704. * Dumps the current bound framebuffer
  32705. * @param width defines the rendering width
  32706. * @param height defines the rendering height
  32707. * @param engine defines the hosting engine
  32708. * @param successCallback defines the callback triggered once the data are available
  32709. * @param mimeType defines the mime type of the result
  32710. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32711. */
  32712. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32713. /**
  32714. * Converts the canvas data to blob.
  32715. * This acts as a polyfill for browsers not supporting the to blob function.
  32716. * @param canvas Defines the canvas to extract the data from
  32717. * @param successCallback Defines the callback triggered once the data are available
  32718. * @param mimeType Defines the mime type of the result
  32719. */
  32720. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32721. /**
  32722. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32723. * @param successCallback defines the callback triggered once the data are available
  32724. * @param mimeType defines the mime type of the result
  32725. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32726. */
  32727. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32728. /**
  32729. * Downloads a blob in the browser
  32730. * @param blob defines the blob to download
  32731. * @param fileName defines the name of the downloaded file
  32732. */
  32733. static Download(blob: Blob, fileName: string): void;
  32734. /**
  32735. * Captures a screenshot of the current rendering
  32736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32737. * @param engine defines the rendering engine
  32738. * @param camera defines the source camera
  32739. * @param size This parameter can be set to a single number or to an object with the
  32740. * following (optional) properties: precision, width, height. If a single number is passed,
  32741. * it will be used for both width and height. If an object is passed, the screenshot size
  32742. * will be derived from the parameters. The precision property is a multiplier allowing
  32743. * rendering at a higher or lower resolution
  32744. * @param successCallback defines the callback receives a single parameter which contains the
  32745. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32746. * src parameter of an <img> to display it
  32747. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32748. * Check your browser for supported MIME types
  32749. */
  32750. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32751. /**
  32752. * Generates an image screenshot from the specified camera.
  32753. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32754. * @param engine The engine to use for rendering
  32755. * @param camera The camera to use for rendering
  32756. * @param size This parameter can be set to a single number or to an object with the
  32757. * following (optional) properties: precision, width, height. If a single number is passed,
  32758. * it will be used for both width and height. If an object is passed, the screenshot size
  32759. * will be derived from the parameters. The precision property is a multiplier allowing
  32760. * rendering at a higher or lower resolution
  32761. * @param successCallback The callback receives a single parameter which contains the
  32762. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32763. * src parameter of an <img> to display it
  32764. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32765. * Check your browser for supported MIME types
  32766. * @param samples Texture samples (default: 1)
  32767. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32768. * @param fileName A name for for the downloaded file.
  32769. */
  32770. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32771. /**
  32772. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32773. * Be aware Math.random() could cause collisions, but:
  32774. * "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"
  32775. * @returns a pseudo random id
  32776. */
  32777. static RandomId(): string;
  32778. /**
  32779. * Test if the given uri is a base64 string
  32780. * @param uri The uri to test
  32781. * @return True if the uri is a base64 string or false otherwise
  32782. */
  32783. static IsBase64(uri: string): boolean;
  32784. /**
  32785. * Decode the given base64 uri.
  32786. * @param uri The uri to decode
  32787. * @return The decoded base64 data.
  32788. */
  32789. static DecodeBase64(uri: string): ArrayBuffer;
  32790. /**
  32791. * Gets the absolute url.
  32792. * @param url the input url
  32793. * @return the absolute url
  32794. */
  32795. static GetAbsoluteUrl(url: string): string;
  32796. /**
  32797. * No log
  32798. */
  32799. static readonly NoneLogLevel: number;
  32800. /**
  32801. * Only message logs
  32802. */
  32803. static readonly MessageLogLevel: number;
  32804. /**
  32805. * Only warning logs
  32806. */
  32807. static readonly WarningLogLevel: number;
  32808. /**
  32809. * Only error logs
  32810. */
  32811. static readonly ErrorLogLevel: number;
  32812. /**
  32813. * All logs
  32814. */
  32815. static readonly AllLogLevel: number;
  32816. /**
  32817. * Gets a value indicating the number of loading errors
  32818. * @ignorenaming
  32819. */
  32820. static readonly errorsCount: number;
  32821. /**
  32822. * Callback called when a new log is added
  32823. */
  32824. static OnNewCacheEntry: (entry: string) => void;
  32825. /**
  32826. * Log a message to the console
  32827. * @param message defines the message to log
  32828. */
  32829. static Log(message: string): void;
  32830. /**
  32831. * Write a warning message to the console
  32832. * @param message defines the message to log
  32833. */
  32834. static Warn(message: string): void;
  32835. /**
  32836. * Write an error message to the console
  32837. * @param message defines the message to log
  32838. */
  32839. static Error(message: string): void;
  32840. /**
  32841. * Gets current log cache (list of logs)
  32842. */
  32843. static readonly LogCache: string;
  32844. /**
  32845. * Clears the log cache
  32846. */
  32847. static ClearLogCache(): void;
  32848. /**
  32849. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32850. */
  32851. static LogLevels: number;
  32852. /**
  32853. * Checks if the window object exists
  32854. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32855. */
  32856. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32857. /**
  32858. * No performance log
  32859. */
  32860. static readonly PerformanceNoneLogLevel: number;
  32861. /**
  32862. * Use user marks to log performance
  32863. */
  32864. static readonly PerformanceUserMarkLogLevel: number;
  32865. /**
  32866. * Log performance to the console
  32867. */
  32868. static readonly PerformanceConsoleLogLevel: number;
  32869. private static _performance;
  32870. /**
  32871. * Sets the current performance log level
  32872. */
  32873. static PerformanceLogLevel: number;
  32874. private static _StartPerformanceCounterDisabled;
  32875. private static _EndPerformanceCounterDisabled;
  32876. private static _StartUserMark;
  32877. private static _EndUserMark;
  32878. private static _StartPerformanceConsole;
  32879. private static _EndPerformanceConsole;
  32880. /**
  32881. * Starts a performance counter
  32882. */
  32883. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32884. /**
  32885. * Ends a specific performance coutner
  32886. */
  32887. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32888. /**
  32889. * Gets either window.performance.now() if supported or Date.now() else
  32890. */
  32891. static readonly Now: number;
  32892. /**
  32893. * This method will return the name of the class used to create the instance of the given object.
  32894. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32895. * @param object the object to get the class name from
  32896. * @param isType defines if the object is actually a type
  32897. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32898. */
  32899. static GetClassName(object: any, isType?: boolean): string;
  32900. /**
  32901. * Gets the first element of an array satisfying a given predicate
  32902. * @param array defines the array to browse
  32903. * @param predicate defines the predicate to use
  32904. * @returns null if not found or the element
  32905. */
  32906. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32907. /**
  32908. * This method will return the name of the full name of the class, including its owning module (if any).
  32909. * 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).
  32910. * @param object the object to get the class name from
  32911. * @param isType defines if the object is actually a type
  32912. * @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.
  32913. * @ignorenaming
  32914. */
  32915. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32916. /**
  32917. * Returns a promise that resolves after the given amount of time.
  32918. * @param delay Number of milliseconds to delay
  32919. * @returns Promise that resolves after the given amount of time
  32920. */
  32921. static DelayAsync(delay: number): Promise<void>;
  32922. }
  32923. /**
  32924. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32925. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32926. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32927. * @param name The name of the class, case should be preserved
  32928. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32929. */
  32930. export function className(name: string, module?: string): (target: Object) => void;
  32931. /**
  32932. * An implementation of a loop for asynchronous functions.
  32933. */
  32934. export class AsyncLoop {
  32935. /**
  32936. * Defines the number of iterations for the loop
  32937. */
  32938. iterations: number;
  32939. /**
  32940. * Defines the current index of the loop.
  32941. */
  32942. index: number;
  32943. private _done;
  32944. private _fn;
  32945. private _successCallback;
  32946. /**
  32947. * Constructor.
  32948. * @param iterations the number of iterations.
  32949. * @param func the function to run each iteration
  32950. * @param successCallback the callback that will be called upon succesful execution
  32951. * @param offset starting offset.
  32952. */
  32953. constructor(
  32954. /**
  32955. * Defines the number of iterations for the loop
  32956. */
  32957. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32958. /**
  32959. * Execute the next iteration. Must be called after the last iteration was finished.
  32960. */
  32961. executeNext(): void;
  32962. /**
  32963. * Break the loop and run the success callback.
  32964. */
  32965. breakLoop(): void;
  32966. /**
  32967. * Create and run an async loop.
  32968. * @param iterations the number of iterations.
  32969. * @param fn the function to run each iteration
  32970. * @param successCallback the callback that will be called upon succesful execution
  32971. * @param offset starting offset.
  32972. * @returns the created async loop object
  32973. */
  32974. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32975. /**
  32976. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32977. * @param iterations total number of iterations
  32978. * @param syncedIterations number of synchronous iterations in each async iteration.
  32979. * @param fn the function to call each iteration.
  32980. * @param callback a success call back that will be called when iterating stops.
  32981. * @param breakFunction a break condition (optional)
  32982. * @param timeout timeout settings for the setTimeout function. default - 0.
  32983. * @returns the created async loop object
  32984. */
  32985. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32986. }
  32987. }
  32988. declare module "babylonjs/Collisions/collisionCoordinator" {
  32989. import { Nullable } from "babylonjs/types";
  32990. import { Scene } from "babylonjs/scene";
  32991. import { Vector3 } from "babylonjs/Maths/math.vector";
  32992. import { Collider } from "babylonjs/Collisions/collider";
  32993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32994. /** @hidden */
  32995. export interface ICollisionCoordinator {
  32996. createCollider(): Collider;
  32997. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32998. init(scene: Scene): void;
  32999. }
  33000. /** @hidden */
  33001. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33002. private _scene;
  33003. private _scaledPosition;
  33004. private _scaledVelocity;
  33005. private _finalPosition;
  33006. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33007. createCollider(): Collider;
  33008. init(scene: Scene): void;
  33009. private _collideWithWorld;
  33010. }
  33011. }
  33012. declare module "babylonjs/Inputs/scene.inputManager" {
  33013. import { Nullable } from "babylonjs/types";
  33014. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33015. import { Vector2 } from "babylonjs/Maths/math.vector";
  33016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33017. import { Scene } from "babylonjs/scene";
  33018. /**
  33019. * Class used to manage all inputs for the scene.
  33020. */
  33021. export class InputManager {
  33022. /** The distance in pixel that you have to move to prevent some events */
  33023. static DragMovementThreshold: number;
  33024. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33025. static LongPressDelay: number;
  33026. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33027. static DoubleClickDelay: number;
  33028. /** If you need to check double click without raising a single click at first click, enable this flag */
  33029. static ExclusiveDoubleClickMode: boolean;
  33030. private _wheelEventName;
  33031. private _onPointerMove;
  33032. private _onPointerDown;
  33033. private _onPointerUp;
  33034. private _initClickEvent;
  33035. private _initActionManager;
  33036. private _delayedSimpleClick;
  33037. private _delayedSimpleClickTimeout;
  33038. private _previousDelayedSimpleClickTimeout;
  33039. private _meshPickProceed;
  33040. private _previousButtonPressed;
  33041. private _currentPickResult;
  33042. private _previousPickResult;
  33043. private _totalPointersPressed;
  33044. private _doubleClickOccured;
  33045. private _pointerOverMesh;
  33046. private _pickedDownMesh;
  33047. private _pickedUpMesh;
  33048. private _pointerX;
  33049. private _pointerY;
  33050. private _unTranslatedPointerX;
  33051. private _unTranslatedPointerY;
  33052. private _startingPointerPosition;
  33053. private _previousStartingPointerPosition;
  33054. private _startingPointerTime;
  33055. private _previousStartingPointerTime;
  33056. private _pointerCaptures;
  33057. private _onKeyDown;
  33058. private _onKeyUp;
  33059. private _onCanvasFocusObserver;
  33060. private _onCanvasBlurObserver;
  33061. private _scene;
  33062. /**
  33063. * Creates a new InputManager
  33064. * @param scene defines the hosting scene
  33065. */
  33066. constructor(scene: Scene);
  33067. /**
  33068. * Gets the mesh that is currently under the pointer
  33069. */
  33070. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33071. /**
  33072. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33073. */
  33074. readonly unTranslatedPointer: Vector2;
  33075. /**
  33076. * Gets or sets the current on-screen X position of the pointer
  33077. */
  33078. pointerX: number;
  33079. /**
  33080. * Gets or sets the current on-screen Y position of the pointer
  33081. */
  33082. pointerY: number;
  33083. private _updatePointerPosition;
  33084. private _processPointerMove;
  33085. private _setRayOnPointerInfo;
  33086. private _checkPrePointerObservable;
  33087. /**
  33088. * Use this method to simulate a pointer move on a mesh
  33089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33092. */
  33093. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33094. /**
  33095. * Use this method to simulate a pointer down on a mesh
  33096. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33097. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33098. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33099. */
  33100. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33101. private _processPointerDown;
  33102. /** @hidden */
  33103. _isPointerSwiping(): boolean;
  33104. /**
  33105. * Use this method to simulate a pointer up on a mesh
  33106. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33107. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33108. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33109. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33110. */
  33111. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33112. private _processPointerUp;
  33113. /**
  33114. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33115. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33116. * @returns true if the pointer was captured
  33117. */
  33118. isPointerCaptured(pointerId?: number): boolean;
  33119. /**
  33120. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33121. * @param attachUp defines if you want to attach events to pointerup
  33122. * @param attachDown defines if you want to attach events to pointerdown
  33123. * @param attachMove defines if you want to attach events to pointermove
  33124. */
  33125. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33126. /**
  33127. * Detaches all event handlers
  33128. */
  33129. detachControl(): void;
  33130. /**
  33131. * Force the value of meshUnderPointer
  33132. * @param mesh defines the mesh to use
  33133. */
  33134. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33135. /**
  33136. * Gets the mesh under the pointer
  33137. * @returns a Mesh or null if no mesh is under the pointer
  33138. */
  33139. getPointerOverMesh(): Nullable<AbstractMesh>;
  33140. }
  33141. }
  33142. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33143. /**
  33144. * Helper class used to generate session unique ID
  33145. */
  33146. export class UniqueIdGenerator {
  33147. private static _UniqueIdCounter;
  33148. /**
  33149. * Gets an unique (relatively to the current scene) Id
  33150. */
  33151. static readonly UniqueId: number;
  33152. }
  33153. }
  33154. declare module "babylonjs/Animations/animationGroup" {
  33155. import { Animatable } from "babylonjs/Animations/animatable";
  33156. import { Animation } from "babylonjs/Animations/animation";
  33157. import { Scene, IDisposable } from "babylonjs/scene";
  33158. import { Observable } from "babylonjs/Misc/observable";
  33159. import { Nullable } from "babylonjs/types";
  33160. import "babylonjs/Animations/animatable";
  33161. /**
  33162. * This class defines the direct association between an animation and a target
  33163. */
  33164. export class TargetedAnimation {
  33165. /**
  33166. * Animation to perform
  33167. */
  33168. animation: Animation;
  33169. /**
  33170. * Target to animate
  33171. */
  33172. target: any;
  33173. /**
  33174. * Serialize the object
  33175. * @returns the JSON object representing the current entity
  33176. */
  33177. serialize(): any;
  33178. }
  33179. /**
  33180. * Use this class to create coordinated animations on multiple targets
  33181. */
  33182. export class AnimationGroup implements IDisposable {
  33183. /** The name of the animation group */
  33184. name: string;
  33185. private _scene;
  33186. private _targetedAnimations;
  33187. private _animatables;
  33188. private _from;
  33189. private _to;
  33190. private _isStarted;
  33191. private _isPaused;
  33192. private _speedRatio;
  33193. private _loopAnimation;
  33194. /**
  33195. * Gets or sets the unique id of the node
  33196. */
  33197. uniqueId: number;
  33198. /**
  33199. * This observable will notify when one animation have ended
  33200. */
  33201. onAnimationEndObservable: Observable<TargetedAnimation>;
  33202. /**
  33203. * Observer raised when one animation loops
  33204. */
  33205. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33206. /**
  33207. * This observable will notify when all animations have ended.
  33208. */
  33209. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33210. /**
  33211. * This observable will notify when all animations have paused.
  33212. */
  33213. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33214. /**
  33215. * This observable will notify when all animations are playing.
  33216. */
  33217. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33218. /**
  33219. * Gets the first frame
  33220. */
  33221. readonly from: number;
  33222. /**
  33223. * Gets the last frame
  33224. */
  33225. readonly to: number;
  33226. /**
  33227. * Define if the animations are started
  33228. */
  33229. readonly isStarted: boolean;
  33230. /**
  33231. * Gets a value indicating that the current group is playing
  33232. */
  33233. readonly isPlaying: boolean;
  33234. /**
  33235. * Gets or sets the speed ratio to use for all animations
  33236. */
  33237. /**
  33238. * Gets or sets the speed ratio to use for all animations
  33239. */
  33240. speedRatio: number;
  33241. /**
  33242. * Gets or sets if all animations should loop or not
  33243. */
  33244. loopAnimation: boolean;
  33245. /**
  33246. * Gets the targeted animations for this animation group
  33247. */
  33248. readonly targetedAnimations: Array<TargetedAnimation>;
  33249. /**
  33250. * returning the list of animatables controlled by this animation group.
  33251. */
  33252. readonly animatables: Array<Animatable>;
  33253. /**
  33254. * Instantiates a new Animation Group.
  33255. * This helps managing several animations at once.
  33256. * @see http://doc.babylonjs.com/how_to/group
  33257. * @param name Defines the name of the group
  33258. * @param scene Defines the scene the group belongs to
  33259. */
  33260. constructor(
  33261. /** The name of the animation group */
  33262. name: string, scene?: Nullable<Scene>);
  33263. /**
  33264. * Add an animation (with its target) in the group
  33265. * @param animation defines the animation we want to add
  33266. * @param target defines the target of the animation
  33267. * @returns the TargetedAnimation object
  33268. */
  33269. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33270. /**
  33271. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33272. * It can add constant keys at begin or end
  33273. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33274. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33275. * @returns the animation group
  33276. */
  33277. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33278. /**
  33279. * Start all animations on given targets
  33280. * @param loop defines if animations must loop
  33281. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33282. * @param from defines the from key (optional)
  33283. * @param to defines the to key (optional)
  33284. * @returns the current animation group
  33285. */
  33286. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33287. /**
  33288. * Pause all animations
  33289. * @returns the animation group
  33290. */
  33291. pause(): AnimationGroup;
  33292. /**
  33293. * Play all animations to initial state
  33294. * This function will start() the animations if they were not started or will restart() them if they were paused
  33295. * @param loop defines if animations must loop
  33296. * @returns the animation group
  33297. */
  33298. play(loop?: boolean): AnimationGroup;
  33299. /**
  33300. * Reset all animations to initial state
  33301. * @returns the animation group
  33302. */
  33303. reset(): AnimationGroup;
  33304. /**
  33305. * Restart animations from key 0
  33306. * @returns the animation group
  33307. */
  33308. restart(): AnimationGroup;
  33309. /**
  33310. * Stop all animations
  33311. * @returns the animation group
  33312. */
  33313. stop(): AnimationGroup;
  33314. /**
  33315. * Set animation weight for all animatables
  33316. * @param weight defines the weight to use
  33317. * @return the animationGroup
  33318. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33319. */
  33320. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33321. /**
  33322. * Synchronize and normalize all animatables with a source animatable
  33323. * @param root defines the root animatable to synchronize with
  33324. * @return the animationGroup
  33325. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33326. */
  33327. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33328. /**
  33329. * Goes to a specific frame in this animation group
  33330. * @param frame the frame number to go to
  33331. * @return the animationGroup
  33332. */
  33333. goToFrame(frame: number): AnimationGroup;
  33334. /**
  33335. * Dispose all associated resources
  33336. */
  33337. dispose(): void;
  33338. private _checkAnimationGroupEnded;
  33339. /**
  33340. * Clone the current animation group and returns a copy
  33341. * @param newName defines the name of the new group
  33342. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33343. * @returns the new aniamtion group
  33344. */
  33345. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33346. /**
  33347. * Serializes the animationGroup to an object
  33348. * @returns Serialized object
  33349. */
  33350. serialize(): any;
  33351. /**
  33352. * Returns a new AnimationGroup object parsed from the source provided.
  33353. * @param parsedAnimationGroup defines the source
  33354. * @param scene defines the scene that will receive the animationGroup
  33355. * @returns a new AnimationGroup
  33356. */
  33357. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33358. /**
  33359. * Returns the string "AnimationGroup"
  33360. * @returns "AnimationGroup"
  33361. */
  33362. getClassName(): string;
  33363. /**
  33364. * Creates a detailled string about the object
  33365. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33366. * @returns a string representing the object
  33367. */
  33368. toString(fullDetails?: boolean): string;
  33369. }
  33370. }
  33371. declare module "babylonjs/scene" {
  33372. import { Nullable } from "babylonjs/types";
  33373. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33374. import { Observable } from "babylonjs/Misc/observable";
  33375. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33376. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33377. import { Geometry } from "babylonjs/Meshes/geometry";
  33378. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33379. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33381. import { Mesh } from "babylonjs/Meshes/mesh";
  33382. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33383. import { Bone } from "babylonjs/Bones/bone";
  33384. import { Skeleton } from "babylonjs/Bones/skeleton";
  33385. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33386. import { Camera } from "babylonjs/Cameras/camera";
  33387. import { AbstractScene } from "babylonjs/abstractScene";
  33388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33390. import { Material } from "babylonjs/Materials/material";
  33391. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33392. import { Effect } from "babylonjs/Materials/effect";
  33393. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33394. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33395. import { Light } from "babylonjs/Lights/light";
  33396. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33397. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33398. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33399. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33400. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33401. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33402. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33403. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33404. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33405. import { Engine } from "babylonjs/Engines/engine";
  33406. import { Node } from "babylonjs/node";
  33407. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33408. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33409. import { WebRequest } from "babylonjs/Misc/webRequest";
  33410. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33411. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33412. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33413. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33414. import { Plane } from "babylonjs/Maths/math.plane";
  33415. import { Ray } from "babylonjs/Culling/ray";
  33416. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33417. import { Animation } from "babylonjs/Animations/animation";
  33418. import { Animatable } from "babylonjs/Animations/animatable";
  33419. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33420. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33421. import { Collider } from "babylonjs/Collisions/collider";
  33422. /**
  33423. * Define an interface for all classes that will hold resources
  33424. */
  33425. export interface IDisposable {
  33426. /**
  33427. * Releases all held resources
  33428. */
  33429. dispose(): void;
  33430. }
  33431. /** Interface defining initialization parameters for Scene class */
  33432. export interface SceneOptions {
  33433. /**
  33434. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33435. * It will improve performance when the number of geometries becomes important.
  33436. */
  33437. useGeometryUniqueIdsMap?: boolean;
  33438. /**
  33439. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33440. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33441. */
  33442. useMaterialMeshMap?: boolean;
  33443. /**
  33444. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33445. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33446. */
  33447. useClonedMeshhMap?: boolean;
  33448. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33449. virtual?: boolean;
  33450. }
  33451. /**
  33452. * Represents a scene to be rendered by the engine.
  33453. * @see http://doc.babylonjs.com/features/scene
  33454. */
  33455. export class Scene extends AbstractScene implements IAnimatable {
  33456. /** The fog is deactivated */
  33457. static readonly FOGMODE_NONE: number;
  33458. /** The fog density is following an exponential function */
  33459. static readonly FOGMODE_EXP: number;
  33460. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33461. static readonly FOGMODE_EXP2: number;
  33462. /** The fog density is following a linear function. */
  33463. static readonly FOGMODE_LINEAR: number;
  33464. /**
  33465. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33467. */
  33468. static MinDeltaTime: number;
  33469. /**
  33470. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33471. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33472. */
  33473. static MaxDeltaTime: number;
  33474. /**
  33475. * Factory used to create the default material.
  33476. * @param name The name of the material to create
  33477. * @param scene The scene to create the material for
  33478. * @returns The default material
  33479. */
  33480. static DefaultMaterialFactory(scene: Scene): Material;
  33481. /**
  33482. * Factory used to create the a collision coordinator.
  33483. * @returns The collision coordinator
  33484. */
  33485. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33486. /** @hidden */
  33487. _inputManager: InputManager;
  33488. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33489. cameraToUseForPointers: Nullable<Camera>;
  33490. /** @hidden */
  33491. readonly _isScene: boolean;
  33492. /**
  33493. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33494. */
  33495. autoClear: boolean;
  33496. /**
  33497. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33498. */
  33499. autoClearDepthAndStencil: boolean;
  33500. /**
  33501. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33502. */
  33503. clearColor: Color4;
  33504. /**
  33505. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33506. */
  33507. ambientColor: Color3;
  33508. /**
  33509. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33510. * It should only be one of the following (if not the default embedded one):
  33511. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33512. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33513. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33514. * The material properties need to be setup according to the type of texture in use.
  33515. */
  33516. environmentBRDFTexture: BaseTexture;
  33517. /** @hidden */
  33518. protected _environmentTexture: Nullable<BaseTexture>;
  33519. /**
  33520. * Texture used in all pbr material as the reflection texture.
  33521. * As in the majority of the scene they are the same (exception for multi room and so on),
  33522. * this is easier to reference from here than from all the materials.
  33523. */
  33524. /**
  33525. * Texture used in all pbr material as the reflection texture.
  33526. * As in the majority of the scene they are the same (exception for multi room and so on),
  33527. * this is easier to set here than in all the materials.
  33528. */
  33529. environmentTexture: Nullable<BaseTexture>;
  33530. /** @hidden */
  33531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33532. /**
  33533. * Default image processing configuration used either in the rendering
  33534. * Forward main pass or through the imageProcessingPostProcess if present.
  33535. * As in the majority of the scene they are the same (exception for multi camera),
  33536. * this is easier to reference from here than from all the materials and post process.
  33537. *
  33538. * No setter as we it is a shared configuration, you can set the values instead.
  33539. */
  33540. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33541. private _forceWireframe;
  33542. /**
  33543. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33544. */
  33545. forceWireframe: boolean;
  33546. private _forcePointsCloud;
  33547. /**
  33548. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33549. */
  33550. forcePointsCloud: boolean;
  33551. /**
  33552. * Gets or sets the active clipplane 1
  33553. */
  33554. clipPlane: Nullable<Plane>;
  33555. /**
  33556. * Gets or sets the active clipplane 2
  33557. */
  33558. clipPlane2: Nullable<Plane>;
  33559. /**
  33560. * Gets or sets the active clipplane 3
  33561. */
  33562. clipPlane3: Nullable<Plane>;
  33563. /**
  33564. * Gets or sets the active clipplane 4
  33565. */
  33566. clipPlane4: Nullable<Plane>;
  33567. /**
  33568. * Gets or sets a boolean indicating if animations are enabled
  33569. */
  33570. animationsEnabled: boolean;
  33571. private _animationPropertiesOverride;
  33572. /**
  33573. * Gets or sets the animation properties override
  33574. */
  33575. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33576. /**
  33577. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33578. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33579. */
  33580. useConstantAnimationDeltaTime: boolean;
  33581. /**
  33582. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33583. * Please note that it requires to run a ray cast through the scene on every frame
  33584. */
  33585. constantlyUpdateMeshUnderPointer: boolean;
  33586. /**
  33587. * Defines the HTML cursor to use when hovering over interactive elements
  33588. */
  33589. hoverCursor: string;
  33590. /**
  33591. * Defines the HTML default cursor to use (empty by default)
  33592. */
  33593. defaultCursor: string;
  33594. /**
  33595. * This is used to call preventDefault() on pointer down
  33596. * in order to block unwanted artifacts like system double clicks
  33597. */
  33598. preventDefaultOnPointerDown: boolean;
  33599. /**
  33600. * This is used to call preventDefault() on pointer up
  33601. * in order to block unwanted artifacts like system double clicks
  33602. */
  33603. preventDefaultOnPointerUp: boolean;
  33604. /**
  33605. * Gets or sets user defined metadata
  33606. */
  33607. metadata: any;
  33608. /**
  33609. * For internal use only. Please do not use.
  33610. */
  33611. reservedDataStore: any;
  33612. /**
  33613. * Gets the name of the plugin used to load this scene (null by default)
  33614. */
  33615. loadingPluginName: string;
  33616. /**
  33617. * Use this array to add regular expressions used to disable offline support for specific urls
  33618. */
  33619. disableOfflineSupportExceptionRules: RegExp[];
  33620. /**
  33621. * An event triggered when the scene is disposed.
  33622. */
  33623. onDisposeObservable: Observable<Scene>;
  33624. private _onDisposeObserver;
  33625. /** Sets a function to be executed when this scene is disposed. */
  33626. onDispose: () => void;
  33627. /**
  33628. * An event triggered before rendering the scene (right after animations and physics)
  33629. */
  33630. onBeforeRenderObservable: Observable<Scene>;
  33631. private _onBeforeRenderObserver;
  33632. /** Sets a function to be executed before rendering this scene */
  33633. beforeRender: Nullable<() => void>;
  33634. /**
  33635. * An event triggered after rendering the scene
  33636. */
  33637. onAfterRenderObservable: Observable<Scene>;
  33638. /**
  33639. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33640. */
  33641. onAfterRenderCameraObservable: Observable<Camera>;
  33642. private _onAfterRenderObserver;
  33643. /** Sets a function to be executed after rendering this scene */
  33644. afterRender: Nullable<() => void>;
  33645. /**
  33646. * An event triggered before animating the scene
  33647. */
  33648. onBeforeAnimationsObservable: Observable<Scene>;
  33649. /**
  33650. * An event triggered after animations processing
  33651. */
  33652. onAfterAnimationsObservable: Observable<Scene>;
  33653. /**
  33654. * An event triggered before draw calls are ready to be sent
  33655. */
  33656. onBeforeDrawPhaseObservable: Observable<Scene>;
  33657. /**
  33658. * An event triggered after draw calls have been sent
  33659. */
  33660. onAfterDrawPhaseObservable: Observable<Scene>;
  33661. /**
  33662. * An event triggered when the scene is ready
  33663. */
  33664. onReadyObservable: Observable<Scene>;
  33665. /**
  33666. * An event triggered before rendering a camera
  33667. */
  33668. onBeforeCameraRenderObservable: Observable<Camera>;
  33669. private _onBeforeCameraRenderObserver;
  33670. /** Sets a function to be executed before rendering a camera*/
  33671. beforeCameraRender: () => void;
  33672. /**
  33673. * An event triggered after rendering a camera
  33674. */
  33675. onAfterCameraRenderObservable: Observable<Camera>;
  33676. private _onAfterCameraRenderObserver;
  33677. /** Sets a function to be executed after rendering a camera*/
  33678. afterCameraRender: () => void;
  33679. /**
  33680. * An event triggered when active meshes evaluation is about to start
  33681. */
  33682. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33683. /**
  33684. * An event triggered when active meshes evaluation is done
  33685. */
  33686. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33687. /**
  33688. * An event triggered when particles rendering is about to start
  33689. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33690. */
  33691. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33692. /**
  33693. * An event triggered when particles rendering is done
  33694. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33695. */
  33696. onAfterParticlesRenderingObservable: Observable<Scene>;
  33697. /**
  33698. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33699. */
  33700. onDataLoadedObservable: Observable<Scene>;
  33701. /**
  33702. * An event triggered when a camera is created
  33703. */
  33704. onNewCameraAddedObservable: Observable<Camera>;
  33705. /**
  33706. * An event triggered when a camera is removed
  33707. */
  33708. onCameraRemovedObservable: Observable<Camera>;
  33709. /**
  33710. * An event triggered when a light is created
  33711. */
  33712. onNewLightAddedObservable: Observable<Light>;
  33713. /**
  33714. * An event triggered when a light is removed
  33715. */
  33716. onLightRemovedObservable: Observable<Light>;
  33717. /**
  33718. * An event triggered when a geometry is created
  33719. */
  33720. onNewGeometryAddedObservable: Observable<Geometry>;
  33721. /**
  33722. * An event triggered when a geometry is removed
  33723. */
  33724. onGeometryRemovedObservable: Observable<Geometry>;
  33725. /**
  33726. * An event triggered when a transform node is created
  33727. */
  33728. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33729. /**
  33730. * An event triggered when a transform node is removed
  33731. */
  33732. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33733. /**
  33734. * An event triggered when a mesh is created
  33735. */
  33736. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33737. /**
  33738. * An event triggered when a mesh is removed
  33739. */
  33740. onMeshRemovedObservable: Observable<AbstractMesh>;
  33741. /**
  33742. * An event triggered when a skeleton is created
  33743. */
  33744. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33745. /**
  33746. * An event triggered when a skeleton is removed
  33747. */
  33748. onSkeletonRemovedObservable: Observable<Skeleton>;
  33749. /**
  33750. * An event triggered when a material is created
  33751. */
  33752. onNewMaterialAddedObservable: Observable<Material>;
  33753. /**
  33754. * An event triggered when a material is removed
  33755. */
  33756. onMaterialRemovedObservable: Observable<Material>;
  33757. /**
  33758. * An event triggered when a texture is created
  33759. */
  33760. onNewTextureAddedObservable: Observable<BaseTexture>;
  33761. /**
  33762. * An event triggered when a texture is removed
  33763. */
  33764. onTextureRemovedObservable: Observable<BaseTexture>;
  33765. /**
  33766. * An event triggered when render targets are about to be rendered
  33767. * Can happen multiple times per frame.
  33768. */
  33769. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33770. /**
  33771. * An event triggered when render targets were rendered.
  33772. * Can happen multiple times per frame.
  33773. */
  33774. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33775. /**
  33776. * An event triggered before calculating deterministic simulation step
  33777. */
  33778. onBeforeStepObservable: Observable<Scene>;
  33779. /**
  33780. * An event triggered after calculating deterministic simulation step
  33781. */
  33782. onAfterStepObservable: Observable<Scene>;
  33783. /**
  33784. * An event triggered when the activeCamera property is updated
  33785. */
  33786. onActiveCameraChanged: Observable<Scene>;
  33787. /**
  33788. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33789. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33790. * 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)
  33791. */
  33792. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33793. /**
  33794. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33795. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33796. * 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)
  33797. */
  33798. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33799. /**
  33800. * This Observable will when a mesh has been imported into the scene.
  33801. */
  33802. onMeshImportedObservable: Observable<AbstractMesh>;
  33803. /**
  33804. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33805. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33806. */
  33807. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33808. /** @hidden */
  33809. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33810. /**
  33811. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33812. */
  33813. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33814. /**
  33815. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33816. */
  33817. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33818. /**
  33819. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33820. */
  33821. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33822. /** Callback called when a pointer move is detected */
  33823. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33824. /** Callback called when a pointer down is detected */
  33825. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33826. /** Callback called when a pointer up is detected */
  33827. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33828. /** Callback called when a pointer pick is detected */
  33829. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33830. /**
  33831. * 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).
  33832. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33833. */
  33834. onPrePointerObservable: Observable<PointerInfoPre>;
  33835. /**
  33836. * Observable event triggered each time an input event is received from the rendering canvas
  33837. */
  33838. onPointerObservable: Observable<PointerInfo>;
  33839. /**
  33840. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33841. */
  33842. readonly unTranslatedPointer: Vector2;
  33843. /**
  33844. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33845. */
  33846. static DragMovementThreshold: number;
  33847. /**
  33848. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33849. */
  33850. static LongPressDelay: number;
  33851. /**
  33852. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33853. */
  33854. static DoubleClickDelay: number;
  33855. /** If you need to check double click without raising a single click at first click, enable this flag */
  33856. static ExclusiveDoubleClickMode: boolean;
  33857. /** @hidden */
  33858. _mirroredCameraPosition: Nullable<Vector3>;
  33859. /**
  33860. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33861. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33862. */
  33863. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33864. /**
  33865. * Observable event triggered each time an keyboard event is received from the hosting window
  33866. */
  33867. onKeyboardObservable: Observable<KeyboardInfo>;
  33868. private _useRightHandedSystem;
  33869. /**
  33870. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33871. */
  33872. useRightHandedSystem: boolean;
  33873. private _timeAccumulator;
  33874. private _currentStepId;
  33875. private _currentInternalStep;
  33876. /**
  33877. * Sets the step Id used by deterministic lock step
  33878. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33879. * @param newStepId defines the step Id
  33880. */
  33881. setStepId(newStepId: number): void;
  33882. /**
  33883. * Gets the step Id used by deterministic lock step
  33884. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33885. * @returns the step Id
  33886. */
  33887. getStepId(): number;
  33888. /**
  33889. * Gets the internal step used by deterministic lock step
  33890. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33891. * @returns the internal step
  33892. */
  33893. getInternalStep(): number;
  33894. private _fogEnabled;
  33895. /**
  33896. * Gets or sets a boolean indicating if fog is enabled on this scene
  33897. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33898. * (Default is true)
  33899. */
  33900. fogEnabled: boolean;
  33901. private _fogMode;
  33902. /**
  33903. * Gets or sets the fog mode to use
  33904. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33905. * | mode | value |
  33906. * | --- | --- |
  33907. * | FOGMODE_NONE | 0 |
  33908. * | FOGMODE_EXP | 1 |
  33909. * | FOGMODE_EXP2 | 2 |
  33910. * | FOGMODE_LINEAR | 3 |
  33911. */
  33912. fogMode: number;
  33913. /**
  33914. * Gets or sets the fog color to use
  33915. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33916. * (Default is Color3(0.2, 0.2, 0.3))
  33917. */
  33918. fogColor: Color3;
  33919. /**
  33920. * Gets or sets the fog density to use
  33921. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33922. * (Default is 0.1)
  33923. */
  33924. fogDensity: number;
  33925. /**
  33926. * Gets or sets the fog start distance to use
  33927. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33928. * (Default is 0)
  33929. */
  33930. fogStart: number;
  33931. /**
  33932. * Gets or sets the fog end distance to use
  33933. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33934. * (Default is 1000)
  33935. */
  33936. fogEnd: number;
  33937. private _shadowsEnabled;
  33938. /**
  33939. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33940. */
  33941. shadowsEnabled: boolean;
  33942. private _lightsEnabled;
  33943. /**
  33944. * Gets or sets a boolean indicating if lights are enabled on this scene
  33945. */
  33946. lightsEnabled: boolean;
  33947. /** All of the active cameras added to this scene. */
  33948. activeCameras: Camera[];
  33949. /** @hidden */
  33950. _activeCamera: Nullable<Camera>;
  33951. /** Gets or sets the current active camera */
  33952. activeCamera: Nullable<Camera>;
  33953. private _defaultMaterial;
  33954. /** The default material used on meshes when no material is affected */
  33955. /** The default material used on meshes when no material is affected */
  33956. defaultMaterial: Material;
  33957. private _texturesEnabled;
  33958. /**
  33959. * Gets or sets a boolean indicating if textures are enabled on this scene
  33960. */
  33961. texturesEnabled: boolean;
  33962. /**
  33963. * Gets or sets a boolean indicating if particles are enabled on this scene
  33964. */
  33965. particlesEnabled: boolean;
  33966. /**
  33967. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33968. */
  33969. spritesEnabled: boolean;
  33970. private _skeletonsEnabled;
  33971. /**
  33972. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33973. */
  33974. skeletonsEnabled: boolean;
  33975. /**
  33976. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33977. */
  33978. lensFlaresEnabled: boolean;
  33979. /**
  33980. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33981. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33982. */
  33983. collisionsEnabled: boolean;
  33984. private _collisionCoordinator;
  33985. /** @hidden */
  33986. readonly collisionCoordinator: ICollisionCoordinator;
  33987. /**
  33988. * Defines the gravity applied to this scene (used only for collisions)
  33989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33990. */
  33991. gravity: Vector3;
  33992. /**
  33993. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33994. */
  33995. postProcessesEnabled: boolean;
  33996. /**
  33997. * The list of postprocesses added to the scene
  33998. */
  33999. postProcesses: PostProcess[];
  34000. /**
  34001. * Gets the current postprocess manager
  34002. */
  34003. postProcessManager: PostProcessManager;
  34004. /**
  34005. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34006. */
  34007. renderTargetsEnabled: boolean;
  34008. /**
  34009. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34010. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34011. */
  34012. dumpNextRenderTargets: boolean;
  34013. /**
  34014. * The list of user defined render targets added to the scene
  34015. */
  34016. customRenderTargets: RenderTargetTexture[];
  34017. /**
  34018. * Defines if texture loading must be delayed
  34019. * If true, textures will only be loaded when they need to be rendered
  34020. */
  34021. useDelayedTextureLoading: boolean;
  34022. /**
  34023. * Gets the list of meshes imported to the scene through SceneLoader
  34024. */
  34025. importedMeshesFiles: String[];
  34026. /**
  34027. * Gets or sets a boolean indicating if probes are enabled on this scene
  34028. */
  34029. probesEnabled: boolean;
  34030. /**
  34031. * Gets or sets the current offline provider to use to store scene data
  34032. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34033. */
  34034. offlineProvider: IOfflineProvider;
  34035. /**
  34036. * Gets or sets the action manager associated with the scene
  34037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34038. */
  34039. actionManager: AbstractActionManager;
  34040. private _meshesForIntersections;
  34041. /**
  34042. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34043. */
  34044. proceduralTexturesEnabled: boolean;
  34045. private _engine;
  34046. private _totalVertices;
  34047. /** @hidden */
  34048. _activeIndices: PerfCounter;
  34049. /** @hidden */
  34050. _activeParticles: PerfCounter;
  34051. /** @hidden */
  34052. _activeBones: PerfCounter;
  34053. private _animationRatio;
  34054. /** @hidden */
  34055. _animationTimeLast: number;
  34056. /** @hidden */
  34057. _animationTime: number;
  34058. /**
  34059. * Gets or sets a general scale for animation speed
  34060. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34061. */
  34062. animationTimeScale: number;
  34063. /** @hidden */
  34064. _cachedMaterial: Nullable<Material>;
  34065. /** @hidden */
  34066. _cachedEffect: Nullable<Effect>;
  34067. /** @hidden */
  34068. _cachedVisibility: Nullable<number>;
  34069. private _renderId;
  34070. private _frameId;
  34071. private _executeWhenReadyTimeoutId;
  34072. private _intermediateRendering;
  34073. private _viewUpdateFlag;
  34074. private _projectionUpdateFlag;
  34075. /** @hidden */
  34076. _toBeDisposed: Nullable<IDisposable>[];
  34077. private _activeRequests;
  34078. /** @hidden */
  34079. _pendingData: any[];
  34080. private _isDisposed;
  34081. /**
  34082. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34083. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34084. */
  34085. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34086. private _activeMeshes;
  34087. private _processedMaterials;
  34088. private _renderTargets;
  34089. /** @hidden */
  34090. _activeParticleSystems: SmartArray<IParticleSystem>;
  34091. private _activeSkeletons;
  34092. private _softwareSkinnedMeshes;
  34093. private _renderingManager;
  34094. /** @hidden */
  34095. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34096. private _transformMatrix;
  34097. private _sceneUbo;
  34098. /** @hidden */
  34099. _viewMatrix: Matrix;
  34100. private _projectionMatrix;
  34101. /** @hidden */
  34102. _forcedViewPosition: Nullable<Vector3>;
  34103. /** @hidden */
  34104. _frustumPlanes: Plane[];
  34105. /**
  34106. * Gets the list of frustum planes (built from the active camera)
  34107. */
  34108. readonly frustumPlanes: Plane[];
  34109. /**
  34110. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34111. * This is useful if there are more lights that the maximum simulteanous authorized
  34112. */
  34113. requireLightSorting: boolean;
  34114. /** @hidden */
  34115. readonly useMaterialMeshMap: boolean;
  34116. /** @hidden */
  34117. readonly useClonedMeshhMap: boolean;
  34118. private _externalData;
  34119. private _uid;
  34120. /**
  34121. * @hidden
  34122. * Backing store of defined scene components.
  34123. */
  34124. _components: ISceneComponent[];
  34125. /**
  34126. * @hidden
  34127. * Backing store of defined scene components.
  34128. */
  34129. _serializableComponents: ISceneSerializableComponent[];
  34130. /**
  34131. * List of components to register on the next registration step.
  34132. */
  34133. private _transientComponents;
  34134. /**
  34135. * Registers the transient components if needed.
  34136. */
  34137. private _registerTransientComponents;
  34138. /**
  34139. * @hidden
  34140. * Add a component to the scene.
  34141. * Note that the ccomponent could be registered on th next frame if this is called after
  34142. * the register component stage.
  34143. * @param component Defines the component to add to the scene
  34144. */
  34145. _addComponent(component: ISceneComponent): void;
  34146. /**
  34147. * @hidden
  34148. * Gets a component from the scene.
  34149. * @param name defines the name of the component to retrieve
  34150. * @returns the component or null if not present
  34151. */
  34152. _getComponent(name: string): Nullable<ISceneComponent>;
  34153. /**
  34154. * @hidden
  34155. * Defines the actions happening before camera updates.
  34156. */
  34157. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34158. /**
  34159. * @hidden
  34160. * Defines the actions happening before clear the canvas.
  34161. */
  34162. _beforeClearStage: Stage<SimpleStageAction>;
  34163. /**
  34164. * @hidden
  34165. * Defines the actions when collecting render targets for the frame.
  34166. */
  34167. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34168. /**
  34169. * @hidden
  34170. * Defines the actions happening for one camera in the frame.
  34171. */
  34172. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34173. /**
  34174. * @hidden
  34175. * Defines the actions happening during the per mesh ready checks.
  34176. */
  34177. _isReadyForMeshStage: Stage<MeshStageAction>;
  34178. /**
  34179. * @hidden
  34180. * Defines the actions happening before evaluate active mesh checks.
  34181. */
  34182. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34183. /**
  34184. * @hidden
  34185. * Defines the actions happening during the evaluate sub mesh checks.
  34186. */
  34187. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34188. /**
  34189. * @hidden
  34190. * Defines the actions happening during the active mesh stage.
  34191. */
  34192. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34193. /**
  34194. * @hidden
  34195. * Defines the actions happening during the per camera render target step.
  34196. */
  34197. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34198. /**
  34199. * @hidden
  34200. * Defines the actions happening just before the active camera is drawing.
  34201. */
  34202. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34203. /**
  34204. * @hidden
  34205. * Defines the actions happening just before a render target is drawing.
  34206. */
  34207. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34208. /**
  34209. * @hidden
  34210. * Defines the actions happening just before a rendering group is drawing.
  34211. */
  34212. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34213. /**
  34214. * @hidden
  34215. * Defines the actions happening just before a mesh is drawing.
  34216. */
  34217. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34218. /**
  34219. * @hidden
  34220. * Defines the actions happening just after a mesh has been drawn.
  34221. */
  34222. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34223. /**
  34224. * @hidden
  34225. * Defines the actions happening just after a rendering group has been drawn.
  34226. */
  34227. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34228. /**
  34229. * @hidden
  34230. * Defines the actions happening just after the active camera has been drawn.
  34231. */
  34232. _afterCameraDrawStage: Stage<CameraStageAction>;
  34233. /**
  34234. * @hidden
  34235. * Defines the actions happening just after a render target has been drawn.
  34236. */
  34237. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34238. /**
  34239. * @hidden
  34240. * Defines the actions happening just after rendering all cameras and computing intersections.
  34241. */
  34242. _afterRenderStage: Stage<SimpleStageAction>;
  34243. /**
  34244. * @hidden
  34245. * Defines the actions happening when a pointer move event happens.
  34246. */
  34247. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34248. /**
  34249. * @hidden
  34250. * Defines the actions happening when a pointer down event happens.
  34251. */
  34252. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34253. /**
  34254. * @hidden
  34255. * Defines the actions happening when a pointer up event happens.
  34256. */
  34257. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34258. /**
  34259. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34260. */
  34261. private geometriesByUniqueId;
  34262. /**
  34263. * Creates a new Scene
  34264. * @param engine defines the engine to use to render this scene
  34265. * @param options defines the scene options
  34266. */
  34267. constructor(engine: Engine, options?: SceneOptions);
  34268. /**
  34269. * Gets a string idenfifying the name of the class
  34270. * @returns "Scene" string
  34271. */
  34272. getClassName(): string;
  34273. private _defaultMeshCandidates;
  34274. /**
  34275. * @hidden
  34276. */
  34277. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34278. private _defaultSubMeshCandidates;
  34279. /**
  34280. * @hidden
  34281. */
  34282. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34283. /**
  34284. * Sets the default candidate providers for the scene.
  34285. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34286. * and getCollidingSubMeshCandidates to their default function
  34287. */
  34288. setDefaultCandidateProviders(): void;
  34289. /**
  34290. * Gets the mesh that is currently under the pointer
  34291. */
  34292. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34293. /**
  34294. * Gets or sets the current on-screen X position of the pointer
  34295. */
  34296. pointerX: number;
  34297. /**
  34298. * Gets or sets the current on-screen Y position of the pointer
  34299. */
  34300. pointerY: number;
  34301. /**
  34302. * Gets the cached material (ie. the latest rendered one)
  34303. * @returns the cached material
  34304. */
  34305. getCachedMaterial(): Nullable<Material>;
  34306. /**
  34307. * Gets the cached effect (ie. the latest rendered one)
  34308. * @returns the cached effect
  34309. */
  34310. getCachedEffect(): Nullable<Effect>;
  34311. /**
  34312. * Gets the cached visibility state (ie. the latest rendered one)
  34313. * @returns the cached visibility state
  34314. */
  34315. getCachedVisibility(): Nullable<number>;
  34316. /**
  34317. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34318. * @param material defines the current material
  34319. * @param effect defines the current effect
  34320. * @param visibility defines the current visibility state
  34321. * @returns true if one parameter is not cached
  34322. */
  34323. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34324. /**
  34325. * Gets the engine associated with the scene
  34326. * @returns an Engine
  34327. */
  34328. getEngine(): Engine;
  34329. /**
  34330. * Gets the total number of vertices rendered per frame
  34331. * @returns the total number of vertices rendered per frame
  34332. */
  34333. getTotalVertices(): number;
  34334. /**
  34335. * Gets the performance counter for total vertices
  34336. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34337. */
  34338. readonly totalVerticesPerfCounter: PerfCounter;
  34339. /**
  34340. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34341. * @returns the total number of active indices rendered per frame
  34342. */
  34343. getActiveIndices(): number;
  34344. /**
  34345. * Gets the performance counter for active indices
  34346. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34347. */
  34348. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34349. /**
  34350. * Gets the total number of active particles rendered per frame
  34351. * @returns the total number of active particles rendered per frame
  34352. */
  34353. getActiveParticles(): number;
  34354. /**
  34355. * Gets the performance counter for active particles
  34356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34357. */
  34358. readonly activeParticlesPerfCounter: PerfCounter;
  34359. /**
  34360. * Gets the total number of active bones rendered per frame
  34361. * @returns the total number of active bones rendered per frame
  34362. */
  34363. getActiveBones(): number;
  34364. /**
  34365. * Gets the performance counter for active bones
  34366. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34367. */
  34368. readonly activeBonesPerfCounter: PerfCounter;
  34369. /**
  34370. * Gets the array of active meshes
  34371. * @returns an array of AbstractMesh
  34372. */
  34373. getActiveMeshes(): SmartArray<AbstractMesh>;
  34374. /**
  34375. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34376. * @returns a number
  34377. */
  34378. getAnimationRatio(): number;
  34379. /**
  34380. * Gets an unique Id for the current render phase
  34381. * @returns a number
  34382. */
  34383. getRenderId(): number;
  34384. /**
  34385. * Gets an unique Id for the current frame
  34386. * @returns a number
  34387. */
  34388. getFrameId(): number;
  34389. /** Call this function if you want to manually increment the render Id*/
  34390. incrementRenderId(): void;
  34391. private _createUbo;
  34392. /**
  34393. * Use this method to simulate a pointer move on a mesh
  34394. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34395. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34396. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34397. * @returns the current scene
  34398. */
  34399. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34400. /**
  34401. * Use this method to simulate a pointer down on a mesh
  34402. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34403. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34404. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34405. * @returns the current scene
  34406. */
  34407. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34408. /**
  34409. * Use this method to simulate a pointer up on a mesh
  34410. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34411. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34412. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34413. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34414. * @returns the current scene
  34415. */
  34416. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34417. /**
  34418. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34419. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34420. * @returns true if the pointer was captured
  34421. */
  34422. isPointerCaptured(pointerId?: number): boolean;
  34423. /**
  34424. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34425. * @param attachUp defines if you want to attach events to pointerup
  34426. * @param attachDown defines if you want to attach events to pointerdown
  34427. * @param attachMove defines if you want to attach events to pointermove
  34428. */
  34429. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34430. /** Detaches all event handlers*/
  34431. detachControl(): void;
  34432. /**
  34433. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34434. * Delay loaded resources are not taking in account
  34435. * @return true if all required resources are ready
  34436. */
  34437. isReady(): boolean;
  34438. /** Resets all cached information relative to material (including effect and visibility) */
  34439. resetCachedMaterial(): void;
  34440. /**
  34441. * Registers a function to be called before every frame render
  34442. * @param func defines the function to register
  34443. */
  34444. registerBeforeRender(func: () => void): void;
  34445. /**
  34446. * Unregisters a function called before every frame render
  34447. * @param func defines the function to unregister
  34448. */
  34449. unregisterBeforeRender(func: () => void): void;
  34450. /**
  34451. * Registers a function to be called after every frame render
  34452. * @param func defines the function to register
  34453. */
  34454. registerAfterRender(func: () => void): void;
  34455. /**
  34456. * Unregisters a function called after every frame render
  34457. * @param func defines the function to unregister
  34458. */
  34459. unregisterAfterRender(func: () => void): void;
  34460. private _executeOnceBeforeRender;
  34461. /**
  34462. * The provided function will run before render once and will be disposed afterwards.
  34463. * A timeout delay can be provided so that the function will be executed in N ms.
  34464. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34465. * @param func The function to be executed.
  34466. * @param timeout optional delay in ms
  34467. */
  34468. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34469. /** @hidden */
  34470. _addPendingData(data: any): void;
  34471. /** @hidden */
  34472. _removePendingData(data: any): void;
  34473. /**
  34474. * Returns the number of items waiting to be loaded
  34475. * @returns the number of items waiting to be loaded
  34476. */
  34477. getWaitingItemsCount(): number;
  34478. /**
  34479. * Returns a boolean indicating if the scene is still loading data
  34480. */
  34481. readonly isLoading: boolean;
  34482. /**
  34483. * Registers a function to be executed when the scene is ready
  34484. * @param {Function} func - the function to be executed
  34485. */
  34486. executeWhenReady(func: () => void): void;
  34487. /**
  34488. * Returns a promise that resolves when the scene is ready
  34489. * @returns A promise that resolves when the scene is ready
  34490. */
  34491. whenReadyAsync(): Promise<void>;
  34492. /** @hidden */
  34493. _checkIsReady(): void;
  34494. /**
  34495. * Gets all animatable attached to the scene
  34496. */
  34497. readonly animatables: Animatable[];
  34498. /**
  34499. * Resets the last animation time frame.
  34500. * Useful to override when animations start running when loading a scene for the first time.
  34501. */
  34502. resetLastAnimationTimeFrame(): void;
  34503. /**
  34504. * Gets the current view matrix
  34505. * @returns a Matrix
  34506. */
  34507. getViewMatrix(): Matrix;
  34508. /**
  34509. * Gets the current projection matrix
  34510. * @returns a Matrix
  34511. */
  34512. getProjectionMatrix(): Matrix;
  34513. /**
  34514. * Gets the current transform matrix
  34515. * @returns a Matrix made of View * Projection
  34516. */
  34517. getTransformMatrix(): Matrix;
  34518. /**
  34519. * Sets the current transform matrix
  34520. * @param viewL defines the View matrix to use
  34521. * @param projectionL defines the Projection matrix to use
  34522. * @param viewR defines the right View matrix to use (if provided)
  34523. * @param projectionR defines the right Projection matrix to use (if provided)
  34524. */
  34525. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34526. /**
  34527. * Gets the uniform buffer used to store scene data
  34528. * @returns a UniformBuffer
  34529. */
  34530. getSceneUniformBuffer(): UniformBuffer;
  34531. /**
  34532. * Gets an unique (relatively to the current scene) Id
  34533. * @returns an unique number for the scene
  34534. */
  34535. getUniqueId(): number;
  34536. /**
  34537. * Add a mesh to the list of scene's meshes
  34538. * @param newMesh defines the mesh to add
  34539. * @param recursive if all child meshes should also be added to the scene
  34540. */
  34541. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34542. /**
  34543. * Remove a mesh for the list of scene's meshes
  34544. * @param toRemove defines the mesh to remove
  34545. * @param recursive if all child meshes should also be removed from the scene
  34546. * @returns the index where the mesh was in the mesh list
  34547. */
  34548. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34549. /**
  34550. * Add a transform node to the list of scene's transform nodes
  34551. * @param newTransformNode defines the transform node to add
  34552. */
  34553. addTransformNode(newTransformNode: TransformNode): void;
  34554. /**
  34555. * Remove a transform node for the list of scene's transform nodes
  34556. * @param toRemove defines the transform node to remove
  34557. * @returns the index where the transform node was in the transform node list
  34558. */
  34559. removeTransformNode(toRemove: TransformNode): number;
  34560. /**
  34561. * Remove a skeleton for the list of scene's skeletons
  34562. * @param toRemove defines the skeleton to remove
  34563. * @returns the index where the skeleton was in the skeleton list
  34564. */
  34565. removeSkeleton(toRemove: Skeleton): number;
  34566. /**
  34567. * Remove a morph target for the list of scene's morph targets
  34568. * @param toRemove defines the morph target to remove
  34569. * @returns the index where the morph target was in the morph target list
  34570. */
  34571. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34572. /**
  34573. * Remove a light for the list of scene's lights
  34574. * @param toRemove defines the light to remove
  34575. * @returns the index where the light was in the light list
  34576. */
  34577. removeLight(toRemove: Light): number;
  34578. /**
  34579. * Remove a camera for the list of scene's cameras
  34580. * @param toRemove defines the camera to remove
  34581. * @returns the index where the camera was in the camera list
  34582. */
  34583. removeCamera(toRemove: Camera): number;
  34584. /**
  34585. * Remove a particle system for the list of scene's particle systems
  34586. * @param toRemove defines the particle system to remove
  34587. * @returns the index where the particle system was in the particle system list
  34588. */
  34589. removeParticleSystem(toRemove: IParticleSystem): number;
  34590. /**
  34591. * Remove a animation for the list of scene's animations
  34592. * @param toRemove defines the animation to remove
  34593. * @returns the index where the animation was in the animation list
  34594. */
  34595. removeAnimation(toRemove: Animation): number;
  34596. /**
  34597. * Will stop the animation of the given target
  34598. * @param target - the target
  34599. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34600. * @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)
  34601. */
  34602. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34603. /**
  34604. * Removes the given animation group from this scene.
  34605. * @param toRemove The animation group to remove
  34606. * @returns The index of the removed animation group
  34607. */
  34608. removeAnimationGroup(toRemove: AnimationGroup): number;
  34609. /**
  34610. * Removes the given multi-material from this scene.
  34611. * @param toRemove The multi-material to remove
  34612. * @returns The index of the removed multi-material
  34613. */
  34614. removeMultiMaterial(toRemove: MultiMaterial): number;
  34615. /**
  34616. * Removes the given material from this scene.
  34617. * @param toRemove The material to remove
  34618. * @returns The index of the removed material
  34619. */
  34620. removeMaterial(toRemove: Material): number;
  34621. /**
  34622. * Removes the given action manager from this scene.
  34623. * @param toRemove The action manager to remove
  34624. * @returns The index of the removed action manager
  34625. */
  34626. removeActionManager(toRemove: AbstractActionManager): number;
  34627. /**
  34628. * Removes the given texture from this scene.
  34629. * @param toRemove The texture to remove
  34630. * @returns The index of the removed texture
  34631. */
  34632. removeTexture(toRemove: BaseTexture): number;
  34633. /**
  34634. * Adds the given light to this scene
  34635. * @param newLight The light to add
  34636. */
  34637. addLight(newLight: Light): void;
  34638. /**
  34639. * Sorts the list list based on light priorities
  34640. */
  34641. sortLightsByPriority(): void;
  34642. /**
  34643. * Adds the given camera to this scene
  34644. * @param newCamera The camera to add
  34645. */
  34646. addCamera(newCamera: Camera): void;
  34647. /**
  34648. * Adds the given skeleton to this scene
  34649. * @param newSkeleton The skeleton to add
  34650. */
  34651. addSkeleton(newSkeleton: Skeleton): void;
  34652. /**
  34653. * Adds the given particle system to this scene
  34654. * @param newParticleSystem The particle system to add
  34655. */
  34656. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34657. /**
  34658. * Adds the given animation to this scene
  34659. * @param newAnimation The animation to add
  34660. */
  34661. addAnimation(newAnimation: Animation): void;
  34662. /**
  34663. * Adds the given animation group to this scene.
  34664. * @param newAnimationGroup The animation group to add
  34665. */
  34666. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34667. /**
  34668. * Adds the given multi-material to this scene
  34669. * @param newMultiMaterial The multi-material to add
  34670. */
  34671. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34672. /**
  34673. * Adds the given material to this scene
  34674. * @param newMaterial The material to add
  34675. */
  34676. addMaterial(newMaterial: Material): void;
  34677. /**
  34678. * Adds the given morph target to this scene
  34679. * @param newMorphTargetManager The morph target to add
  34680. */
  34681. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34682. /**
  34683. * Adds the given geometry to this scene
  34684. * @param newGeometry The geometry to add
  34685. */
  34686. addGeometry(newGeometry: Geometry): void;
  34687. /**
  34688. * Adds the given action manager to this scene
  34689. * @param newActionManager The action manager to add
  34690. */
  34691. addActionManager(newActionManager: AbstractActionManager): void;
  34692. /**
  34693. * Adds the given texture to this scene.
  34694. * @param newTexture The texture to add
  34695. */
  34696. addTexture(newTexture: BaseTexture): void;
  34697. /**
  34698. * Switch active camera
  34699. * @param newCamera defines the new active camera
  34700. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34701. */
  34702. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34703. /**
  34704. * sets the active camera of the scene using its ID
  34705. * @param id defines the camera's ID
  34706. * @return the new active camera or null if none found.
  34707. */
  34708. setActiveCameraByID(id: string): Nullable<Camera>;
  34709. /**
  34710. * sets the active camera of the scene using its name
  34711. * @param name defines the camera's name
  34712. * @returns the new active camera or null if none found.
  34713. */
  34714. setActiveCameraByName(name: string): Nullable<Camera>;
  34715. /**
  34716. * get an animation group using its name
  34717. * @param name defines the material's name
  34718. * @return the animation group or null if none found.
  34719. */
  34720. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34721. /**
  34722. * Get a material using its unique id
  34723. * @param uniqueId defines the material's unique id
  34724. * @return the material or null if none found.
  34725. */
  34726. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34727. /**
  34728. * get a material using its id
  34729. * @param id defines the material's ID
  34730. * @return the material or null if none found.
  34731. */
  34732. getMaterialByID(id: string): Nullable<Material>;
  34733. /**
  34734. * Gets a the last added material using a given id
  34735. * @param id defines the material's ID
  34736. * @return the last material with the given id or null if none found.
  34737. */
  34738. getLastMaterialByID(id: string): Nullable<Material>;
  34739. /**
  34740. * Gets a material using its name
  34741. * @param name defines the material's name
  34742. * @return the material or null if none found.
  34743. */
  34744. getMaterialByName(name: string): Nullable<Material>;
  34745. /**
  34746. * Gets a camera using its id
  34747. * @param id defines the id to look for
  34748. * @returns the camera or null if not found
  34749. */
  34750. getCameraByID(id: string): Nullable<Camera>;
  34751. /**
  34752. * Gets a camera using its unique id
  34753. * @param uniqueId defines the unique id to look for
  34754. * @returns the camera or null if not found
  34755. */
  34756. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34757. /**
  34758. * Gets a camera using its name
  34759. * @param name defines the camera's name
  34760. * @return the camera or null if none found.
  34761. */
  34762. getCameraByName(name: string): Nullable<Camera>;
  34763. /**
  34764. * Gets a bone using its id
  34765. * @param id defines the bone's id
  34766. * @return the bone or null if not found
  34767. */
  34768. getBoneByID(id: string): Nullable<Bone>;
  34769. /**
  34770. * Gets a bone using its id
  34771. * @param name defines the bone's name
  34772. * @return the bone or null if not found
  34773. */
  34774. getBoneByName(name: string): Nullable<Bone>;
  34775. /**
  34776. * Gets a light node using its name
  34777. * @param name defines the the light's name
  34778. * @return the light or null if none found.
  34779. */
  34780. getLightByName(name: string): Nullable<Light>;
  34781. /**
  34782. * Gets a light node using its id
  34783. * @param id defines the light's id
  34784. * @return the light or null if none found.
  34785. */
  34786. getLightByID(id: string): Nullable<Light>;
  34787. /**
  34788. * Gets a light node using its scene-generated unique ID
  34789. * @param uniqueId defines the light's unique id
  34790. * @return the light or null if none found.
  34791. */
  34792. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34793. /**
  34794. * Gets a particle system by id
  34795. * @param id defines the particle system id
  34796. * @return the corresponding system or null if none found
  34797. */
  34798. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34799. /**
  34800. * Gets a geometry using its ID
  34801. * @param id defines the geometry's id
  34802. * @return the geometry or null if none found.
  34803. */
  34804. getGeometryByID(id: string): Nullable<Geometry>;
  34805. private _getGeometryByUniqueID;
  34806. /**
  34807. * Add a new geometry to this scene
  34808. * @param geometry defines the geometry to be added to the scene.
  34809. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34810. * @return a boolean defining if the geometry was added or not
  34811. */
  34812. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34813. /**
  34814. * Removes an existing geometry
  34815. * @param geometry defines the geometry to be removed from the scene
  34816. * @return a boolean defining if the geometry was removed or not
  34817. */
  34818. removeGeometry(geometry: Geometry): boolean;
  34819. /**
  34820. * Gets the list of geometries attached to the scene
  34821. * @returns an array of Geometry
  34822. */
  34823. getGeometries(): Geometry[];
  34824. /**
  34825. * Gets the first added mesh found of a given ID
  34826. * @param id defines the id to search for
  34827. * @return the mesh found or null if not found at all
  34828. */
  34829. getMeshByID(id: string): Nullable<AbstractMesh>;
  34830. /**
  34831. * Gets a list of meshes using their id
  34832. * @param id defines the id to search for
  34833. * @returns a list of meshes
  34834. */
  34835. getMeshesByID(id: string): Array<AbstractMesh>;
  34836. /**
  34837. * Gets the first added transform node found of a given ID
  34838. * @param id defines the id to search for
  34839. * @return the found transform node or null if not found at all.
  34840. */
  34841. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34842. /**
  34843. * Gets a transform node with its auto-generated unique id
  34844. * @param uniqueId efines the unique id to search for
  34845. * @return the found transform node or null if not found at all.
  34846. */
  34847. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34848. /**
  34849. * Gets a list of transform nodes using their id
  34850. * @param id defines the id to search for
  34851. * @returns a list of transform nodes
  34852. */
  34853. getTransformNodesByID(id: string): Array<TransformNode>;
  34854. /**
  34855. * Gets a mesh with its auto-generated unique id
  34856. * @param uniqueId defines the unique id to search for
  34857. * @return the found mesh or null if not found at all.
  34858. */
  34859. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34860. /**
  34861. * Gets a the last added mesh using a given id
  34862. * @param id defines the id to search for
  34863. * @return the found mesh or null if not found at all.
  34864. */
  34865. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34866. /**
  34867. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34868. * @param id defines the id to search for
  34869. * @return the found node or null if not found at all
  34870. */
  34871. getLastEntryByID(id: string): Nullable<Node>;
  34872. /**
  34873. * Gets a node (Mesh, Camera, Light) using a given id
  34874. * @param id defines the id to search for
  34875. * @return the found node or null if not found at all
  34876. */
  34877. getNodeByID(id: string): Nullable<Node>;
  34878. /**
  34879. * Gets a node (Mesh, Camera, Light) using a given name
  34880. * @param name defines the name to search for
  34881. * @return the found node or null if not found at all.
  34882. */
  34883. getNodeByName(name: string): Nullable<Node>;
  34884. /**
  34885. * Gets a mesh using a given name
  34886. * @param name defines the name to search for
  34887. * @return the found mesh or null if not found at all.
  34888. */
  34889. getMeshByName(name: string): Nullable<AbstractMesh>;
  34890. /**
  34891. * Gets a transform node using a given name
  34892. * @param name defines the name to search for
  34893. * @return the found transform node or null if not found at all.
  34894. */
  34895. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34896. /**
  34897. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34898. * @param id defines the id to search for
  34899. * @return the found skeleton or null if not found at all.
  34900. */
  34901. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34902. /**
  34903. * Gets a skeleton using a given auto generated unique id
  34904. * @param uniqueId defines the unique id to search for
  34905. * @return the found skeleton or null if not found at all.
  34906. */
  34907. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34908. /**
  34909. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34910. * @param id defines the id to search for
  34911. * @return the found skeleton or null if not found at all.
  34912. */
  34913. getSkeletonById(id: string): Nullable<Skeleton>;
  34914. /**
  34915. * Gets a skeleton using a given name
  34916. * @param name defines the name to search for
  34917. * @return the found skeleton or null if not found at all.
  34918. */
  34919. getSkeletonByName(name: string): Nullable<Skeleton>;
  34920. /**
  34921. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34922. * @param id defines the id to search for
  34923. * @return the found morph target manager or null if not found at all.
  34924. */
  34925. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34926. /**
  34927. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34928. * @param id defines the id to search for
  34929. * @return the found morph target or null if not found at all.
  34930. */
  34931. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34932. /**
  34933. * Gets a boolean indicating if the given mesh is active
  34934. * @param mesh defines the mesh to look for
  34935. * @returns true if the mesh is in the active list
  34936. */
  34937. isActiveMesh(mesh: AbstractMesh): boolean;
  34938. /**
  34939. * Return a unique id as a string which can serve as an identifier for the scene
  34940. */
  34941. readonly uid: string;
  34942. /**
  34943. * Add an externaly attached data from its key.
  34944. * This method call will fail and return false, if such key already exists.
  34945. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34946. * @param key the unique key that identifies the data
  34947. * @param data the data object to associate to the key for this Engine instance
  34948. * @return true if no such key were already present and the data was added successfully, false otherwise
  34949. */
  34950. addExternalData<T>(key: string, data: T): boolean;
  34951. /**
  34952. * Get an externaly attached data from its key
  34953. * @param key the unique key that identifies the data
  34954. * @return the associated data, if present (can be null), or undefined if not present
  34955. */
  34956. getExternalData<T>(key: string): Nullable<T>;
  34957. /**
  34958. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34959. * @param key the unique key that identifies the data
  34960. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34961. * @return the associated data, can be null if the factory returned null.
  34962. */
  34963. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34964. /**
  34965. * Remove an externaly attached data from the Engine instance
  34966. * @param key the unique key that identifies the data
  34967. * @return true if the data was successfully removed, false if it doesn't exist
  34968. */
  34969. removeExternalData(key: string): boolean;
  34970. private _evaluateSubMesh;
  34971. /**
  34972. * Clear the processed materials smart array preventing retention point in material dispose.
  34973. */
  34974. freeProcessedMaterials(): void;
  34975. private _preventFreeActiveMeshesAndRenderingGroups;
  34976. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34977. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34978. * when disposing several meshes in a row or a hierarchy of meshes.
  34979. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34980. */
  34981. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34982. /**
  34983. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34984. */
  34985. freeActiveMeshes(): void;
  34986. /**
  34987. * Clear the info related to rendering groups preventing retention points during dispose.
  34988. */
  34989. freeRenderingGroups(): void;
  34990. /** @hidden */
  34991. _isInIntermediateRendering(): boolean;
  34992. /**
  34993. * Lambda returning the list of potentially active meshes.
  34994. */
  34995. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34996. /**
  34997. * Lambda returning the list of potentially active sub meshes.
  34998. */
  34999. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35000. /**
  35001. * Lambda returning the list of potentially intersecting sub meshes.
  35002. */
  35003. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35004. /**
  35005. * Lambda returning the list of potentially colliding sub meshes.
  35006. */
  35007. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35008. private _activeMeshesFrozen;
  35009. /**
  35010. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35011. * @returns the current scene
  35012. */
  35013. freezeActiveMeshes(): Scene;
  35014. /**
  35015. * Use this function to restart evaluating active meshes on every frame
  35016. * @returns the current scene
  35017. */
  35018. unfreezeActiveMeshes(): Scene;
  35019. private _evaluateActiveMeshes;
  35020. private _activeMesh;
  35021. /**
  35022. * Update the transform matrix to update from the current active camera
  35023. * @param force defines a boolean used to force the update even if cache is up to date
  35024. */
  35025. updateTransformMatrix(force?: boolean): void;
  35026. private _bindFrameBuffer;
  35027. /** @hidden */
  35028. _allowPostProcessClearColor: boolean;
  35029. /** @hidden */
  35030. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35031. private _processSubCameras;
  35032. private _checkIntersections;
  35033. /** @hidden */
  35034. _advancePhysicsEngineStep(step: number): void;
  35035. /**
  35036. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35037. */
  35038. getDeterministicFrameTime: () => number;
  35039. /** @hidden */
  35040. _animate(): void;
  35041. /** Execute all animations (for a frame) */
  35042. animate(): void;
  35043. /**
  35044. * Render the scene
  35045. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35046. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35047. */
  35048. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35049. /**
  35050. * Freeze all materials
  35051. * A frozen material will not be updatable but should be faster to render
  35052. */
  35053. freezeMaterials(): void;
  35054. /**
  35055. * Unfreeze all materials
  35056. * A frozen material will not be updatable but should be faster to render
  35057. */
  35058. unfreezeMaterials(): void;
  35059. /**
  35060. * Releases all held ressources
  35061. */
  35062. dispose(): void;
  35063. /**
  35064. * Gets if the scene is already disposed
  35065. */
  35066. readonly isDisposed: boolean;
  35067. /**
  35068. * Call this function to reduce memory footprint of the scene.
  35069. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35070. */
  35071. clearCachedVertexData(): void;
  35072. /**
  35073. * This function will remove the local cached buffer data from texture.
  35074. * It will save memory but will prevent the texture from being rebuilt
  35075. */
  35076. cleanCachedTextureBuffer(): void;
  35077. /**
  35078. * Get the world extend vectors with an optional filter
  35079. *
  35080. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35081. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35082. */
  35083. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35084. min: Vector3;
  35085. max: Vector3;
  35086. };
  35087. /**
  35088. * Creates a ray that can be used to pick in the scene
  35089. * @param x defines the x coordinate of the origin (on-screen)
  35090. * @param y defines the y coordinate of the origin (on-screen)
  35091. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35092. * @param camera defines the camera to use for the picking
  35093. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35094. * @returns a Ray
  35095. */
  35096. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35097. /**
  35098. * Creates a ray that can be used to pick in the scene
  35099. * @param x defines the x coordinate of the origin (on-screen)
  35100. * @param y defines the y coordinate of the origin (on-screen)
  35101. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35102. * @param result defines the ray where to store the picking ray
  35103. * @param camera defines the camera to use for the picking
  35104. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35105. * @returns the current scene
  35106. */
  35107. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35108. /**
  35109. * Creates a ray that can be used to pick in the scene
  35110. * @param x defines the x coordinate of the origin (on-screen)
  35111. * @param y defines the y coordinate of the origin (on-screen)
  35112. * @param camera defines the camera to use for the picking
  35113. * @returns a Ray
  35114. */
  35115. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35116. /**
  35117. * Creates a ray that can be used to pick in the scene
  35118. * @param x defines the x coordinate of the origin (on-screen)
  35119. * @param y defines the y coordinate of the origin (on-screen)
  35120. * @param result defines the ray where to store the picking ray
  35121. * @param camera defines the camera to use for the picking
  35122. * @returns the current scene
  35123. */
  35124. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35125. /** Launch a ray to try to pick a mesh in the scene
  35126. * @param x position on screen
  35127. * @param y position on screen
  35128. * @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
  35129. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35130. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35131. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35132. * @returns a PickingInfo
  35133. */
  35134. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35135. /** Use the given ray to pick a mesh in the scene
  35136. * @param ray The ray to use to pick meshes
  35137. * @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
  35138. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35139. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35140. * @returns a PickingInfo
  35141. */
  35142. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35143. /**
  35144. * Launch a ray to try to pick a mesh in the scene
  35145. * @param x X position on screen
  35146. * @param y Y position on screen
  35147. * @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
  35148. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35149. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35150. * @returns an array of PickingInfo
  35151. */
  35152. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35153. /**
  35154. * Launch a ray to try to pick a mesh in the scene
  35155. * @param ray Ray to use
  35156. * @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
  35157. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35158. * @returns an array of PickingInfo
  35159. */
  35160. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35161. /**
  35162. * Force the value of meshUnderPointer
  35163. * @param mesh defines the mesh to use
  35164. */
  35165. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35166. /**
  35167. * Gets the mesh under the pointer
  35168. * @returns a Mesh or null if no mesh is under the pointer
  35169. */
  35170. getPointerOverMesh(): Nullable<AbstractMesh>;
  35171. /** @hidden */
  35172. _rebuildGeometries(): void;
  35173. /** @hidden */
  35174. _rebuildTextures(): void;
  35175. private _getByTags;
  35176. /**
  35177. * Get a list of meshes by tags
  35178. * @param tagsQuery defines the tags query to use
  35179. * @param forEach defines a predicate used to filter results
  35180. * @returns an array of Mesh
  35181. */
  35182. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35183. /**
  35184. * Get a list of cameras by tags
  35185. * @param tagsQuery defines the tags query to use
  35186. * @param forEach defines a predicate used to filter results
  35187. * @returns an array of Camera
  35188. */
  35189. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35190. /**
  35191. * Get a list of lights by tags
  35192. * @param tagsQuery defines the tags query to use
  35193. * @param forEach defines a predicate used to filter results
  35194. * @returns an array of Light
  35195. */
  35196. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35197. /**
  35198. * Get a list of materials by tags
  35199. * @param tagsQuery defines the tags query to use
  35200. * @param forEach defines a predicate used to filter results
  35201. * @returns an array of Material
  35202. */
  35203. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35204. /**
  35205. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35206. * This allowed control for front to back rendering or reversly depending of the special needs.
  35207. *
  35208. * @param renderingGroupId The rendering group id corresponding to its index
  35209. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35210. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35211. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35212. */
  35213. 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;
  35214. /**
  35215. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35216. *
  35217. * @param renderingGroupId The rendering group id corresponding to its index
  35218. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35219. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35220. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35221. */
  35222. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35223. /**
  35224. * Gets the current auto clear configuration for one rendering group of the rendering
  35225. * manager.
  35226. * @param index the rendering group index to get the information for
  35227. * @returns The auto clear setup for the requested rendering group
  35228. */
  35229. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35230. private _blockMaterialDirtyMechanism;
  35231. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35232. blockMaterialDirtyMechanism: boolean;
  35233. /**
  35234. * Will flag all materials as dirty to trigger new shader compilation
  35235. * @param flag defines the flag used to specify which material part must be marked as dirty
  35236. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35237. */
  35238. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35239. /** @hidden */
  35240. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35241. /** @hidden */
  35242. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35243. }
  35244. }
  35245. declare module "babylonjs/assetContainer" {
  35246. import { AbstractScene } from "babylonjs/abstractScene";
  35247. import { Scene } from "babylonjs/scene";
  35248. import { Mesh } from "babylonjs/Meshes/mesh";
  35249. /**
  35250. * Set of assets to keep when moving a scene into an asset container.
  35251. */
  35252. export class KeepAssets extends AbstractScene {
  35253. }
  35254. /**
  35255. * Container with a set of assets that can be added or removed from a scene.
  35256. */
  35257. export class AssetContainer extends AbstractScene {
  35258. /**
  35259. * The scene the AssetContainer belongs to.
  35260. */
  35261. scene: Scene;
  35262. /**
  35263. * Instantiates an AssetContainer.
  35264. * @param scene The scene the AssetContainer belongs to.
  35265. */
  35266. constructor(scene: Scene);
  35267. /**
  35268. * Adds all the assets from the container to the scene.
  35269. */
  35270. addAllToScene(): void;
  35271. /**
  35272. * Removes all the assets in the container from the scene
  35273. */
  35274. removeAllFromScene(): void;
  35275. /**
  35276. * Disposes all the assets in the container
  35277. */
  35278. dispose(): void;
  35279. private _moveAssets;
  35280. /**
  35281. * Removes all the assets contained in the scene and adds them to the container.
  35282. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35283. */
  35284. moveAllFromScene(keepAssets?: KeepAssets): void;
  35285. /**
  35286. * 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.
  35287. * @returns the root mesh
  35288. */
  35289. createRootMesh(): Mesh;
  35290. }
  35291. }
  35292. declare module "babylonjs/abstractScene" {
  35293. import { Scene } from "babylonjs/scene";
  35294. import { Nullable } from "babylonjs/types";
  35295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35297. import { Geometry } from "babylonjs/Meshes/geometry";
  35298. import { Skeleton } from "babylonjs/Bones/skeleton";
  35299. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35300. import { AssetContainer } from "babylonjs/assetContainer";
  35301. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35302. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35303. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35304. import { Material } from "babylonjs/Materials/material";
  35305. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35306. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35307. import { Camera } from "babylonjs/Cameras/camera";
  35308. import { Light } from "babylonjs/Lights/light";
  35309. import { Node } from "babylonjs/node";
  35310. import { Animation } from "babylonjs/Animations/animation";
  35311. /**
  35312. * Defines how the parser contract is defined.
  35313. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35314. */
  35315. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35316. /**
  35317. * Defines how the individual parser contract is defined.
  35318. * These parser can parse an individual asset
  35319. */
  35320. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35321. /**
  35322. * Base class of the scene acting as a container for the different elements composing a scene.
  35323. * This class is dynamically extended by the different components of the scene increasing
  35324. * flexibility and reducing coupling
  35325. */
  35326. export abstract class AbstractScene {
  35327. /**
  35328. * Stores the list of available parsers in the application.
  35329. */
  35330. private static _BabylonFileParsers;
  35331. /**
  35332. * Stores the list of available individual parsers in the application.
  35333. */
  35334. private static _IndividualBabylonFileParsers;
  35335. /**
  35336. * Adds a parser in the list of available ones
  35337. * @param name Defines the name of the parser
  35338. * @param parser Defines the parser to add
  35339. */
  35340. static AddParser(name: string, parser: BabylonFileParser): void;
  35341. /**
  35342. * Gets a general parser from the list of avaialble ones
  35343. * @param name Defines the name of the parser
  35344. * @returns the requested parser or null
  35345. */
  35346. static GetParser(name: string): Nullable<BabylonFileParser>;
  35347. /**
  35348. * Adds n individual parser in the list of available ones
  35349. * @param name Defines the name of the parser
  35350. * @param parser Defines the parser to add
  35351. */
  35352. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35353. /**
  35354. * Gets an individual parser from the list of avaialble ones
  35355. * @param name Defines the name of the parser
  35356. * @returns the requested parser or null
  35357. */
  35358. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35359. /**
  35360. * Parser json data and populate both a scene and its associated container object
  35361. * @param jsonData Defines the data to parse
  35362. * @param scene Defines the scene to parse the data for
  35363. * @param container Defines the container attached to the parsing sequence
  35364. * @param rootUrl Defines the root url of the data
  35365. */
  35366. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35367. /**
  35368. * Gets the list of root nodes (ie. nodes with no parent)
  35369. */
  35370. rootNodes: Node[];
  35371. /** All of the cameras added to this scene
  35372. * @see http://doc.babylonjs.com/babylon101/cameras
  35373. */
  35374. cameras: Camera[];
  35375. /**
  35376. * All of the lights added to this scene
  35377. * @see http://doc.babylonjs.com/babylon101/lights
  35378. */
  35379. lights: Light[];
  35380. /**
  35381. * All of the (abstract) meshes added to this scene
  35382. */
  35383. meshes: AbstractMesh[];
  35384. /**
  35385. * The list of skeletons added to the scene
  35386. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35387. */
  35388. skeletons: Skeleton[];
  35389. /**
  35390. * All of the particle systems added to this scene
  35391. * @see http://doc.babylonjs.com/babylon101/particles
  35392. */
  35393. particleSystems: IParticleSystem[];
  35394. /**
  35395. * Gets a list of Animations associated with the scene
  35396. */
  35397. animations: Animation[];
  35398. /**
  35399. * All of the animation groups added to this scene
  35400. * @see http://doc.babylonjs.com/how_to/group
  35401. */
  35402. animationGroups: AnimationGroup[];
  35403. /**
  35404. * All of the multi-materials added to this scene
  35405. * @see http://doc.babylonjs.com/how_to/multi_materials
  35406. */
  35407. multiMaterials: MultiMaterial[];
  35408. /**
  35409. * All of the materials added to this scene
  35410. * In the context of a Scene, it is not supposed to be modified manually.
  35411. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35412. * Note also that the order of the Material wihin the array is not significant and might change.
  35413. * @see http://doc.babylonjs.com/babylon101/materials
  35414. */
  35415. materials: Material[];
  35416. /**
  35417. * The list of morph target managers added to the scene
  35418. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35419. */
  35420. morphTargetManagers: MorphTargetManager[];
  35421. /**
  35422. * The list of geometries used in the scene.
  35423. */
  35424. geometries: Geometry[];
  35425. /**
  35426. * All of the tranform nodes added to this scene
  35427. * In the context of a Scene, it is not supposed to be modified manually.
  35428. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35429. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35430. * @see http://doc.babylonjs.com/how_to/transformnode
  35431. */
  35432. transformNodes: TransformNode[];
  35433. /**
  35434. * ActionManagers available on the scene.
  35435. */
  35436. actionManagers: AbstractActionManager[];
  35437. /**
  35438. * Textures to keep.
  35439. */
  35440. textures: BaseTexture[];
  35441. /**
  35442. * Environment texture for the scene
  35443. */
  35444. environmentTexture: Nullable<BaseTexture>;
  35445. }
  35446. }
  35447. declare module "babylonjs/Audio/sound" {
  35448. import { Observable } from "babylonjs/Misc/observable";
  35449. import { Vector3 } from "babylonjs/Maths/math.vector";
  35450. import { Nullable } from "babylonjs/types";
  35451. import { Scene } from "babylonjs/scene";
  35452. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35453. /**
  35454. * Interface used to define options for Sound class
  35455. */
  35456. export interface ISoundOptions {
  35457. /**
  35458. * Does the sound autoplay once loaded.
  35459. */
  35460. autoplay?: boolean;
  35461. /**
  35462. * Does the sound loop after it finishes playing once.
  35463. */
  35464. loop?: boolean;
  35465. /**
  35466. * Sound's volume
  35467. */
  35468. volume?: number;
  35469. /**
  35470. * Is it a spatial sound?
  35471. */
  35472. spatialSound?: boolean;
  35473. /**
  35474. * Maximum distance to hear that sound
  35475. */
  35476. maxDistance?: number;
  35477. /**
  35478. * Uses user defined attenuation function
  35479. */
  35480. useCustomAttenuation?: boolean;
  35481. /**
  35482. * Define the roll off factor of spatial sounds.
  35483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35484. */
  35485. rolloffFactor?: number;
  35486. /**
  35487. * Define the reference distance the sound should be heard perfectly.
  35488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35489. */
  35490. refDistance?: number;
  35491. /**
  35492. * Define the distance attenuation model the sound will follow.
  35493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35494. */
  35495. distanceModel?: string;
  35496. /**
  35497. * Defines the playback speed (1 by default)
  35498. */
  35499. playbackRate?: number;
  35500. /**
  35501. * Defines if the sound is from a streaming source
  35502. */
  35503. streaming?: boolean;
  35504. /**
  35505. * Defines an optional length (in seconds) inside the sound file
  35506. */
  35507. length?: number;
  35508. /**
  35509. * Defines an optional offset (in seconds) inside the sound file
  35510. */
  35511. offset?: number;
  35512. /**
  35513. * If true, URLs will not be required to state the audio file codec to use.
  35514. */
  35515. skipCodecCheck?: boolean;
  35516. }
  35517. /**
  35518. * Defines a sound that can be played in the application.
  35519. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35521. */
  35522. export class Sound {
  35523. /**
  35524. * The name of the sound in the scene.
  35525. */
  35526. name: string;
  35527. /**
  35528. * Does the sound autoplay once loaded.
  35529. */
  35530. autoplay: boolean;
  35531. /**
  35532. * Does the sound loop after it finishes playing once.
  35533. */
  35534. loop: boolean;
  35535. /**
  35536. * Does the sound use a custom attenuation curve to simulate the falloff
  35537. * happening when the source gets further away from the camera.
  35538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35539. */
  35540. useCustomAttenuation: boolean;
  35541. /**
  35542. * The sound track id this sound belongs to.
  35543. */
  35544. soundTrackId: number;
  35545. /**
  35546. * Is this sound currently played.
  35547. */
  35548. isPlaying: boolean;
  35549. /**
  35550. * Is this sound currently paused.
  35551. */
  35552. isPaused: boolean;
  35553. /**
  35554. * Does this sound enables spatial sound.
  35555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35556. */
  35557. spatialSound: boolean;
  35558. /**
  35559. * Define the reference distance the sound should be heard perfectly.
  35560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35561. */
  35562. refDistance: number;
  35563. /**
  35564. * Define the roll off factor of spatial sounds.
  35565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35566. */
  35567. rolloffFactor: number;
  35568. /**
  35569. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35571. */
  35572. maxDistance: number;
  35573. /**
  35574. * Define the distance attenuation model the sound will follow.
  35575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35576. */
  35577. distanceModel: string;
  35578. /**
  35579. * @hidden
  35580. * Back Compat
  35581. **/
  35582. onended: () => any;
  35583. /**
  35584. * Observable event when the current playing sound finishes.
  35585. */
  35586. onEndedObservable: Observable<Sound>;
  35587. private _panningModel;
  35588. private _playbackRate;
  35589. private _streaming;
  35590. private _startTime;
  35591. private _startOffset;
  35592. private _position;
  35593. /** @hidden */
  35594. _positionInEmitterSpace: boolean;
  35595. private _localDirection;
  35596. private _volume;
  35597. private _isReadyToPlay;
  35598. private _isDirectional;
  35599. private _readyToPlayCallback;
  35600. private _audioBuffer;
  35601. private _soundSource;
  35602. private _streamingSource;
  35603. private _soundPanner;
  35604. private _soundGain;
  35605. private _inputAudioNode;
  35606. private _outputAudioNode;
  35607. private _coneInnerAngle;
  35608. private _coneOuterAngle;
  35609. private _coneOuterGain;
  35610. private _scene;
  35611. private _connectedTransformNode;
  35612. private _customAttenuationFunction;
  35613. private _registerFunc;
  35614. private _isOutputConnected;
  35615. private _htmlAudioElement;
  35616. private _urlType;
  35617. private _length?;
  35618. private _offset?;
  35619. /** @hidden */
  35620. static _SceneComponentInitialization: (scene: Scene) => void;
  35621. /**
  35622. * Create a sound and attach it to a scene
  35623. * @param name Name of your sound
  35624. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35625. * @param scene defines the scene the sound belongs to
  35626. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35627. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35628. */
  35629. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35630. /**
  35631. * Release the sound and its associated resources
  35632. */
  35633. dispose(): void;
  35634. /**
  35635. * Gets if the sounds is ready to be played or not.
  35636. * @returns true if ready, otherwise false
  35637. */
  35638. isReady(): boolean;
  35639. private _soundLoaded;
  35640. /**
  35641. * Sets the data of the sound from an audiobuffer
  35642. * @param audioBuffer The audioBuffer containing the data
  35643. */
  35644. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35645. /**
  35646. * Updates the current sounds options such as maxdistance, loop...
  35647. * @param options A JSON object containing values named as the object properties
  35648. */
  35649. updateOptions(options: ISoundOptions): void;
  35650. private _createSpatialParameters;
  35651. private _updateSpatialParameters;
  35652. /**
  35653. * Switch the panning model to HRTF:
  35654. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35656. */
  35657. switchPanningModelToHRTF(): void;
  35658. /**
  35659. * Switch the panning model to Equal Power:
  35660. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35662. */
  35663. switchPanningModelToEqualPower(): void;
  35664. private _switchPanningModel;
  35665. /**
  35666. * Connect this sound to a sound track audio node like gain...
  35667. * @param soundTrackAudioNode the sound track audio node to connect to
  35668. */
  35669. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35670. /**
  35671. * Transform this sound into a directional source
  35672. * @param coneInnerAngle Size of the inner cone in degree
  35673. * @param coneOuterAngle Size of the outer cone in degree
  35674. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35675. */
  35676. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35677. /**
  35678. * Gets or sets the inner angle for the directional cone.
  35679. */
  35680. /**
  35681. * Gets or sets the inner angle for the directional cone.
  35682. */
  35683. directionalConeInnerAngle: number;
  35684. /**
  35685. * Gets or sets the outer angle for the directional cone.
  35686. */
  35687. /**
  35688. * Gets or sets the outer angle for the directional cone.
  35689. */
  35690. directionalConeOuterAngle: number;
  35691. /**
  35692. * Sets the position of the emitter if spatial sound is enabled
  35693. * @param newPosition Defines the new posisiton
  35694. */
  35695. setPosition(newPosition: Vector3): void;
  35696. /**
  35697. * Sets the local direction of the emitter if spatial sound is enabled
  35698. * @param newLocalDirection Defines the new local direction
  35699. */
  35700. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35701. private _updateDirection;
  35702. /** @hidden */
  35703. updateDistanceFromListener(): void;
  35704. /**
  35705. * Sets a new custom attenuation function for the sound.
  35706. * @param callback Defines the function used for the attenuation
  35707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35708. */
  35709. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35710. /**
  35711. * Play the sound
  35712. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35713. * @param offset (optional) Start the sound at a specific time in seconds
  35714. * @param length (optional) Sound duration (in seconds)
  35715. */
  35716. play(time?: number, offset?: number, length?: number): void;
  35717. private _onended;
  35718. /**
  35719. * Stop the sound
  35720. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35721. */
  35722. stop(time?: number): void;
  35723. /**
  35724. * Put the sound in pause
  35725. */
  35726. pause(): void;
  35727. /**
  35728. * Sets a dedicated volume for this sounds
  35729. * @param newVolume Define the new volume of the sound
  35730. * @param time Define time for gradual change to new volume
  35731. */
  35732. setVolume(newVolume: number, time?: number): void;
  35733. /**
  35734. * Set the sound play back rate
  35735. * @param newPlaybackRate Define the playback rate the sound should be played at
  35736. */
  35737. setPlaybackRate(newPlaybackRate: number): void;
  35738. /**
  35739. * Gets the volume of the sound.
  35740. * @returns the volume of the sound
  35741. */
  35742. getVolume(): number;
  35743. /**
  35744. * Attach the sound to a dedicated mesh
  35745. * @param transformNode The transform node to connect the sound with
  35746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35747. */
  35748. attachToMesh(transformNode: TransformNode): void;
  35749. /**
  35750. * Detach the sound from the previously attached mesh
  35751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35752. */
  35753. detachFromMesh(): void;
  35754. private _onRegisterAfterWorldMatrixUpdate;
  35755. /**
  35756. * Clone the current sound in the scene.
  35757. * @returns the new sound clone
  35758. */
  35759. clone(): Nullable<Sound>;
  35760. /**
  35761. * Gets the current underlying audio buffer containing the data
  35762. * @returns the audio buffer
  35763. */
  35764. getAudioBuffer(): Nullable<AudioBuffer>;
  35765. /**
  35766. * Serializes the Sound in a JSON representation
  35767. * @returns the JSON representation of the sound
  35768. */
  35769. serialize(): any;
  35770. /**
  35771. * Parse a JSON representation of a sound to innstantiate in a given scene
  35772. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35773. * @param scene Define the scene the new parsed sound should be created in
  35774. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35775. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35776. * @returns the newly parsed sound
  35777. */
  35778. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35779. }
  35780. }
  35781. declare module "babylonjs/Actions/directAudioActions" {
  35782. import { Action } from "babylonjs/Actions/action";
  35783. import { Condition } from "babylonjs/Actions/condition";
  35784. import { Sound } from "babylonjs/Audio/sound";
  35785. /**
  35786. * This defines an action helpful to play a defined sound on a triggered action.
  35787. */
  35788. export class PlaySoundAction extends Action {
  35789. private _sound;
  35790. /**
  35791. * Instantiate the action
  35792. * @param triggerOptions defines the trigger options
  35793. * @param sound defines the sound to play
  35794. * @param condition defines the trigger related conditions
  35795. */
  35796. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35797. /** @hidden */
  35798. _prepare(): void;
  35799. /**
  35800. * Execute the action and play the sound.
  35801. */
  35802. execute(): void;
  35803. /**
  35804. * Serializes the actions and its related information.
  35805. * @param parent defines the object to serialize in
  35806. * @returns the serialized object
  35807. */
  35808. serialize(parent: any): any;
  35809. }
  35810. /**
  35811. * This defines an action helpful to stop a defined sound on a triggered action.
  35812. */
  35813. export class StopSoundAction extends Action {
  35814. private _sound;
  35815. /**
  35816. * Instantiate the action
  35817. * @param triggerOptions defines the trigger options
  35818. * @param sound defines the sound to stop
  35819. * @param condition defines the trigger related conditions
  35820. */
  35821. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35822. /** @hidden */
  35823. _prepare(): void;
  35824. /**
  35825. * Execute the action and stop the sound.
  35826. */
  35827. execute(): void;
  35828. /**
  35829. * Serializes the actions and its related information.
  35830. * @param parent defines the object to serialize in
  35831. * @returns the serialized object
  35832. */
  35833. serialize(parent: any): any;
  35834. }
  35835. }
  35836. declare module "babylonjs/Actions/interpolateValueAction" {
  35837. import { Action } from "babylonjs/Actions/action";
  35838. import { Condition } from "babylonjs/Actions/condition";
  35839. import { Observable } from "babylonjs/Misc/observable";
  35840. /**
  35841. * This defines an action responsible to change the value of a property
  35842. * by interpolating between its current value and the newly set one once triggered.
  35843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35844. */
  35845. export class InterpolateValueAction extends Action {
  35846. /**
  35847. * Defines the path of the property where the value should be interpolated
  35848. */
  35849. propertyPath: string;
  35850. /**
  35851. * Defines the target value at the end of the interpolation.
  35852. */
  35853. value: any;
  35854. /**
  35855. * Defines the time it will take for the property to interpolate to the value.
  35856. */
  35857. duration: number;
  35858. /**
  35859. * Defines if the other scene animations should be stopped when the action has been triggered
  35860. */
  35861. stopOtherAnimations?: boolean;
  35862. /**
  35863. * Defines a callback raised once the interpolation animation has been done.
  35864. */
  35865. onInterpolationDone?: () => void;
  35866. /**
  35867. * Observable triggered once the interpolation animation has been done.
  35868. */
  35869. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35870. private _target;
  35871. private _effectiveTarget;
  35872. private _property;
  35873. /**
  35874. * Instantiate the action
  35875. * @param triggerOptions defines the trigger options
  35876. * @param target defines the object containing the value to interpolate
  35877. * @param propertyPath defines the path to the property in the target object
  35878. * @param value defines the target value at the end of the interpolation
  35879. * @param duration deines the time it will take for the property to interpolate to the value.
  35880. * @param condition defines the trigger related conditions
  35881. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35882. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35883. */
  35884. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35885. /** @hidden */
  35886. _prepare(): void;
  35887. /**
  35888. * Execute the action starts the value interpolation.
  35889. */
  35890. execute(): void;
  35891. /**
  35892. * Serializes the actions and its related information.
  35893. * @param parent defines the object to serialize in
  35894. * @returns the serialized object
  35895. */
  35896. serialize(parent: any): any;
  35897. }
  35898. }
  35899. declare module "babylonjs/Actions/index" {
  35900. export * from "babylonjs/Actions/action";
  35901. export * from "babylonjs/Actions/actionEvent";
  35902. export * from "babylonjs/Actions/actionManager";
  35903. export * from "babylonjs/Actions/condition";
  35904. export * from "babylonjs/Actions/directActions";
  35905. export * from "babylonjs/Actions/directAudioActions";
  35906. export * from "babylonjs/Actions/interpolateValueAction";
  35907. }
  35908. declare module "babylonjs/Animations/index" {
  35909. export * from "babylonjs/Animations/animatable";
  35910. export * from "babylonjs/Animations/animation";
  35911. export * from "babylonjs/Animations/animationGroup";
  35912. export * from "babylonjs/Animations/animationPropertiesOverride";
  35913. export * from "babylonjs/Animations/easing";
  35914. export * from "babylonjs/Animations/runtimeAnimation";
  35915. export * from "babylonjs/Animations/animationEvent";
  35916. export * from "babylonjs/Animations/animationGroup";
  35917. export * from "babylonjs/Animations/animationKey";
  35918. export * from "babylonjs/Animations/animationRange";
  35919. export * from "babylonjs/Animations/animatable.interface";
  35920. }
  35921. declare module "babylonjs/Audio/soundTrack" {
  35922. import { Sound } from "babylonjs/Audio/sound";
  35923. import { Analyser } from "babylonjs/Audio/analyser";
  35924. import { Scene } from "babylonjs/scene";
  35925. /**
  35926. * Options allowed during the creation of a sound track.
  35927. */
  35928. export interface ISoundTrackOptions {
  35929. /**
  35930. * The volume the sound track should take during creation
  35931. */
  35932. volume?: number;
  35933. /**
  35934. * Define if the sound track is the main sound track of the scene
  35935. */
  35936. mainTrack?: boolean;
  35937. }
  35938. /**
  35939. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35940. * It will be also used in a future release to apply effects on a specific track.
  35941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35942. */
  35943. export class SoundTrack {
  35944. /**
  35945. * The unique identifier of the sound track in the scene.
  35946. */
  35947. id: number;
  35948. /**
  35949. * The list of sounds included in the sound track.
  35950. */
  35951. soundCollection: Array<Sound>;
  35952. private _outputAudioNode;
  35953. private _scene;
  35954. private _isMainTrack;
  35955. private _connectedAnalyser;
  35956. private _options;
  35957. private _isInitialized;
  35958. /**
  35959. * Creates a new sound track.
  35960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35961. * @param scene Define the scene the sound track belongs to
  35962. * @param options
  35963. */
  35964. constructor(scene: Scene, options?: ISoundTrackOptions);
  35965. private _initializeSoundTrackAudioGraph;
  35966. /**
  35967. * Release the sound track and its associated resources
  35968. */
  35969. dispose(): void;
  35970. /**
  35971. * Adds a sound to this sound track
  35972. * @param sound define the cound to add
  35973. * @ignoreNaming
  35974. */
  35975. AddSound(sound: Sound): void;
  35976. /**
  35977. * Removes a sound to this sound track
  35978. * @param sound define the cound to remove
  35979. * @ignoreNaming
  35980. */
  35981. RemoveSound(sound: Sound): void;
  35982. /**
  35983. * Set a global volume for the full sound track.
  35984. * @param newVolume Define the new volume of the sound track
  35985. */
  35986. setVolume(newVolume: number): void;
  35987. /**
  35988. * Switch the panning model to HRTF:
  35989. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35991. */
  35992. switchPanningModelToHRTF(): void;
  35993. /**
  35994. * Switch the panning model to Equal Power:
  35995. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35997. */
  35998. switchPanningModelToEqualPower(): void;
  35999. /**
  36000. * Connect the sound track to an audio analyser allowing some amazing
  36001. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36003. * @param analyser The analyser to connect to the engine
  36004. */
  36005. connectToAnalyser(analyser: Analyser): void;
  36006. }
  36007. }
  36008. declare module "babylonjs/Audio/audioSceneComponent" {
  36009. import { Sound } from "babylonjs/Audio/sound";
  36010. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36011. import { Nullable } from "babylonjs/types";
  36012. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36013. import { Scene } from "babylonjs/scene";
  36014. import { AbstractScene } from "babylonjs/abstractScene";
  36015. module "babylonjs/abstractScene" {
  36016. interface AbstractScene {
  36017. /**
  36018. * The list of sounds used in the scene.
  36019. */
  36020. sounds: Nullable<Array<Sound>>;
  36021. }
  36022. }
  36023. module "babylonjs/scene" {
  36024. interface Scene {
  36025. /**
  36026. * @hidden
  36027. * Backing field
  36028. */
  36029. _mainSoundTrack: SoundTrack;
  36030. /**
  36031. * The main sound track played by the scene.
  36032. * It cotains your primary collection of sounds.
  36033. */
  36034. mainSoundTrack: SoundTrack;
  36035. /**
  36036. * The list of sound tracks added to the scene
  36037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36038. */
  36039. soundTracks: Nullable<Array<SoundTrack>>;
  36040. /**
  36041. * Gets a sound using a given name
  36042. * @param name defines the name to search for
  36043. * @return the found sound or null if not found at all.
  36044. */
  36045. getSoundByName(name: string): Nullable<Sound>;
  36046. /**
  36047. * Gets or sets if audio support is enabled
  36048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36049. */
  36050. audioEnabled: boolean;
  36051. /**
  36052. * Gets or sets if audio will be output to headphones
  36053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36054. */
  36055. headphone: boolean;
  36056. }
  36057. }
  36058. /**
  36059. * Defines the sound scene component responsible to manage any sounds
  36060. * in a given scene.
  36061. */
  36062. export class AudioSceneComponent implements ISceneSerializableComponent {
  36063. /**
  36064. * The component name helpfull to identify the component in the list of scene components.
  36065. */
  36066. readonly name: string;
  36067. /**
  36068. * The scene the component belongs to.
  36069. */
  36070. scene: Scene;
  36071. private _audioEnabled;
  36072. /**
  36073. * Gets whether audio is enabled or not.
  36074. * Please use related enable/disable method to switch state.
  36075. */
  36076. readonly audioEnabled: boolean;
  36077. private _headphone;
  36078. /**
  36079. * Gets whether audio is outputing to headphone or not.
  36080. * Please use the according Switch methods to change output.
  36081. */
  36082. readonly headphone: boolean;
  36083. /**
  36084. * Creates a new instance of the component for the given scene
  36085. * @param scene Defines the scene to register the component in
  36086. */
  36087. constructor(scene: Scene);
  36088. /**
  36089. * Registers the component in a given scene
  36090. */
  36091. register(): void;
  36092. /**
  36093. * Rebuilds the elements related to this component in case of
  36094. * context lost for instance.
  36095. */
  36096. rebuild(): void;
  36097. /**
  36098. * Serializes the component data to the specified json object
  36099. * @param serializationObject The object to serialize to
  36100. */
  36101. serialize(serializationObject: any): void;
  36102. /**
  36103. * Adds all the elements from the container to the scene
  36104. * @param container the container holding the elements
  36105. */
  36106. addFromContainer(container: AbstractScene): void;
  36107. /**
  36108. * Removes all the elements in the container from the scene
  36109. * @param container contains the elements to remove
  36110. * @param dispose if the removed element should be disposed (default: false)
  36111. */
  36112. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36113. /**
  36114. * Disposes the component and the associated ressources.
  36115. */
  36116. dispose(): void;
  36117. /**
  36118. * Disables audio in the associated scene.
  36119. */
  36120. disableAudio(): void;
  36121. /**
  36122. * Enables audio in the associated scene.
  36123. */
  36124. enableAudio(): void;
  36125. /**
  36126. * Switch audio to headphone output.
  36127. */
  36128. switchAudioModeForHeadphones(): void;
  36129. /**
  36130. * Switch audio to normal speakers.
  36131. */
  36132. switchAudioModeForNormalSpeakers(): void;
  36133. private _afterRender;
  36134. }
  36135. }
  36136. declare module "babylonjs/Audio/weightedsound" {
  36137. import { Sound } from "babylonjs/Audio/sound";
  36138. /**
  36139. * Wraps one or more Sound objects and selects one with random weight for playback.
  36140. */
  36141. export class WeightedSound {
  36142. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36143. loop: boolean;
  36144. private _coneInnerAngle;
  36145. private _coneOuterAngle;
  36146. private _volume;
  36147. /** A Sound is currently playing. */
  36148. isPlaying: boolean;
  36149. /** A Sound is currently paused. */
  36150. isPaused: boolean;
  36151. private _sounds;
  36152. private _weights;
  36153. private _currentIndex?;
  36154. /**
  36155. * Creates a new WeightedSound from the list of sounds given.
  36156. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36157. * @param sounds Array of Sounds that will be selected from.
  36158. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36159. */
  36160. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36161. /**
  36162. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36163. */
  36164. /**
  36165. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36166. */
  36167. directionalConeInnerAngle: number;
  36168. /**
  36169. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36170. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36171. */
  36172. /**
  36173. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36174. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36175. */
  36176. directionalConeOuterAngle: number;
  36177. /**
  36178. * Playback volume.
  36179. */
  36180. /**
  36181. * Playback volume.
  36182. */
  36183. volume: number;
  36184. private _onended;
  36185. /**
  36186. * Suspend playback
  36187. */
  36188. pause(): void;
  36189. /**
  36190. * Stop playback
  36191. */
  36192. stop(): void;
  36193. /**
  36194. * Start playback.
  36195. * @param startOffset Position the clip head at a specific time in seconds.
  36196. */
  36197. play(startOffset?: number): void;
  36198. }
  36199. }
  36200. declare module "babylonjs/Audio/index" {
  36201. export * from "babylonjs/Audio/analyser";
  36202. export * from "babylonjs/Audio/audioEngine";
  36203. export * from "babylonjs/Audio/audioSceneComponent";
  36204. export * from "babylonjs/Audio/sound";
  36205. export * from "babylonjs/Audio/soundTrack";
  36206. export * from "babylonjs/Audio/weightedsound";
  36207. }
  36208. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36209. import { Behavior } from "babylonjs/Behaviors/behavior";
  36210. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36211. import { BackEase } from "babylonjs/Animations/easing";
  36212. /**
  36213. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36214. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36215. */
  36216. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36217. /**
  36218. * Gets the name of the behavior.
  36219. */
  36220. readonly name: string;
  36221. /**
  36222. * The easing function used by animations
  36223. */
  36224. static EasingFunction: BackEase;
  36225. /**
  36226. * The easing mode used by animations
  36227. */
  36228. static EasingMode: number;
  36229. /**
  36230. * The duration of the animation, in milliseconds
  36231. */
  36232. transitionDuration: number;
  36233. /**
  36234. * Length of the distance animated by the transition when lower radius is reached
  36235. */
  36236. lowerRadiusTransitionRange: number;
  36237. /**
  36238. * Length of the distance animated by the transition when upper radius is reached
  36239. */
  36240. upperRadiusTransitionRange: number;
  36241. private _autoTransitionRange;
  36242. /**
  36243. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36244. */
  36245. /**
  36246. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36247. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36248. */
  36249. autoTransitionRange: boolean;
  36250. private _attachedCamera;
  36251. private _onAfterCheckInputsObserver;
  36252. private _onMeshTargetChangedObserver;
  36253. /**
  36254. * Initializes the behavior.
  36255. */
  36256. init(): void;
  36257. /**
  36258. * Attaches the behavior to its arc rotate camera.
  36259. * @param camera Defines the camera to attach the behavior to
  36260. */
  36261. attach(camera: ArcRotateCamera): void;
  36262. /**
  36263. * Detaches the behavior from its current arc rotate camera.
  36264. */
  36265. detach(): void;
  36266. private _radiusIsAnimating;
  36267. private _radiusBounceTransition;
  36268. private _animatables;
  36269. private _cachedWheelPrecision;
  36270. /**
  36271. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36272. * @param radiusLimit The limit to check against.
  36273. * @return Bool to indicate if at limit.
  36274. */
  36275. private _isRadiusAtLimit;
  36276. /**
  36277. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36278. * @param radiusDelta The delta by which to animate to. Can be negative.
  36279. */
  36280. private _applyBoundRadiusAnimation;
  36281. /**
  36282. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36283. */
  36284. protected _clearAnimationLocks(): void;
  36285. /**
  36286. * Stops and removes all animations that have been applied to the camera
  36287. */
  36288. stopAllAnimations(): void;
  36289. }
  36290. }
  36291. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36292. import { Behavior } from "babylonjs/Behaviors/behavior";
  36293. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36294. import { ExponentialEase } from "babylonjs/Animations/easing";
  36295. import { Nullable } from "babylonjs/types";
  36296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36297. import { Vector3 } from "babylonjs/Maths/math.vector";
  36298. /**
  36299. * 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.
  36300. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36301. */
  36302. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36303. /**
  36304. * Gets the name of the behavior.
  36305. */
  36306. readonly name: string;
  36307. private _mode;
  36308. private _radiusScale;
  36309. private _positionScale;
  36310. private _defaultElevation;
  36311. private _elevationReturnTime;
  36312. private _elevationReturnWaitTime;
  36313. private _zoomStopsAnimation;
  36314. private _framingTime;
  36315. /**
  36316. * The easing function used by animations
  36317. */
  36318. static EasingFunction: ExponentialEase;
  36319. /**
  36320. * The easing mode used by animations
  36321. */
  36322. static EasingMode: number;
  36323. /**
  36324. * Sets the current mode used by the behavior
  36325. */
  36326. /**
  36327. * Gets current mode used by the behavior.
  36328. */
  36329. mode: number;
  36330. /**
  36331. * Sets the scale applied to the radius (1 by default)
  36332. */
  36333. /**
  36334. * Gets the scale applied to the radius
  36335. */
  36336. radiusScale: number;
  36337. /**
  36338. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36339. */
  36340. /**
  36341. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36342. */
  36343. positionScale: number;
  36344. /**
  36345. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36346. * behaviour is triggered, in radians.
  36347. */
  36348. /**
  36349. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36350. * behaviour is triggered, in radians.
  36351. */
  36352. defaultElevation: number;
  36353. /**
  36354. * Sets the time (in milliseconds) taken to return to the default beta position.
  36355. * Negative value indicates camera should not return to default.
  36356. */
  36357. /**
  36358. * Gets the time (in milliseconds) taken to return to the default beta position.
  36359. * Negative value indicates camera should not return to default.
  36360. */
  36361. elevationReturnTime: number;
  36362. /**
  36363. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36364. */
  36365. /**
  36366. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36367. */
  36368. elevationReturnWaitTime: number;
  36369. /**
  36370. * Sets the flag that indicates if user zooming should stop animation.
  36371. */
  36372. /**
  36373. * Gets the flag that indicates if user zooming should stop animation.
  36374. */
  36375. zoomStopsAnimation: boolean;
  36376. /**
  36377. * Sets the transition time when framing the mesh, in milliseconds
  36378. */
  36379. /**
  36380. * Gets the transition time when framing the mesh, in milliseconds
  36381. */
  36382. framingTime: number;
  36383. /**
  36384. * Define if the behavior should automatically change the configured
  36385. * camera limits and sensibilities.
  36386. */
  36387. autoCorrectCameraLimitsAndSensibility: boolean;
  36388. private _onPrePointerObservableObserver;
  36389. private _onAfterCheckInputsObserver;
  36390. private _onMeshTargetChangedObserver;
  36391. private _attachedCamera;
  36392. private _isPointerDown;
  36393. private _lastInteractionTime;
  36394. /**
  36395. * Initializes the behavior.
  36396. */
  36397. init(): void;
  36398. /**
  36399. * Attaches the behavior to its arc rotate camera.
  36400. * @param camera Defines the camera to attach the behavior to
  36401. */
  36402. attach(camera: ArcRotateCamera): void;
  36403. /**
  36404. * Detaches the behavior from its current arc rotate camera.
  36405. */
  36406. detach(): void;
  36407. private _animatables;
  36408. private _betaIsAnimating;
  36409. private _betaTransition;
  36410. private _radiusTransition;
  36411. private _vectorTransition;
  36412. /**
  36413. * Targets the given mesh and updates zoom level accordingly.
  36414. * @param mesh The mesh to target.
  36415. * @param radius Optional. If a cached radius position already exists, overrides default.
  36416. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36417. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36418. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36419. */
  36420. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36421. /**
  36422. * Targets the given mesh with its children and updates zoom level accordingly.
  36423. * @param mesh The mesh to target.
  36424. * @param radius Optional. If a cached radius position already exists, overrides default.
  36425. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36426. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36427. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36428. */
  36429. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36430. /**
  36431. * Targets the given meshes with their children and updates zoom level accordingly.
  36432. * @param meshes The mesh to target.
  36433. * @param radius Optional. If a cached radius position already exists, overrides default.
  36434. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36435. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36436. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36437. */
  36438. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36439. /**
  36440. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36441. * @param minimumWorld Determines the smaller position of the bounding box extend
  36442. * @param maximumWorld Determines the bigger position of the bounding box extend
  36443. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36444. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36445. */
  36446. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36447. /**
  36448. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36449. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36450. * frustum width.
  36451. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36452. * to fully enclose the mesh in the viewing frustum.
  36453. */
  36454. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36455. /**
  36456. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36457. * is automatically returned to its default position (expected to be above ground plane).
  36458. */
  36459. private _maintainCameraAboveGround;
  36460. /**
  36461. * Returns the frustum slope based on the canvas ratio and camera FOV
  36462. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36463. */
  36464. private _getFrustumSlope;
  36465. /**
  36466. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36467. */
  36468. private _clearAnimationLocks;
  36469. /**
  36470. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36471. */
  36472. private _applyUserInteraction;
  36473. /**
  36474. * Stops and removes all animations that have been applied to the camera
  36475. */
  36476. stopAllAnimations(): void;
  36477. /**
  36478. * Gets a value indicating if the user is moving the camera
  36479. */
  36480. readonly isUserIsMoving: boolean;
  36481. /**
  36482. * The camera can move all the way towards the mesh.
  36483. */
  36484. static IgnoreBoundsSizeMode: number;
  36485. /**
  36486. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36487. */
  36488. static FitFrustumSidesMode: number;
  36489. }
  36490. }
  36491. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36492. import { Nullable } from "babylonjs/types";
  36493. import { Camera } from "babylonjs/Cameras/camera";
  36494. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36495. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36496. /**
  36497. * Base class for Camera Pointer Inputs.
  36498. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36499. * for example usage.
  36500. */
  36501. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36502. /**
  36503. * Defines the camera the input is attached to.
  36504. */
  36505. abstract camera: Camera;
  36506. /**
  36507. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36508. */
  36509. protected _altKey: boolean;
  36510. protected _ctrlKey: boolean;
  36511. protected _metaKey: boolean;
  36512. protected _shiftKey: boolean;
  36513. /**
  36514. * Which mouse buttons were pressed at time of last mouse event.
  36515. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36516. */
  36517. protected _buttonsPressed: number;
  36518. /**
  36519. * Defines the buttons associated with the input to handle camera move.
  36520. */
  36521. buttons: number[];
  36522. /**
  36523. * Attach the input controls to a specific dom element to get the input from.
  36524. * @param element Defines the element the controls should be listened from
  36525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36526. */
  36527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36528. /**
  36529. * Detach the current controls from the specified dom element.
  36530. * @param element Defines the element to stop listening the inputs from
  36531. */
  36532. detachControl(element: Nullable<HTMLElement>): void;
  36533. /**
  36534. * Gets the class name of the current input.
  36535. * @returns the class name
  36536. */
  36537. getClassName(): string;
  36538. /**
  36539. * Get the friendly name associated with the input class.
  36540. * @returns the input friendly name
  36541. */
  36542. getSimpleName(): string;
  36543. /**
  36544. * Called on pointer POINTERDOUBLETAP event.
  36545. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36546. */
  36547. protected onDoubleTap(type: string): void;
  36548. /**
  36549. * Called on pointer POINTERMOVE event if only a single touch is active.
  36550. * Override this method to provide functionality.
  36551. */
  36552. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36553. /**
  36554. * Called on pointer POINTERMOVE event if multiple touches are active.
  36555. * Override this method to provide functionality.
  36556. */
  36557. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36558. /**
  36559. * Called on JS contextmenu event.
  36560. * Override this method to provide functionality.
  36561. */
  36562. protected onContextMenu(evt: PointerEvent): void;
  36563. /**
  36564. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36565. * press.
  36566. * Override this method to provide functionality.
  36567. */
  36568. protected onButtonDown(evt: PointerEvent): void;
  36569. /**
  36570. * Called each time a new POINTERUP event occurs. Ie, for each button
  36571. * release.
  36572. * Override this method to provide functionality.
  36573. */
  36574. protected onButtonUp(evt: PointerEvent): void;
  36575. /**
  36576. * Called when window becomes inactive.
  36577. * Override this method to provide functionality.
  36578. */
  36579. protected onLostFocus(): void;
  36580. private _pointerInput;
  36581. private _observer;
  36582. private _onLostFocus;
  36583. private pointA;
  36584. private pointB;
  36585. }
  36586. }
  36587. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36588. import { Nullable } from "babylonjs/types";
  36589. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36590. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36591. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36592. /**
  36593. * Manage the pointers inputs to control an arc rotate camera.
  36594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36595. */
  36596. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36597. /**
  36598. * Defines the camera the input is attached to.
  36599. */
  36600. camera: ArcRotateCamera;
  36601. /**
  36602. * Gets the class name of the current input.
  36603. * @returns the class name
  36604. */
  36605. getClassName(): string;
  36606. /**
  36607. * Defines the buttons associated with the input to handle camera move.
  36608. */
  36609. buttons: number[];
  36610. /**
  36611. * Defines the pointer angular sensibility along the X axis or how fast is
  36612. * the camera rotating.
  36613. */
  36614. angularSensibilityX: number;
  36615. /**
  36616. * Defines the pointer angular sensibility along the Y axis or how fast is
  36617. * the camera rotating.
  36618. */
  36619. angularSensibilityY: number;
  36620. /**
  36621. * Defines the pointer pinch precision or how fast is the camera zooming.
  36622. */
  36623. pinchPrecision: number;
  36624. /**
  36625. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36626. * from 0.
  36627. * It defines the percentage of current camera.radius to use as delta when
  36628. * pinch zoom is used.
  36629. */
  36630. pinchDeltaPercentage: number;
  36631. /**
  36632. * Defines the pointer panning sensibility or how fast is the camera moving.
  36633. */
  36634. panningSensibility: number;
  36635. /**
  36636. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36637. */
  36638. multiTouchPanning: boolean;
  36639. /**
  36640. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36641. * zoom (pinch) through multitouch.
  36642. */
  36643. multiTouchPanAndZoom: boolean;
  36644. /**
  36645. * Revers pinch action direction.
  36646. */
  36647. pinchInwards: boolean;
  36648. private _isPanClick;
  36649. private _twoFingerActivityCount;
  36650. private _isPinching;
  36651. /**
  36652. * Called on pointer POINTERMOVE event if only a single touch is active.
  36653. */
  36654. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36655. /**
  36656. * Called on pointer POINTERDOUBLETAP event.
  36657. */
  36658. protected onDoubleTap(type: string): void;
  36659. /**
  36660. * Called on pointer POINTERMOVE event if multiple touches are active.
  36661. */
  36662. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36663. /**
  36664. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36665. * press.
  36666. */
  36667. protected onButtonDown(evt: PointerEvent): void;
  36668. /**
  36669. * Called each time a new POINTERUP event occurs. Ie, for each button
  36670. * release.
  36671. */
  36672. protected onButtonUp(evt: PointerEvent): void;
  36673. /**
  36674. * Called when window becomes inactive.
  36675. */
  36676. protected onLostFocus(): void;
  36677. }
  36678. }
  36679. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36680. import { Nullable } from "babylonjs/types";
  36681. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36682. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36683. /**
  36684. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36686. */
  36687. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36688. /**
  36689. * Defines the camera the input is attached to.
  36690. */
  36691. camera: ArcRotateCamera;
  36692. /**
  36693. * Defines the list of key codes associated with the up action (increase alpha)
  36694. */
  36695. keysUp: number[];
  36696. /**
  36697. * Defines the list of key codes associated with the down action (decrease alpha)
  36698. */
  36699. keysDown: number[];
  36700. /**
  36701. * Defines the list of key codes associated with the left action (increase beta)
  36702. */
  36703. keysLeft: number[];
  36704. /**
  36705. * Defines the list of key codes associated with the right action (decrease beta)
  36706. */
  36707. keysRight: number[];
  36708. /**
  36709. * Defines the list of key codes associated with the reset action.
  36710. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36711. */
  36712. keysReset: number[];
  36713. /**
  36714. * Defines the panning sensibility of the inputs.
  36715. * (How fast is the camera paning)
  36716. */
  36717. panningSensibility: number;
  36718. /**
  36719. * Defines the zooming sensibility of the inputs.
  36720. * (How fast is the camera zooming)
  36721. */
  36722. zoomingSensibility: number;
  36723. /**
  36724. * Defines wether maintaining the alt key down switch the movement mode from
  36725. * orientation to zoom.
  36726. */
  36727. useAltToZoom: boolean;
  36728. /**
  36729. * Rotation speed of the camera
  36730. */
  36731. angularSpeed: number;
  36732. private _keys;
  36733. private _ctrlPressed;
  36734. private _altPressed;
  36735. private _onCanvasBlurObserver;
  36736. private _onKeyboardObserver;
  36737. private _engine;
  36738. private _scene;
  36739. /**
  36740. * Attach the input controls to a specific dom element to get the input from.
  36741. * @param element Defines the element the controls should be listened from
  36742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36743. */
  36744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36745. /**
  36746. * Detach the current controls from the specified dom element.
  36747. * @param element Defines the element to stop listening the inputs from
  36748. */
  36749. detachControl(element: Nullable<HTMLElement>): void;
  36750. /**
  36751. * Update the current camera state depending on the inputs that have been used this frame.
  36752. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36753. */
  36754. checkInputs(): void;
  36755. /**
  36756. * Gets the class name of the current intput.
  36757. * @returns the class name
  36758. */
  36759. getClassName(): string;
  36760. /**
  36761. * Get the friendly name associated with the input class.
  36762. * @returns the input friendly name
  36763. */
  36764. getSimpleName(): string;
  36765. }
  36766. }
  36767. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36768. import { Nullable } from "babylonjs/types";
  36769. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36770. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36771. /**
  36772. * Manage the mouse wheel inputs to control an arc rotate camera.
  36773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36774. */
  36775. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36776. /**
  36777. * Defines the camera the input is attached to.
  36778. */
  36779. camera: ArcRotateCamera;
  36780. /**
  36781. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36782. */
  36783. wheelPrecision: number;
  36784. /**
  36785. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36786. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36787. */
  36788. wheelDeltaPercentage: number;
  36789. private _wheel;
  36790. private _observer;
  36791. private computeDeltaFromMouseWheelLegacyEvent;
  36792. /**
  36793. * Attach the input controls to a specific dom element to get the input from.
  36794. * @param element Defines the element the controls should be listened from
  36795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36796. */
  36797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36798. /**
  36799. * Detach the current controls from the specified dom element.
  36800. * @param element Defines the element to stop listening the inputs from
  36801. */
  36802. detachControl(element: Nullable<HTMLElement>): void;
  36803. /**
  36804. * Gets the class name of the current intput.
  36805. * @returns the class name
  36806. */
  36807. getClassName(): string;
  36808. /**
  36809. * Get the friendly name associated with the input class.
  36810. * @returns the input friendly name
  36811. */
  36812. getSimpleName(): string;
  36813. }
  36814. }
  36815. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36816. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36817. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36818. /**
  36819. * Default Inputs manager for the ArcRotateCamera.
  36820. * It groups all the default supported inputs for ease of use.
  36821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36822. */
  36823. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36824. /**
  36825. * Instantiates a new ArcRotateCameraInputsManager.
  36826. * @param camera Defines the camera the inputs belong to
  36827. */
  36828. constructor(camera: ArcRotateCamera);
  36829. /**
  36830. * Add mouse wheel input support to the input manager.
  36831. * @returns the current input manager
  36832. */
  36833. addMouseWheel(): ArcRotateCameraInputsManager;
  36834. /**
  36835. * Add pointers input support to the input manager.
  36836. * @returns the current input manager
  36837. */
  36838. addPointers(): ArcRotateCameraInputsManager;
  36839. /**
  36840. * Add keyboard input support to the input manager.
  36841. * @returns the current input manager
  36842. */
  36843. addKeyboard(): ArcRotateCameraInputsManager;
  36844. }
  36845. }
  36846. declare module "babylonjs/Cameras/arcRotateCamera" {
  36847. import { Observable } from "babylonjs/Misc/observable";
  36848. import { Nullable } from "babylonjs/types";
  36849. import { Scene } from "babylonjs/scene";
  36850. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36852. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36853. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36854. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36855. import { Camera } from "babylonjs/Cameras/camera";
  36856. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36857. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36858. import { Collider } from "babylonjs/Collisions/collider";
  36859. /**
  36860. * This represents an orbital type of camera.
  36861. *
  36862. * 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.
  36863. * 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.
  36864. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36865. */
  36866. export class ArcRotateCamera extends TargetCamera {
  36867. /**
  36868. * Defines the rotation angle of the camera along the longitudinal axis.
  36869. */
  36870. alpha: number;
  36871. /**
  36872. * Defines the rotation angle of the camera along the latitudinal axis.
  36873. */
  36874. beta: number;
  36875. /**
  36876. * Defines the radius of the camera from it s target point.
  36877. */
  36878. radius: number;
  36879. protected _target: Vector3;
  36880. protected _targetHost: Nullable<AbstractMesh>;
  36881. /**
  36882. * Defines the target point of the camera.
  36883. * The camera looks towards it form the radius distance.
  36884. */
  36885. target: Vector3;
  36886. /**
  36887. * Define the current local position of the camera in the scene
  36888. */
  36889. position: Vector3;
  36890. protected _upVector: Vector3;
  36891. protected _upToYMatrix: Matrix;
  36892. protected _YToUpMatrix: Matrix;
  36893. /**
  36894. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36895. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36896. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36897. */
  36898. upVector: Vector3;
  36899. /**
  36900. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36901. */
  36902. setMatUp(): void;
  36903. /**
  36904. * Current inertia value on the longitudinal axis.
  36905. * The bigger this number the longer it will take for the camera to stop.
  36906. */
  36907. inertialAlphaOffset: number;
  36908. /**
  36909. * Current inertia value on the latitudinal axis.
  36910. * The bigger this number the longer it will take for the camera to stop.
  36911. */
  36912. inertialBetaOffset: number;
  36913. /**
  36914. * Current inertia value on the radius axis.
  36915. * The bigger this number the longer it will take for the camera to stop.
  36916. */
  36917. inertialRadiusOffset: number;
  36918. /**
  36919. * Minimum allowed angle on the longitudinal axis.
  36920. * This can help limiting how the Camera is able to move in the scene.
  36921. */
  36922. lowerAlphaLimit: Nullable<number>;
  36923. /**
  36924. * Maximum allowed angle on the longitudinal axis.
  36925. * This can help limiting how the Camera is able to move in the scene.
  36926. */
  36927. upperAlphaLimit: Nullable<number>;
  36928. /**
  36929. * Minimum allowed angle on the latitudinal axis.
  36930. * This can help limiting how the Camera is able to move in the scene.
  36931. */
  36932. lowerBetaLimit: number;
  36933. /**
  36934. * Maximum allowed angle on the latitudinal axis.
  36935. * This can help limiting how the Camera is able to move in the scene.
  36936. */
  36937. upperBetaLimit: number;
  36938. /**
  36939. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36940. * This can help limiting how the Camera is able to move in the scene.
  36941. */
  36942. lowerRadiusLimit: Nullable<number>;
  36943. /**
  36944. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36945. * This can help limiting how the Camera is able to move in the scene.
  36946. */
  36947. upperRadiusLimit: Nullable<number>;
  36948. /**
  36949. * Defines the current inertia value used during panning of the camera along the X axis.
  36950. */
  36951. inertialPanningX: number;
  36952. /**
  36953. * Defines the current inertia value used during panning of the camera along the Y axis.
  36954. */
  36955. inertialPanningY: number;
  36956. /**
  36957. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36958. * Basically if your fingers moves away from more than this distance you will be considered
  36959. * in pinch mode.
  36960. */
  36961. pinchToPanMaxDistance: number;
  36962. /**
  36963. * Defines the maximum distance the camera can pan.
  36964. * This could help keeping the cammera always in your scene.
  36965. */
  36966. panningDistanceLimit: Nullable<number>;
  36967. /**
  36968. * Defines the target of the camera before paning.
  36969. */
  36970. panningOriginTarget: Vector3;
  36971. /**
  36972. * Defines the value of the inertia used during panning.
  36973. * 0 would mean stop inertia and one would mean no decelleration at all.
  36974. */
  36975. panningInertia: number;
  36976. /**
  36977. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36978. */
  36979. angularSensibilityX: number;
  36980. /**
  36981. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36982. */
  36983. angularSensibilityY: number;
  36984. /**
  36985. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36986. */
  36987. pinchPrecision: number;
  36988. /**
  36989. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36990. * It will be used instead of pinchDeltaPrecision if different from 0.
  36991. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36992. */
  36993. pinchDeltaPercentage: number;
  36994. /**
  36995. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36996. */
  36997. panningSensibility: number;
  36998. /**
  36999. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37000. */
  37001. keysUp: number[];
  37002. /**
  37003. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37004. */
  37005. keysDown: number[];
  37006. /**
  37007. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37008. */
  37009. keysLeft: number[];
  37010. /**
  37011. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37012. */
  37013. keysRight: number[];
  37014. /**
  37015. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37016. */
  37017. wheelPrecision: number;
  37018. /**
  37019. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37020. * It will be used instead of pinchDeltaPrecision if different from 0.
  37021. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37022. */
  37023. wheelDeltaPercentage: number;
  37024. /**
  37025. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37026. */
  37027. zoomOnFactor: number;
  37028. /**
  37029. * Defines a screen offset for the camera position.
  37030. */
  37031. targetScreenOffset: Vector2;
  37032. /**
  37033. * Allows the camera to be completely reversed.
  37034. * If false the camera can not arrive upside down.
  37035. */
  37036. allowUpsideDown: boolean;
  37037. /**
  37038. * Define if double tap/click is used to restore the previously saved state of the camera.
  37039. */
  37040. useInputToRestoreState: boolean;
  37041. /** @hidden */
  37042. _viewMatrix: Matrix;
  37043. /** @hidden */
  37044. _useCtrlForPanning: boolean;
  37045. /** @hidden */
  37046. _panningMouseButton: number;
  37047. /**
  37048. * Defines the input associated to the camera.
  37049. */
  37050. inputs: ArcRotateCameraInputsManager;
  37051. /** @hidden */
  37052. _reset: () => void;
  37053. /**
  37054. * Defines the allowed panning axis.
  37055. */
  37056. panningAxis: Vector3;
  37057. protected _localDirection: Vector3;
  37058. protected _transformedDirection: Vector3;
  37059. private _bouncingBehavior;
  37060. /**
  37061. * Gets the bouncing behavior of the camera if it has been enabled.
  37062. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37063. */
  37064. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37065. /**
  37066. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37067. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37068. */
  37069. useBouncingBehavior: boolean;
  37070. private _framingBehavior;
  37071. /**
  37072. * Gets the framing behavior of the camera if it has been enabled.
  37073. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37074. */
  37075. readonly framingBehavior: Nullable<FramingBehavior>;
  37076. /**
  37077. * Defines if the framing behavior of the camera is enabled on the camera.
  37078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37079. */
  37080. useFramingBehavior: boolean;
  37081. private _autoRotationBehavior;
  37082. /**
  37083. * Gets the auto rotation behavior of the camera if it has been enabled.
  37084. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37085. */
  37086. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37087. /**
  37088. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37089. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37090. */
  37091. useAutoRotationBehavior: boolean;
  37092. /**
  37093. * Observable triggered when the mesh target has been changed on the camera.
  37094. */
  37095. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37096. /**
  37097. * Event raised when the camera is colliding with a mesh.
  37098. */
  37099. onCollide: (collidedMesh: AbstractMesh) => void;
  37100. /**
  37101. * Defines whether the camera should check collision with the objects oh the scene.
  37102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37103. */
  37104. checkCollisions: boolean;
  37105. /**
  37106. * Defines the collision radius of the camera.
  37107. * This simulates a sphere around the camera.
  37108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37109. */
  37110. collisionRadius: Vector3;
  37111. protected _collider: Collider;
  37112. protected _previousPosition: Vector3;
  37113. protected _collisionVelocity: Vector3;
  37114. protected _newPosition: Vector3;
  37115. protected _previousAlpha: number;
  37116. protected _previousBeta: number;
  37117. protected _previousRadius: number;
  37118. protected _collisionTriggered: boolean;
  37119. protected _targetBoundingCenter: Nullable<Vector3>;
  37120. private _computationVector;
  37121. /**
  37122. * Instantiates a new ArcRotateCamera in a given scene
  37123. * @param name Defines the name of the camera
  37124. * @param alpha Defines the camera rotation along the logitudinal axis
  37125. * @param beta Defines the camera rotation along the latitudinal axis
  37126. * @param radius Defines the camera distance from its target
  37127. * @param target Defines the camera target
  37128. * @param scene Defines the scene the camera belongs to
  37129. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37130. */
  37131. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37132. /** @hidden */
  37133. _initCache(): void;
  37134. /** @hidden */
  37135. _updateCache(ignoreParentClass?: boolean): void;
  37136. protected _getTargetPosition(): Vector3;
  37137. private _storedAlpha;
  37138. private _storedBeta;
  37139. private _storedRadius;
  37140. private _storedTarget;
  37141. /**
  37142. * Stores the current state of the camera (alpha, beta, radius and target)
  37143. * @returns the camera itself
  37144. */
  37145. storeState(): Camera;
  37146. /**
  37147. * @hidden
  37148. * Restored camera state. You must call storeState() first
  37149. */
  37150. _restoreStateValues(): boolean;
  37151. /** @hidden */
  37152. _isSynchronizedViewMatrix(): boolean;
  37153. /**
  37154. * Attached controls to the current camera.
  37155. * @param element Defines the element the controls should be listened from
  37156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37157. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37158. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37159. */
  37160. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37161. /**
  37162. * Detach the current controls from the camera.
  37163. * The camera will stop reacting to inputs.
  37164. * @param element Defines the element to stop listening the inputs from
  37165. */
  37166. detachControl(element: HTMLElement): void;
  37167. /** @hidden */
  37168. _checkInputs(): void;
  37169. protected _checkLimits(): void;
  37170. /**
  37171. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37172. */
  37173. rebuildAnglesAndRadius(): void;
  37174. /**
  37175. * Use a position to define the current camera related information like aplha, beta and radius
  37176. * @param position Defines the position to set the camera at
  37177. */
  37178. setPosition(position: Vector3): void;
  37179. /**
  37180. * Defines the target the camera should look at.
  37181. * This will automatically adapt alpha beta and radius to fit within the new target.
  37182. * @param target Defines the new target as a Vector or a mesh
  37183. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37184. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37185. */
  37186. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37187. /** @hidden */
  37188. _getViewMatrix(): Matrix;
  37189. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37190. /**
  37191. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37192. * @param meshes Defines the mesh to zoom on
  37193. * @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)
  37194. */
  37195. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37196. /**
  37197. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37198. * The target will be changed but the radius
  37199. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37200. * @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)
  37201. */
  37202. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37203. min: Vector3;
  37204. max: Vector3;
  37205. distance: number;
  37206. }, doNotUpdateMaxZ?: boolean): void;
  37207. /**
  37208. * @override
  37209. * Override Camera.createRigCamera
  37210. */
  37211. createRigCamera(name: string, cameraIndex: number): Camera;
  37212. /**
  37213. * @hidden
  37214. * @override
  37215. * Override Camera._updateRigCameras
  37216. */
  37217. _updateRigCameras(): void;
  37218. /**
  37219. * Destroy the camera and release the current resources hold by it.
  37220. */
  37221. dispose(): void;
  37222. /**
  37223. * Gets the current object class name.
  37224. * @return the class name
  37225. */
  37226. getClassName(): string;
  37227. }
  37228. }
  37229. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37230. import { Behavior } from "babylonjs/Behaviors/behavior";
  37231. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37232. /**
  37233. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37234. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37235. */
  37236. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37237. /**
  37238. * Gets the name of the behavior.
  37239. */
  37240. readonly name: string;
  37241. private _zoomStopsAnimation;
  37242. private _idleRotationSpeed;
  37243. private _idleRotationWaitTime;
  37244. private _idleRotationSpinupTime;
  37245. /**
  37246. * Sets the flag that indicates if user zooming should stop animation.
  37247. */
  37248. /**
  37249. * Gets the flag that indicates if user zooming should stop animation.
  37250. */
  37251. zoomStopsAnimation: boolean;
  37252. /**
  37253. * Sets the default speed at which the camera rotates around the model.
  37254. */
  37255. /**
  37256. * Gets the default speed at which the camera rotates around the model.
  37257. */
  37258. idleRotationSpeed: number;
  37259. /**
  37260. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37261. */
  37262. /**
  37263. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37264. */
  37265. idleRotationWaitTime: number;
  37266. /**
  37267. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37268. */
  37269. /**
  37270. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37271. */
  37272. idleRotationSpinupTime: number;
  37273. /**
  37274. * Gets a value indicating if the camera is currently rotating because of this behavior
  37275. */
  37276. readonly rotationInProgress: boolean;
  37277. private _onPrePointerObservableObserver;
  37278. private _onAfterCheckInputsObserver;
  37279. private _attachedCamera;
  37280. private _isPointerDown;
  37281. private _lastFrameTime;
  37282. private _lastInteractionTime;
  37283. private _cameraRotationSpeed;
  37284. /**
  37285. * Initializes the behavior.
  37286. */
  37287. init(): void;
  37288. /**
  37289. * Attaches the behavior to its arc rotate camera.
  37290. * @param camera Defines the camera to attach the behavior to
  37291. */
  37292. attach(camera: ArcRotateCamera): void;
  37293. /**
  37294. * Detaches the behavior from its current arc rotate camera.
  37295. */
  37296. detach(): void;
  37297. /**
  37298. * Returns true if user is scrolling.
  37299. * @return true if user is scrolling.
  37300. */
  37301. private _userIsZooming;
  37302. private _lastFrameRadius;
  37303. private _shouldAnimationStopForInteraction;
  37304. /**
  37305. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37306. */
  37307. private _applyUserInteraction;
  37308. private _userIsMoving;
  37309. }
  37310. }
  37311. declare module "babylonjs/Behaviors/Cameras/index" {
  37312. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37313. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37314. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37315. }
  37316. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37317. import { Mesh } from "babylonjs/Meshes/mesh";
  37318. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37319. import { Behavior } from "babylonjs/Behaviors/behavior";
  37320. /**
  37321. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37322. */
  37323. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37324. private ui;
  37325. /**
  37326. * The name of the behavior
  37327. */
  37328. name: string;
  37329. /**
  37330. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37331. */
  37332. distanceAwayFromFace: number;
  37333. /**
  37334. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37335. */
  37336. distanceAwayFromBottomOfFace: number;
  37337. private _faceVectors;
  37338. private _target;
  37339. private _scene;
  37340. private _onRenderObserver;
  37341. private _tmpMatrix;
  37342. private _tmpVector;
  37343. /**
  37344. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37345. * @param ui The transform node that should be attched to the mesh
  37346. */
  37347. constructor(ui: TransformNode);
  37348. /**
  37349. * Initializes the behavior
  37350. */
  37351. init(): void;
  37352. private _closestFace;
  37353. private _zeroVector;
  37354. private _lookAtTmpMatrix;
  37355. private _lookAtToRef;
  37356. /**
  37357. * Attaches the AttachToBoxBehavior to the passed in mesh
  37358. * @param target The mesh that the specified node will be attached to
  37359. */
  37360. attach(target: Mesh): void;
  37361. /**
  37362. * Detaches the behavior from the mesh
  37363. */
  37364. detach(): void;
  37365. }
  37366. }
  37367. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37368. import { Behavior } from "babylonjs/Behaviors/behavior";
  37369. import { Mesh } from "babylonjs/Meshes/mesh";
  37370. /**
  37371. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37372. */
  37373. export class FadeInOutBehavior implements Behavior<Mesh> {
  37374. /**
  37375. * Time in milliseconds to delay before fading in (Default: 0)
  37376. */
  37377. delay: number;
  37378. /**
  37379. * Time in milliseconds for the mesh to fade in (Default: 300)
  37380. */
  37381. fadeInTime: number;
  37382. private _millisecondsPerFrame;
  37383. private _hovered;
  37384. private _hoverValue;
  37385. private _ownerNode;
  37386. /**
  37387. * Instatiates the FadeInOutBehavior
  37388. */
  37389. constructor();
  37390. /**
  37391. * The name of the behavior
  37392. */
  37393. readonly name: string;
  37394. /**
  37395. * Initializes the behavior
  37396. */
  37397. init(): void;
  37398. /**
  37399. * Attaches the fade behavior on the passed in mesh
  37400. * @param ownerNode The mesh that will be faded in/out once attached
  37401. */
  37402. attach(ownerNode: Mesh): void;
  37403. /**
  37404. * Detaches the behavior from the mesh
  37405. */
  37406. detach(): void;
  37407. /**
  37408. * Triggers the mesh to begin fading in or out
  37409. * @param value if the object should fade in or out (true to fade in)
  37410. */
  37411. fadeIn(value: boolean): void;
  37412. private _update;
  37413. private _setAllVisibility;
  37414. }
  37415. }
  37416. declare module "babylonjs/Misc/pivotTools" {
  37417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37418. /**
  37419. * Class containing a set of static utilities functions for managing Pivots
  37420. * @hidden
  37421. */
  37422. export class PivotTools {
  37423. private static _PivotCached;
  37424. private static _OldPivotPoint;
  37425. private static _PivotTranslation;
  37426. private static _PivotTmpVector;
  37427. /** @hidden */
  37428. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37429. /** @hidden */
  37430. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37431. }
  37432. }
  37433. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37434. import { Scene } from "babylonjs/scene";
  37435. import { Vector4 } from "babylonjs/Maths/math.vector";
  37436. import { Mesh } from "babylonjs/Meshes/mesh";
  37437. import { Nullable } from "babylonjs/types";
  37438. import { Plane } from "babylonjs/Maths/math.plane";
  37439. /**
  37440. * Class containing static functions to help procedurally build meshes
  37441. */
  37442. export class PlaneBuilder {
  37443. /**
  37444. * Creates a plane mesh
  37445. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37446. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37447. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37451. * @param name defines the name of the mesh
  37452. * @param options defines the options used to create the mesh
  37453. * @param scene defines the hosting scene
  37454. * @returns the plane mesh
  37455. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37456. */
  37457. static CreatePlane(name: string, options: {
  37458. size?: number;
  37459. width?: number;
  37460. height?: number;
  37461. sideOrientation?: number;
  37462. frontUVs?: Vector4;
  37463. backUVs?: Vector4;
  37464. updatable?: boolean;
  37465. sourcePlane?: Plane;
  37466. }, scene?: Nullable<Scene>): Mesh;
  37467. }
  37468. }
  37469. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37470. import { Behavior } from "babylonjs/Behaviors/behavior";
  37471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37472. import { Observable } from "babylonjs/Misc/observable";
  37473. import { Vector3 } from "babylonjs/Maths/math.vector";
  37474. import { Ray } from "babylonjs/Culling/ray";
  37475. import "babylonjs/Meshes/Builders/planeBuilder";
  37476. /**
  37477. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37478. */
  37479. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37480. private static _AnyMouseID;
  37481. /**
  37482. * Abstract mesh the behavior is set on
  37483. */
  37484. attachedNode: AbstractMesh;
  37485. private _dragPlane;
  37486. private _scene;
  37487. private _pointerObserver;
  37488. private _beforeRenderObserver;
  37489. private static _planeScene;
  37490. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37491. /**
  37492. * 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)
  37493. */
  37494. maxDragAngle: number;
  37495. /**
  37496. * @hidden
  37497. */
  37498. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37499. /**
  37500. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37501. */
  37502. currentDraggingPointerID: number;
  37503. /**
  37504. * The last position where the pointer hit the drag plane in world space
  37505. */
  37506. lastDragPosition: Vector3;
  37507. /**
  37508. * If the behavior is currently in a dragging state
  37509. */
  37510. dragging: boolean;
  37511. /**
  37512. * 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)
  37513. */
  37514. dragDeltaRatio: number;
  37515. /**
  37516. * If the drag plane orientation should be updated during the dragging (Default: true)
  37517. */
  37518. updateDragPlane: boolean;
  37519. private _debugMode;
  37520. private _moving;
  37521. /**
  37522. * Fires each time the attached mesh is dragged with the pointer
  37523. * * delta between last drag position and current drag position in world space
  37524. * * dragDistance along the drag axis
  37525. * * dragPlaneNormal normal of the current drag plane used during the drag
  37526. * * dragPlanePoint in world space where the drag intersects the drag plane
  37527. */
  37528. onDragObservable: Observable<{
  37529. delta: Vector3;
  37530. dragPlanePoint: Vector3;
  37531. dragPlaneNormal: Vector3;
  37532. dragDistance: number;
  37533. pointerId: number;
  37534. }>;
  37535. /**
  37536. * Fires each time a drag begins (eg. mouse down on mesh)
  37537. */
  37538. onDragStartObservable: Observable<{
  37539. dragPlanePoint: Vector3;
  37540. pointerId: number;
  37541. }>;
  37542. /**
  37543. * Fires each time a drag ends (eg. mouse release after drag)
  37544. */
  37545. onDragEndObservable: Observable<{
  37546. dragPlanePoint: Vector3;
  37547. pointerId: number;
  37548. }>;
  37549. /**
  37550. * If the attached mesh should be moved when dragged
  37551. */
  37552. moveAttached: boolean;
  37553. /**
  37554. * If the drag behavior will react to drag events (Default: true)
  37555. */
  37556. enabled: boolean;
  37557. /**
  37558. * If pointer events should start and release the drag (Default: true)
  37559. */
  37560. startAndReleaseDragOnPointerEvents: boolean;
  37561. /**
  37562. * If camera controls should be detached during the drag
  37563. */
  37564. detachCameraControls: boolean;
  37565. /**
  37566. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37567. */
  37568. useObjectOrienationForDragging: boolean;
  37569. private _options;
  37570. /**
  37571. * Creates a pointer drag behavior that can be attached to a mesh
  37572. * @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)
  37573. */
  37574. constructor(options?: {
  37575. dragAxis?: Vector3;
  37576. dragPlaneNormal?: Vector3;
  37577. });
  37578. /**
  37579. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37580. */
  37581. validateDrag: (targetPosition: Vector3) => boolean;
  37582. /**
  37583. * The name of the behavior
  37584. */
  37585. readonly name: string;
  37586. /**
  37587. * Initializes the behavior
  37588. */
  37589. init(): void;
  37590. private _tmpVector;
  37591. private _alternatePickedPoint;
  37592. private _worldDragAxis;
  37593. private _targetPosition;
  37594. private _attachedElement;
  37595. /**
  37596. * Attaches the drag behavior the passed in mesh
  37597. * @param ownerNode The mesh that will be dragged around once attached
  37598. */
  37599. attach(ownerNode: AbstractMesh): void;
  37600. /**
  37601. * Force relase the drag action by code.
  37602. */
  37603. releaseDrag(): void;
  37604. private _startDragRay;
  37605. private _lastPointerRay;
  37606. /**
  37607. * Simulates the start of a pointer drag event on the behavior
  37608. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37609. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37610. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37611. */
  37612. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37613. private _startDrag;
  37614. private _dragDelta;
  37615. private _moveDrag;
  37616. private _pickWithRayOnDragPlane;
  37617. private _pointA;
  37618. private _pointB;
  37619. private _pointC;
  37620. private _lineA;
  37621. private _lineB;
  37622. private _localAxis;
  37623. private _lookAt;
  37624. private _updateDragPlanePosition;
  37625. /**
  37626. * Detaches the behavior from the mesh
  37627. */
  37628. detach(): void;
  37629. }
  37630. }
  37631. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37632. import { Mesh } from "babylonjs/Meshes/mesh";
  37633. import { Behavior } from "babylonjs/Behaviors/behavior";
  37634. /**
  37635. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37636. */
  37637. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37638. private _dragBehaviorA;
  37639. private _dragBehaviorB;
  37640. private _startDistance;
  37641. private _initialScale;
  37642. private _targetScale;
  37643. private _ownerNode;
  37644. private _sceneRenderObserver;
  37645. /**
  37646. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37647. */
  37648. constructor();
  37649. /**
  37650. * The name of the behavior
  37651. */
  37652. readonly name: string;
  37653. /**
  37654. * Initializes the behavior
  37655. */
  37656. init(): void;
  37657. private _getCurrentDistance;
  37658. /**
  37659. * Attaches the scale behavior the passed in mesh
  37660. * @param ownerNode The mesh that will be scaled around once attached
  37661. */
  37662. attach(ownerNode: Mesh): void;
  37663. /**
  37664. * Detaches the behavior from the mesh
  37665. */
  37666. detach(): void;
  37667. }
  37668. }
  37669. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37670. import { Behavior } from "babylonjs/Behaviors/behavior";
  37671. import { Mesh } from "babylonjs/Meshes/mesh";
  37672. import { Observable } from "babylonjs/Misc/observable";
  37673. /**
  37674. * 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
  37675. */
  37676. export class SixDofDragBehavior implements Behavior<Mesh> {
  37677. private static _virtualScene;
  37678. private _ownerNode;
  37679. private _sceneRenderObserver;
  37680. private _scene;
  37681. private _targetPosition;
  37682. private _virtualOriginMesh;
  37683. private _virtualDragMesh;
  37684. private _pointerObserver;
  37685. private _moving;
  37686. private _startingOrientation;
  37687. /**
  37688. * 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)
  37689. */
  37690. private zDragFactor;
  37691. /**
  37692. * If the object should rotate to face the drag origin
  37693. */
  37694. rotateDraggedObject: boolean;
  37695. /**
  37696. * If the behavior is currently in a dragging state
  37697. */
  37698. dragging: boolean;
  37699. /**
  37700. * 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)
  37701. */
  37702. dragDeltaRatio: number;
  37703. /**
  37704. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37705. */
  37706. currentDraggingPointerID: number;
  37707. /**
  37708. * If camera controls should be detached during the drag
  37709. */
  37710. detachCameraControls: boolean;
  37711. /**
  37712. * Fires each time a drag starts
  37713. */
  37714. onDragStartObservable: Observable<{}>;
  37715. /**
  37716. * Fires each time a drag ends (eg. mouse release after drag)
  37717. */
  37718. onDragEndObservable: Observable<{}>;
  37719. /**
  37720. * 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
  37721. */
  37722. constructor();
  37723. /**
  37724. * The name of the behavior
  37725. */
  37726. readonly name: string;
  37727. /**
  37728. * Initializes the behavior
  37729. */
  37730. init(): void;
  37731. /**
  37732. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37733. */
  37734. private readonly _pointerCamera;
  37735. /**
  37736. * Attaches the scale behavior the passed in mesh
  37737. * @param ownerNode The mesh that will be scaled around once attached
  37738. */
  37739. attach(ownerNode: Mesh): void;
  37740. /**
  37741. * Detaches the behavior from the mesh
  37742. */
  37743. detach(): void;
  37744. }
  37745. }
  37746. declare module "babylonjs/Behaviors/Meshes/index" {
  37747. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37748. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37749. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37750. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37751. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37752. }
  37753. declare module "babylonjs/Behaviors/index" {
  37754. export * from "babylonjs/Behaviors/behavior";
  37755. export * from "babylonjs/Behaviors/Cameras/index";
  37756. export * from "babylonjs/Behaviors/Meshes/index";
  37757. }
  37758. declare module "babylonjs/Bones/boneIKController" {
  37759. import { Bone } from "babylonjs/Bones/bone";
  37760. import { Vector3 } from "babylonjs/Maths/math.vector";
  37761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37762. import { Nullable } from "babylonjs/types";
  37763. /**
  37764. * Class used to apply inverse kinematics to bones
  37765. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37766. */
  37767. export class BoneIKController {
  37768. private static _tmpVecs;
  37769. private static _tmpQuat;
  37770. private static _tmpMats;
  37771. /**
  37772. * Gets or sets the target mesh
  37773. */
  37774. targetMesh: AbstractMesh;
  37775. /** Gets or sets the mesh used as pole */
  37776. poleTargetMesh: AbstractMesh;
  37777. /**
  37778. * Gets or sets the bone used as pole
  37779. */
  37780. poleTargetBone: Nullable<Bone>;
  37781. /**
  37782. * Gets or sets the target position
  37783. */
  37784. targetPosition: Vector3;
  37785. /**
  37786. * Gets or sets the pole target position
  37787. */
  37788. poleTargetPosition: Vector3;
  37789. /**
  37790. * Gets or sets the pole target local offset
  37791. */
  37792. poleTargetLocalOffset: Vector3;
  37793. /**
  37794. * Gets or sets the pole angle
  37795. */
  37796. poleAngle: number;
  37797. /**
  37798. * Gets or sets the mesh associated with the controller
  37799. */
  37800. mesh: AbstractMesh;
  37801. /**
  37802. * 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)
  37803. */
  37804. slerpAmount: number;
  37805. private _bone1Quat;
  37806. private _bone1Mat;
  37807. private _bone2Ang;
  37808. private _bone1;
  37809. private _bone2;
  37810. private _bone1Length;
  37811. private _bone2Length;
  37812. private _maxAngle;
  37813. private _maxReach;
  37814. private _rightHandedSystem;
  37815. private _bendAxis;
  37816. private _slerping;
  37817. private _adjustRoll;
  37818. /**
  37819. * Gets or sets maximum allowed angle
  37820. */
  37821. maxAngle: number;
  37822. /**
  37823. * Creates a new BoneIKController
  37824. * @param mesh defines the mesh to control
  37825. * @param bone defines the bone to control
  37826. * @param options defines options to set up the controller
  37827. */
  37828. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37829. targetMesh?: AbstractMesh;
  37830. poleTargetMesh?: AbstractMesh;
  37831. poleTargetBone?: Bone;
  37832. poleTargetLocalOffset?: Vector3;
  37833. poleAngle?: number;
  37834. bendAxis?: Vector3;
  37835. maxAngle?: number;
  37836. slerpAmount?: number;
  37837. });
  37838. private _setMaxAngle;
  37839. /**
  37840. * Force the controller to update the bones
  37841. */
  37842. update(): void;
  37843. }
  37844. }
  37845. declare module "babylonjs/Bones/boneLookController" {
  37846. import { Vector3 } from "babylonjs/Maths/math.vector";
  37847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37848. import { Bone } from "babylonjs/Bones/bone";
  37849. import { Space } from "babylonjs/Maths/math.axis";
  37850. /**
  37851. * Class used to make a bone look toward a point in space
  37852. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37853. */
  37854. export class BoneLookController {
  37855. private static _tmpVecs;
  37856. private static _tmpQuat;
  37857. private static _tmpMats;
  37858. /**
  37859. * The target Vector3 that the bone will look at
  37860. */
  37861. target: Vector3;
  37862. /**
  37863. * The mesh that the bone is attached to
  37864. */
  37865. mesh: AbstractMesh;
  37866. /**
  37867. * The bone that will be looking to the target
  37868. */
  37869. bone: Bone;
  37870. /**
  37871. * The up axis of the coordinate system that is used when the bone is rotated
  37872. */
  37873. upAxis: Vector3;
  37874. /**
  37875. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37876. */
  37877. upAxisSpace: Space;
  37878. /**
  37879. * Used to make an adjustment to the yaw of the bone
  37880. */
  37881. adjustYaw: number;
  37882. /**
  37883. * Used to make an adjustment to the pitch of the bone
  37884. */
  37885. adjustPitch: number;
  37886. /**
  37887. * Used to make an adjustment to the roll of the bone
  37888. */
  37889. adjustRoll: number;
  37890. /**
  37891. * 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)
  37892. */
  37893. slerpAmount: number;
  37894. private _minYaw;
  37895. private _maxYaw;
  37896. private _minPitch;
  37897. private _maxPitch;
  37898. private _minYawSin;
  37899. private _minYawCos;
  37900. private _maxYawSin;
  37901. private _maxYawCos;
  37902. private _midYawConstraint;
  37903. private _minPitchTan;
  37904. private _maxPitchTan;
  37905. private _boneQuat;
  37906. private _slerping;
  37907. private _transformYawPitch;
  37908. private _transformYawPitchInv;
  37909. private _firstFrameSkipped;
  37910. private _yawRange;
  37911. private _fowardAxis;
  37912. /**
  37913. * Gets or sets the minimum yaw angle that the bone can look to
  37914. */
  37915. minYaw: number;
  37916. /**
  37917. * Gets or sets the maximum yaw angle that the bone can look to
  37918. */
  37919. maxYaw: number;
  37920. /**
  37921. * Gets or sets the minimum pitch angle that the bone can look to
  37922. */
  37923. minPitch: number;
  37924. /**
  37925. * Gets or sets the maximum pitch angle that the bone can look to
  37926. */
  37927. maxPitch: number;
  37928. /**
  37929. * Create a BoneLookController
  37930. * @param mesh the mesh that the bone belongs to
  37931. * @param bone the bone that will be looking to the target
  37932. * @param target the target Vector3 to look at
  37933. * @param options optional settings:
  37934. * * maxYaw: the maximum angle the bone will yaw to
  37935. * * minYaw: the minimum angle the bone will yaw to
  37936. * * maxPitch: the maximum angle the bone will pitch to
  37937. * * minPitch: the minimum angle the bone will yaw to
  37938. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37939. * * upAxis: the up axis of the coordinate system
  37940. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37941. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37942. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37943. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37944. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37945. * * adjustRoll: used to make an adjustment to the roll of the bone
  37946. **/
  37947. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37948. maxYaw?: number;
  37949. minYaw?: number;
  37950. maxPitch?: number;
  37951. minPitch?: number;
  37952. slerpAmount?: number;
  37953. upAxis?: Vector3;
  37954. upAxisSpace?: Space;
  37955. yawAxis?: Vector3;
  37956. pitchAxis?: Vector3;
  37957. adjustYaw?: number;
  37958. adjustPitch?: number;
  37959. adjustRoll?: number;
  37960. });
  37961. /**
  37962. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37963. */
  37964. update(): void;
  37965. private _getAngleDiff;
  37966. private _getAngleBetween;
  37967. private _isAngleBetween;
  37968. }
  37969. }
  37970. declare module "babylonjs/Bones/index" {
  37971. export * from "babylonjs/Bones/bone";
  37972. export * from "babylonjs/Bones/boneIKController";
  37973. export * from "babylonjs/Bones/boneLookController";
  37974. export * from "babylonjs/Bones/skeleton";
  37975. }
  37976. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37977. import { Nullable } from "babylonjs/types";
  37978. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37979. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37980. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37981. /**
  37982. * Manage the gamepad inputs to control an arc rotate camera.
  37983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37984. */
  37985. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37986. /**
  37987. * Defines the camera the input is attached to.
  37988. */
  37989. camera: ArcRotateCamera;
  37990. /**
  37991. * Defines the gamepad the input is gathering event from.
  37992. */
  37993. gamepad: Nullable<Gamepad>;
  37994. /**
  37995. * Defines the gamepad rotation sensiblity.
  37996. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37997. */
  37998. gamepadRotationSensibility: number;
  37999. /**
  38000. * Defines the gamepad move sensiblity.
  38001. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38002. */
  38003. gamepadMoveSensibility: number;
  38004. private _onGamepadConnectedObserver;
  38005. private _onGamepadDisconnectedObserver;
  38006. /**
  38007. * Attach the input controls to a specific dom element to get the input from.
  38008. * @param element Defines the element the controls should be listened from
  38009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38010. */
  38011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38012. /**
  38013. * Detach the current controls from the specified dom element.
  38014. * @param element Defines the element to stop listening the inputs from
  38015. */
  38016. detachControl(element: Nullable<HTMLElement>): void;
  38017. /**
  38018. * Update the current camera state depending on the inputs that have been used this frame.
  38019. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38020. */
  38021. checkInputs(): void;
  38022. /**
  38023. * Gets the class name of the current intput.
  38024. * @returns the class name
  38025. */
  38026. getClassName(): string;
  38027. /**
  38028. * Get the friendly name associated with the input class.
  38029. * @returns the input friendly name
  38030. */
  38031. getSimpleName(): string;
  38032. }
  38033. }
  38034. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38035. import { Nullable } from "babylonjs/types";
  38036. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38037. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38038. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38039. interface ArcRotateCameraInputsManager {
  38040. /**
  38041. * Add orientation input support to the input manager.
  38042. * @returns the current input manager
  38043. */
  38044. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38045. }
  38046. }
  38047. /**
  38048. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38050. */
  38051. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38052. /**
  38053. * Defines the camera the input is attached to.
  38054. */
  38055. camera: ArcRotateCamera;
  38056. /**
  38057. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38058. */
  38059. alphaCorrection: number;
  38060. /**
  38061. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38062. */
  38063. gammaCorrection: number;
  38064. private _alpha;
  38065. private _gamma;
  38066. private _dirty;
  38067. private _deviceOrientationHandler;
  38068. /**
  38069. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38070. */
  38071. constructor();
  38072. /**
  38073. * Attach the input controls to a specific dom element to get the input from.
  38074. * @param element Defines the element the controls should be listened from
  38075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38076. */
  38077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38078. /** @hidden */
  38079. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38080. /**
  38081. * Update the current camera state depending on the inputs that have been used this frame.
  38082. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38083. */
  38084. checkInputs(): void;
  38085. /**
  38086. * Detach the current controls from the specified dom element.
  38087. * @param element Defines the element to stop listening the inputs from
  38088. */
  38089. detachControl(element: Nullable<HTMLElement>): void;
  38090. /**
  38091. * Gets the class name of the current intput.
  38092. * @returns the class name
  38093. */
  38094. getClassName(): string;
  38095. /**
  38096. * Get the friendly name associated with the input class.
  38097. * @returns the input friendly name
  38098. */
  38099. getSimpleName(): string;
  38100. }
  38101. }
  38102. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38103. import { Nullable } from "babylonjs/types";
  38104. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38105. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38106. /**
  38107. * Listen to mouse events to control the camera.
  38108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38109. */
  38110. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38111. /**
  38112. * Defines the camera the input is attached to.
  38113. */
  38114. camera: FlyCamera;
  38115. /**
  38116. * Defines if touch is enabled. (Default is true.)
  38117. */
  38118. touchEnabled: boolean;
  38119. /**
  38120. * Defines the buttons associated with the input to handle camera rotation.
  38121. */
  38122. buttons: number[];
  38123. /**
  38124. * Assign buttons for Yaw control.
  38125. */
  38126. buttonsYaw: number[];
  38127. /**
  38128. * Assign buttons for Pitch control.
  38129. */
  38130. buttonsPitch: number[];
  38131. /**
  38132. * Assign buttons for Roll control.
  38133. */
  38134. buttonsRoll: number[];
  38135. /**
  38136. * Detect if any button is being pressed while mouse is moved.
  38137. * -1 = Mouse locked.
  38138. * 0 = Left button.
  38139. * 1 = Middle Button.
  38140. * 2 = Right Button.
  38141. */
  38142. activeButton: number;
  38143. /**
  38144. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38145. * Higher values reduce its sensitivity.
  38146. */
  38147. angularSensibility: number;
  38148. private _mousemoveCallback;
  38149. private _observer;
  38150. private _rollObserver;
  38151. private previousPosition;
  38152. private noPreventDefault;
  38153. private element;
  38154. /**
  38155. * Listen to mouse events to control the camera.
  38156. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38158. */
  38159. constructor(touchEnabled?: boolean);
  38160. /**
  38161. * Attach the mouse control to the HTML DOM element.
  38162. * @param element Defines the element that listens to the input events.
  38163. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38164. */
  38165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38166. /**
  38167. * Detach the current controls from the specified dom element.
  38168. * @param element Defines the element to stop listening the inputs from
  38169. */
  38170. detachControl(element: Nullable<HTMLElement>): void;
  38171. /**
  38172. * Gets the class name of the current input.
  38173. * @returns the class name.
  38174. */
  38175. getClassName(): string;
  38176. /**
  38177. * Get the friendly name associated with the input class.
  38178. * @returns the input's friendly name.
  38179. */
  38180. getSimpleName(): string;
  38181. private _pointerInput;
  38182. private _onMouseMove;
  38183. /**
  38184. * Rotate camera by mouse offset.
  38185. */
  38186. private rotateCamera;
  38187. }
  38188. }
  38189. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38190. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38191. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38192. /**
  38193. * Default Inputs manager for the FlyCamera.
  38194. * It groups all the default supported inputs for ease of use.
  38195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38196. */
  38197. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38198. /**
  38199. * Instantiates a new FlyCameraInputsManager.
  38200. * @param camera Defines the camera the inputs belong to.
  38201. */
  38202. constructor(camera: FlyCamera);
  38203. /**
  38204. * Add keyboard input support to the input manager.
  38205. * @returns the new FlyCameraKeyboardMoveInput().
  38206. */
  38207. addKeyboard(): FlyCameraInputsManager;
  38208. /**
  38209. * Add mouse input support to the input manager.
  38210. * @param touchEnabled Enable touch screen support.
  38211. * @returns the new FlyCameraMouseInput().
  38212. */
  38213. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38214. }
  38215. }
  38216. declare module "babylonjs/Cameras/flyCamera" {
  38217. import { Scene } from "babylonjs/scene";
  38218. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38220. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38221. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38222. /**
  38223. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38224. * such as in a 3D Space Shooter or a Flight Simulator.
  38225. */
  38226. export class FlyCamera extends TargetCamera {
  38227. /**
  38228. * Define the collision ellipsoid of the camera.
  38229. * This is helpful for simulating a camera body, like a player's body.
  38230. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38231. */
  38232. ellipsoid: Vector3;
  38233. /**
  38234. * Define an offset for the position of the ellipsoid around the camera.
  38235. * This can be helpful if the camera is attached away from the player's body center,
  38236. * such as at its head.
  38237. */
  38238. ellipsoidOffset: Vector3;
  38239. /**
  38240. * Enable or disable collisions of the camera with the rest of the scene objects.
  38241. */
  38242. checkCollisions: boolean;
  38243. /**
  38244. * Enable or disable gravity on the camera.
  38245. */
  38246. applyGravity: boolean;
  38247. /**
  38248. * Define the current direction the camera is moving to.
  38249. */
  38250. cameraDirection: Vector3;
  38251. /**
  38252. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38253. * This overrides and empties cameraRotation.
  38254. */
  38255. rotationQuaternion: Quaternion;
  38256. /**
  38257. * Track Roll to maintain the wanted Rolling when looking around.
  38258. */
  38259. _trackRoll: number;
  38260. /**
  38261. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38262. */
  38263. rollCorrect: number;
  38264. /**
  38265. * Mimic a banked turn, Rolling the camera when Yawing.
  38266. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38267. */
  38268. bankedTurn: boolean;
  38269. /**
  38270. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38271. */
  38272. bankedTurnLimit: number;
  38273. /**
  38274. * Value of 0 disables the banked Roll.
  38275. * Value of 1 is equal to the Yaw angle in radians.
  38276. */
  38277. bankedTurnMultiplier: number;
  38278. /**
  38279. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38280. */
  38281. inputs: FlyCameraInputsManager;
  38282. /**
  38283. * Gets the input sensibility for mouse input.
  38284. * Higher values reduce sensitivity.
  38285. */
  38286. /**
  38287. * Sets the input sensibility for a mouse input.
  38288. * Higher values reduce sensitivity.
  38289. */
  38290. angularSensibility: number;
  38291. /**
  38292. * Get the keys for camera movement forward.
  38293. */
  38294. /**
  38295. * Set the keys for camera movement forward.
  38296. */
  38297. keysForward: number[];
  38298. /**
  38299. * Get the keys for camera movement backward.
  38300. */
  38301. keysBackward: number[];
  38302. /**
  38303. * Get the keys for camera movement up.
  38304. */
  38305. /**
  38306. * Set the keys for camera movement up.
  38307. */
  38308. keysUp: number[];
  38309. /**
  38310. * Get the keys for camera movement down.
  38311. */
  38312. /**
  38313. * Set the keys for camera movement down.
  38314. */
  38315. keysDown: number[];
  38316. /**
  38317. * Get the keys for camera movement left.
  38318. */
  38319. /**
  38320. * Set the keys for camera movement left.
  38321. */
  38322. keysLeft: number[];
  38323. /**
  38324. * Set the keys for camera movement right.
  38325. */
  38326. /**
  38327. * Set the keys for camera movement right.
  38328. */
  38329. keysRight: number[];
  38330. /**
  38331. * Event raised when the camera collides with a mesh in the scene.
  38332. */
  38333. onCollide: (collidedMesh: AbstractMesh) => void;
  38334. private _collider;
  38335. private _needMoveForGravity;
  38336. private _oldPosition;
  38337. private _diffPosition;
  38338. private _newPosition;
  38339. /** @hidden */
  38340. _localDirection: Vector3;
  38341. /** @hidden */
  38342. _transformedDirection: Vector3;
  38343. /**
  38344. * Instantiates a FlyCamera.
  38345. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38346. * such as in a 3D Space Shooter or a Flight Simulator.
  38347. * @param name Define the name of the camera in the scene.
  38348. * @param position Define the starting position of the camera in the scene.
  38349. * @param scene Define the scene the camera belongs to.
  38350. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38351. */
  38352. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38353. /**
  38354. * Attach a control to the HTML DOM element.
  38355. * @param element Defines the element that listens to the input events.
  38356. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38357. */
  38358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38359. /**
  38360. * Detach a control from the HTML DOM element.
  38361. * The camera will stop reacting to that input.
  38362. * @param element Defines the element that listens to the input events.
  38363. */
  38364. detachControl(element: HTMLElement): void;
  38365. private _collisionMask;
  38366. /**
  38367. * Get the mask that the camera ignores in collision events.
  38368. */
  38369. /**
  38370. * Set the mask that the camera ignores in collision events.
  38371. */
  38372. collisionMask: number;
  38373. /** @hidden */
  38374. _collideWithWorld(displacement: Vector3): void;
  38375. /** @hidden */
  38376. private _onCollisionPositionChange;
  38377. /** @hidden */
  38378. _checkInputs(): void;
  38379. /** @hidden */
  38380. _decideIfNeedsToMove(): boolean;
  38381. /** @hidden */
  38382. _updatePosition(): void;
  38383. /**
  38384. * Restore the Roll to its target value at the rate specified.
  38385. * @param rate - Higher means slower restoring.
  38386. * @hidden
  38387. */
  38388. restoreRoll(rate: number): void;
  38389. /**
  38390. * Destroy the camera and release the current resources held by it.
  38391. */
  38392. dispose(): void;
  38393. /**
  38394. * Get the current object class name.
  38395. * @returns the class name.
  38396. */
  38397. getClassName(): string;
  38398. }
  38399. }
  38400. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38401. import { Nullable } from "babylonjs/types";
  38402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38403. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38404. /**
  38405. * Listen to keyboard events to control the camera.
  38406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38407. */
  38408. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38409. /**
  38410. * Defines the camera the input is attached to.
  38411. */
  38412. camera: FlyCamera;
  38413. /**
  38414. * The list of keyboard keys used to control the forward move of the camera.
  38415. */
  38416. keysForward: number[];
  38417. /**
  38418. * The list of keyboard keys used to control the backward move of the camera.
  38419. */
  38420. keysBackward: number[];
  38421. /**
  38422. * The list of keyboard keys used to control the forward move of the camera.
  38423. */
  38424. keysUp: number[];
  38425. /**
  38426. * The list of keyboard keys used to control the backward move of the camera.
  38427. */
  38428. keysDown: number[];
  38429. /**
  38430. * The list of keyboard keys used to control the right strafe move of the camera.
  38431. */
  38432. keysRight: number[];
  38433. /**
  38434. * The list of keyboard keys used to control the left strafe move of the camera.
  38435. */
  38436. keysLeft: number[];
  38437. private _keys;
  38438. private _onCanvasBlurObserver;
  38439. private _onKeyboardObserver;
  38440. private _engine;
  38441. private _scene;
  38442. /**
  38443. * Attach the input controls to a specific dom element to get the input from.
  38444. * @param element Defines the element the controls should be listened from
  38445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38446. */
  38447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38448. /**
  38449. * Detach the current controls from the specified dom element.
  38450. * @param element Defines the element to stop listening the inputs from
  38451. */
  38452. detachControl(element: Nullable<HTMLElement>): void;
  38453. /**
  38454. * Gets the class name of the current intput.
  38455. * @returns the class name
  38456. */
  38457. getClassName(): string;
  38458. /** @hidden */
  38459. _onLostFocus(e: FocusEvent): void;
  38460. /**
  38461. * Get the friendly name associated with the input class.
  38462. * @returns the input friendly name
  38463. */
  38464. getSimpleName(): string;
  38465. /**
  38466. * Update the current camera state depending on the inputs that have been used this frame.
  38467. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38468. */
  38469. checkInputs(): void;
  38470. }
  38471. }
  38472. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38473. import { Nullable } from "babylonjs/types";
  38474. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38475. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38476. /**
  38477. * Manage the mouse wheel inputs to control a follow camera.
  38478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38479. */
  38480. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38481. /**
  38482. * Defines the camera the input is attached to.
  38483. */
  38484. camera: FollowCamera;
  38485. /**
  38486. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38487. */
  38488. axisControlRadius: boolean;
  38489. /**
  38490. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38491. */
  38492. axisControlHeight: boolean;
  38493. /**
  38494. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38495. */
  38496. axisControlRotation: boolean;
  38497. /**
  38498. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38499. * relation to mouseWheel events.
  38500. */
  38501. wheelPrecision: number;
  38502. /**
  38503. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38504. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38505. */
  38506. wheelDeltaPercentage: number;
  38507. private _wheel;
  38508. private _observer;
  38509. /**
  38510. * Attach the input controls to a specific dom element to get the input from.
  38511. * @param element Defines the element the controls should be listened from
  38512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38513. */
  38514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38515. /**
  38516. * Detach the current controls from the specified dom element.
  38517. * @param element Defines the element to stop listening the inputs from
  38518. */
  38519. detachControl(element: Nullable<HTMLElement>): void;
  38520. /**
  38521. * Gets the class name of the current intput.
  38522. * @returns the class name
  38523. */
  38524. getClassName(): string;
  38525. /**
  38526. * Get the friendly name associated with the input class.
  38527. * @returns the input friendly name
  38528. */
  38529. getSimpleName(): string;
  38530. }
  38531. }
  38532. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38533. import { Nullable } from "babylonjs/types";
  38534. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38535. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38536. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38537. /**
  38538. * Manage the pointers inputs to control an follow camera.
  38539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38540. */
  38541. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38542. /**
  38543. * Defines the camera the input is attached to.
  38544. */
  38545. camera: FollowCamera;
  38546. /**
  38547. * Gets the class name of the current input.
  38548. * @returns the class name
  38549. */
  38550. getClassName(): string;
  38551. /**
  38552. * Defines the pointer angular sensibility along the X axis or how fast is
  38553. * the camera rotating.
  38554. * A negative number will reverse the axis direction.
  38555. */
  38556. angularSensibilityX: number;
  38557. /**
  38558. * Defines the pointer angular sensibility along the Y axis or how fast is
  38559. * the camera rotating.
  38560. * A negative number will reverse the axis direction.
  38561. */
  38562. angularSensibilityY: number;
  38563. /**
  38564. * Defines the pointer pinch precision or how fast is the camera zooming.
  38565. * A negative number will reverse the axis direction.
  38566. */
  38567. pinchPrecision: number;
  38568. /**
  38569. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38570. * from 0.
  38571. * It defines the percentage of current camera.radius to use as delta when
  38572. * pinch zoom is used.
  38573. */
  38574. pinchDeltaPercentage: number;
  38575. /**
  38576. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38577. */
  38578. axisXControlRadius: boolean;
  38579. /**
  38580. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38581. */
  38582. axisXControlHeight: boolean;
  38583. /**
  38584. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38585. */
  38586. axisXControlRotation: boolean;
  38587. /**
  38588. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38589. */
  38590. axisYControlRadius: boolean;
  38591. /**
  38592. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38593. */
  38594. axisYControlHeight: boolean;
  38595. /**
  38596. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38597. */
  38598. axisYControlRotation: boolean;
  38599. /**
  38600. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38601. */
  38602. axisPinchControlRadius: boolean;
  38603. /**
  38604. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38605. */
  38606. axisPinchControlHeight: boolean;
  38607. /**
  38608. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38609. */
  38610. axisPinchControlRotation: boolean;
  38611. /**
  38612. * Log error messages if basic misconfiguration has occurred.
  38613. */
  38614. warningEnable: boolean;
  38615. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38616. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38617. private _warningCounter;
  38618. private _warning;
  38619. }
  38620. }
  38621. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38622. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38623. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38624. /**
  38625. * Default Inputs manager for the FollowCamera.
  38626. * It groups all the default supported inputs for ease of use.
  38627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38628. */
  38629. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38630. /**
  38631. * Instantiates a new FollowCameraInputsManager.
  38632. * @param camera Defines the camera the inputs belong to
  38633. */
  38634. constructor(camera: FollowCamera);
  38635. /**
  38636. * Add keyboard input support to the input manager.
  38637. * @returns the current input manager
  38638. */
  38639. addKeyboard(): FollowCameraInputsManager;
  38640. /**
  38641. * Add mouse wheel input support to the input manager.
  38642. * @returns the current input manager
  38643. */
  38644. addMouseWheel(): FollowCameraInputsManager;
  38645. /**
  38646. * Add pointers input support to the input manager.
  38647. * @returns the current input manager
  38648. */
  38649. addPointers(): FollowCameraInputsManager;
  38650. /**
  38651. * Add orientation input support to the input manager.
  38652. * @returns the current input manager
  38653. */
  38654. addVRDeviceOrientation(): FollowCameraInputsManager;
  38655. }
  38656. }
  38657. declare module "babylonjs/Cameras/followCamera" {
  38658. import { Nullable } from "babylonjs/types";
  38659. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38660. import { Scene } from "babylonjs/scene";
  38661. import { Vector3 } from "babylonjs/Maths/math.vector";
  38662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38663. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38664. /**
  38665. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38666. * an arc rotate version arcFollowCamera are available.
  38667. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38668. */
  38669. export class FollowCamera extends TargetCamera {
  38670. /**
  38671. * Distance the follow camera should follow an object at
  38672. */
  38673. radius: number;
  38674. /**
  38675. * Minimum allowed distance of the camera to the axis of rotation
  38676. * (The camera can not get closer).
  38677. * This can help limiting how the Camera is able to move in the scene.
  38678. */
  38679. lowerRadiusLimit: Nullable<number>;
  38680. /**
  38681. * Maximum allowed distance of the camera to the axis of rotation
  38682. * (The camera can not get further).
  38683. * This can help limiting how the Camera is able to move in the scene.
  38684. */
  38685. upperRadiusLimit: Nullable<number>;
  38686. /**
  38687. * Define a rotation offset between the camera and the object it follows
  38688. */
  38689. rotationOffset: number;
  38690. /**
  38691. * Minimum allowed angle to camera position relative to target object.
  38692. * This can help limiting how the Camera is able to move in the scene.
  38693. */
  38694. lowerRotationOffsetLimit: Nullable<number>;
  38695. /**
  38696. * Maximum allowed angle to camera position relative to target object.
  38697. * This can help limiting how the Camera is able to move in the scene.
  38698. */
  38699. upperRotationOffsetLimit: Nullable<number>;
  38700. /**
  38701. * Define a height offset between the camera and the object it follows.
  38702. * It can help following an object from the top (like a car chaing a plane)
  38703. */
  38704. heightOffset: number;
  38705. /**
  38706. * Minimum allowed height of camera position relative to target object.
  38707. * This can help limiting how the Camera is able to move in the scene.
  38708. */
  38709. lowerHeightOffsetLimit: Nullable<number>;
  38710. /**
  38711. * Maximum allowed height of camera position relative to target object.
  38712. * This can help limiting how the Camera is able to move in the scene.
  38713. */
  38714. upperHeightOffsetLimit: Nullable<number>;
  38715. /**
  38716. * Define how fast the camera can accelerate to follow it s target.
  38717. */
  38718. cameraAcceleration: number;
  38719. /**
  38720. * Define the speed limit of the camera following an object.
  38721. */
  38722. maxCameraSpeed: number;
  38723. /**
  38724. * Define the target of the camera.
  38725. */
  38726. lockedTarget: Nullable<AbstractMesh>;
  38727. /**
  38728. * Defines the input associated with the camera.
  38729. */
  38730. inputs: FollowCameraInputsManager;
  38731. /**
  38732. * Instantiates the follow camera.
  38733. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38734. * @param name Define the name of the camera in the scene
  38735. * @param position Define the position of the camera
  38736. * @param scene Define the scene the camera belong to
  38737. * @param lockedTarget Define the target of the camera
  38738. */
  38739. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38740. private _follow;
  38741. /**
  38742. * Attached controls to the current camera.
  38743. * @param element Defines the element the controls should be listened from
  38744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38745. */
  38746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38747. /**
  38748. * Detach the current controls from the camera.
  38749. * The camera will stop reacting to inputs.
  38750. * @param element Defines the element to stop listening the inputs from
  38751. */
  38752. detachControl(element: HTMLElement): void;
  38753. /** @hidden */
  38754. _checkInputs(): void;
  38755. private _checkLimits;
  38756. /**
  38757. * Gets the camera class name.
  38758. * @returns the class name
  38759. */
  38760. getClassName(): string;
  38761. }
  38762. /**
  38763. * Arc Rotate version of the follow camera.
  38764. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38765. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38766. */
  38767. export class ArcFollowCamera extends TargetCamera {
  38768. /** The longitudinal angle of the camera */
  38769. alpha: number;
  38770. /** The latitudinal angle of the camera */
  38771. beta: number;
  38772. /** The radius of the camera from its target */
  38773. radius: number;
  38774. /** Define the camera target (the messh it should follow) */
  38775. target: Nullable<AbstractMesh>;
  38776. private _cartesianCoordinates;
  38777. /**
  38778. * Instantiates a new ArcFollowCamera
  38779. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38780. * @param name Define the name of the camera
  38781. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38782. * @param beta Define the rotation angle of the camera around the elevation axis
  38783. * @param radius Define the radius of the camera from its target point
  38784. * @param target Define the target of the camera
  38785. * @param scene Define the scene the camera belongs to
  38786. */
  38787. constructor(name: string,
  38788. /** The longitudinal angle of the camera */
  38789. alpha: number,
  38790. /** The latitudinal angle of the camera */
  38791. beta: number,
  38792. /** The radius of the camera from its target */
  38793. radius: number,
  38794. /** Define the camera target (the messh it should follow) */
  38795. target: Nullable<AbstractMesh>, scene: Scene);
  38796. private _follow;
  38797. /** @hidden */
  38798. _checkInputs(): void;
  38799. /**
  38800. * Returns the class name of the object.
  38801. * It is mostly used internally for serialization purposes.
  38802. */
  38803. getClassName(): string;
  38804. }
  38805. }
  38806. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38807. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38808. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38809. import { Nullable } from "babylonjs/types";
  38810. /**
  38811. * Manage the keyboard inputs to control the movement of a follow camera.
  38812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38813. */
  38814. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38815. /**
  38816. * Defines the camera the input is attached to.
  38817. */
  38818. camera: FollowCamera;
  38819. /**
  38820. * Defines the list of key codes associated with the up action (increase heightOffset)
  38821. */
  38822. keysHeightOffsetIncr: number[];
  38823. /**
  38824. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38825. */
  38826. keysHeightOffsetDecr: number[];
  38827. /**
  38828. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38829. */
  38830. keysHeightOffsetModifierAlt: boolean;
  38831. /**
  38832. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38833. */
  38834. keysHeightOffsetModifierCtrl: boolean;
  38835. /**
  38836. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38837. */
  38838. keysHeightOffsetModifierShift: boolean;
  38839. /**
  38840. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38841. */
  38842. keysRotationOffsetIncr: number[];
  38843. /**
  38844. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38845. */
  38846. keysRotationOffsetDecr: number[];
  38847. /**
  38848. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38849. */
  38850. keysRotationOffsetModifierAlt: boolean;
  38851. /**
  38852. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38853. */
  38854. keysRotationOffsetModifierCtrl: boolean;
  38855. /**
  38856. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38857. */
  38858. keysRotationOffsetModifierShift: boolean;
  38859. /**
  38860. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38861. */
  38862. keysRadiusIncr: number[];
  38863. /**
  38864. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38865. */
  38866. keysRadiusDecr: number[];
  38867. /**
  38868. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38869. */
  38870. keysRadiusModifierAlt: boolean;
  38871. /**
  38872. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38873. */
  38874. keysRadiusModifierCtrl: boolean;
  38875. /**
  38876. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38877. */
  38878. keysRadiusModifierShift: boolean;
  38879. /**
  38880. * Defines the rate of change of heightOffset.
  38881. */
  38882. heightSensibility: number;
  38883. /**
  38884. * Defines the rate of change of rotationOffset.
  38885. */
  38886. rotationSensibility: number;
  38887. /**
  38888. * Defines the rate of change of radius.
  38889. */
  38890. radiusSensibility: number;
  38891. private _keys;
  38892. private _ctrlPressed;
  38893. private _altPressed;
  38894. private _shiftPressed;
  38895. private _onCanvasBlurObserver;
  38896. private _onKeyboardObserver;
  38897. private _engine;
  38898. private _scene;
  38899. /**
  38900. * Attach the input controls to a specific dom element to get the input from.
  38901. * @param element Defines the element the controls should be listened from
  38902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38903. */
  38904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38905. /**
  38906. * Detach the current controls from the specified dom element.
  38907. * @param element Defines the element to stop listening the inputs from
  38908. */
  38909. detachControl(element: Nullable<HTMLElement>): void;
  38910. /**
  38911. * Update the current camera state depending on the inputs that have been used this frame.
  38912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38913. */
  38914. checkInputs(): void;
  38915. /**
  38916. * Gets the class name of the current input.
  38917. * @returns the class name
  38918. */
  38919. getClassName(): string;
  38920. /**
  38921. * Get the friendly name associated with the input class.
  38922. * @returns the input friendly name
  38923. */
  38924. getSimpleName(): string;
  38925. /**
  38926. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38927. * allow modification of the heightOffset value.
  38928. */
  38929. private _modifierHeightOffset;
  38930. /**
  38931. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38932. * allow modification of the rotationOffset value.
  38933. */
  38934. private _modifierRotationOffset;
  38935. /**
  38936. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38937. * allow modification of the radius value.
  38938. */
  38939. private _modifierRadius;
  38940. }
  38941. }
  38942. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38943. import { Nullable } from "babylonjs/types";
  38944. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38945. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38946. import { Observable } from "babylonjs/Misc/observable";
  38947. module "babylonjs/Cameras/freeCameraInputsManager" {
  38948. interface FreeCameraInputsManager {
  38949. /**
  38950. * @hidden
  38951. */
  38952. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38953. /**
  38954. * Add orientation input support to the input manager.
  38955. * @returns the current input manager
  38956. */
  38957. addDeviceOrientation(): FreeCameraInputsManager;
  38958. }
  38959. }
  38960. /**
  38961. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38962. * Screen rotation is taken into account.
  38963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38964. */
  38965. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38966. private _camera;
  38967. private _screenOrientationAngle;
  38968. private _constantTranform;
  38969. private _screenQuaternion;
  38970. private _alpha;
  38971. private _beta;
  38972. private _gamma;
  38973. /**
  38974. * Can be used to detect if a device orientation sensor is availible on a device
  38975. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38976. * @returns a promise that will resolve on orientation change
  38977. */
  38978. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38979. /**
  38980. * @hidden
  38981. */
  38982. _onDeviceOrientationChangedObservable: Observable<void>;
  38983. /**
  38984. * Instantiates a new input
  38985. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38986. */
  38987. constructor();
  38988. /**
  38989. * Define the camera controlled by the input.
  38990. */
  38991. camera: FreeCamera;
  38992. /**
  38993. * Attach the input controls to a specific dom element to get the input from.
  38994. * @param element Defines the element the controls should be listened from
  38995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38996. */
  38997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38998. private _orientationChanged;
  38999. private _deviceOrientation;
  39000. /**
  39001. * Detach the current controls from the specified dom element.
  39002. * @param element Defines the element to stop listening the inputs from
  39003. */
  39004. detachControl(element: Nullable<HTMLElement>): void;
  39005. /**
  39006. * Update the current camera state depending on the inputs that have been used this frame.
  39007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39008. */
  39009. checkInputs(): void;
  39010. /**
  39011. * Gets the class name of the current intput.
  39012. * @returns the class name
  39013. */
  39014. getClassName(): string;
  39015. /**
  39016. * Get the friendly name associated with the input class.
  39017. * @returns the input friendly name
  39018. */
  39019. getSimpleName(): string;
  39020. }
  39021. }
  39022. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39023. import { Nullable } from "babylonjs/types";
  39024. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39025. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39026. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39027. /**
  39028. * Manage the gamepad inputs to control a free camera.
  39029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39030. */
  39031. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39032. /**
  39033. * Define the camera the input is attached to.
  39034. */
  39035. camera: FreeCamera;
  39036. /**
  39037. * Define the Gamepad controlling the input
  39038. */
  39039. gamepad: Nullable<Gamepad>;
  39040. /**
  39041. * Defines the gamepad rotation sensiblity.
  39042. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39043. */
  39044. gamepadAngularSensibility: number;
  39045. /**
  39046. * Defines the gamepad move sensiblity.
  39047. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39048. */
  39049. gamepadMoveSensibility: number;
  39050. private _onGamepadConnectedObserver;
  39051. private _onGamepadDisconnectedObserver;
  39052. private _cameraTransform;
  39053. private _deltaTransform;
  39054. private _vector3;
  39055. private _vector2;
  39056. /**
  39057. * Attach the input controls to a specific dom element to get the input from.
  39058. * @param element Defines the element the controls should be listened from
  39059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39060. */
  39061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39062. /**
  39063. * Detach the current controls from the specified dom element.
  39064. * @param element Defines the element to stop listening the inputs from
  39065. */
  39066. detachControl(element: Nullable<HTMLElement>): void;
  39067. /**
  39068. * Update the current camera state depending on the inputs that have been used this frame.
  39069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39070. */
  39071. checkInputs(): void;
  39072. /**
  39073. * Gets the class name of the current intput.
  39074. * @returns the class name
  39075. */
  39076. getClassName(): string;
  39077. /**
  39078. * Get the friendly name associated with the input class.
  39079. * @returns the input friendly name
  39080. */
  39081. getSimpleName(): string;
  39082. }
  39083. }
  39084. declare module "babylonjs/Misc/virtualJoystick" {
  39085. import { Nullable } from "babylonjs/types";
  39086. import { Vector3 } from "babylonjs/Maths/math.vector";
  39087. /**
  39088. * Defines the potential axis of a Joystick
  39089. */
  39090. export enum JoystickAxis {
  39091. /** X axis */
  39092. X = 0,
  39093. /** Y axis */
  39094. Y = 1,
  39095. /** Z axis */
  39096. Z = 2
  39097. }
  39098. /**
  39099. * Class used to define virtual joystick (used in touch mode)
  39100. */
  39101. export class VirtualJoystick {
  39102. /**
  39103. * Gets or sets a boolean indicating that left and right values must be inverted
  39104. */
  39105. reverseLeftRight: boolean;
  39106. /**
  39107. * Gets or sets a boolean indicating that up and down values must be inverted
  39108. */
  39109. reverseUpDown: boolean;
  39110. /**
  39111. * Gets the offset value for the position (ie. the change of the position value)
  39112. */
  39113. deltaPosition: Vector3;
  39114. /**
  39115. * Gets a boolean indicating if the virtual joystick was pressed
  39116. */
  39117. pressed: boolean;
  39118. /**
  39119. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39120. */
  39121. static Canvas: Nullable<HTMLCanvasElement>;
  39122. private static _globalJoystickIndex;
  39123. private static vjCanvasContext;
  39124. private static vjCanvasWidth;
  39125. private static vjCanvasHeight;
  39126. private static halfWidth;
  39127. private _action;
  39128. private _axisTargetedByLeftAndRight;
  39129. private _axisTargetedByUpAndDown;
  39130. private _joystickSensibility;
  39131. private _inversedSensibility;
  39132. private _joystickPointerID;
  39133. private _joystickColor;
  39134. private _joystickPointerPos;
  39135. private _joystickPreviousPointerPos;
  39136. private _joystickPointerStartPos;
  39137. private _deltaJoystickVector;
  39138. private _leftJoystick;
  39139. private _touches;
  39140. private _onPointerDownHandlerRef;
  39141. private _onPointerMoveHandlerRef;
  39142. private _onPointerUpHandlerRef;
  39143. private _onResize;
  39144. /**
  39145. * Creates a new virtual joystick
  39146. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39147. */
  39148. constructor(leftJoystick?: boolean);
  39149. /**
  39150. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39151. * @param newJoystickSensibility defines the new sensibility
  39152. */
  39153. setJoystickSensibility(newJoystickSensibility: number): void;
  39154. private _onPointerDown;
  39155. private _onPointerMove;
  39156. private _onPointerUp;
  39157. /**
  39158. * Change the color of the virtual joystick
  39159. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39160. */
  39161. setJoystickColor(newColor: string): void;
  39162. /**
  39163. * Defines a callback to call when the joystick is touched
  39164. * @param action defines the callback
  39165. */
  39166. setActionOnTouch(action: () => any): void;
  39167. /**
  39168. * Defines which axis you'd like to control for left & right
  39169. * @param axis defines the axis to use
  39170. */
  39171. setAxisForLeftRight(axis: JoystickAxis): void;
  39172. /**
  39173. * Defines which axis you'd like to control for up & down
  39174. * @param axis defines the axis to use
  39175. */
  39176. setAxisForUpDown(axis: JoystickAxis): void;
  39177. private _drawVirtualJoystick;
  39178. /**
  39179. * Release internal HTML canvas
  39180. */
  39181. releaseCanvas(): void;
  39182. }
  39183. }
  39184. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39185. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39186. import { Nullable } from "babylonjs/types";
  39187. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39188. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39189. module "babylonjs/Cameras/freeCameraInputsManager" {
  39190. interface FreeCameraInputsManager {
  39191. /**
  39192. * Add virtual joystick input support to the input manager.
  39193. * @returns the current input manager
  39194. */
  39195. addVirtualJoystick(): FreeCameraInputsManager;
  39196. }
  39197. }
  39198. /**
  39199. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39201. */
  39202. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39203. /**
  39204. * Defines the camera the input is attached to.
  39205. */
  39206. camera: FreeCamera;
  39207. private _leftjoystick;
  39208. private _rightjoystick;
  39209. /**
  39210. * Gets the left stick of the virtual joystick.
  39211. * @returns The virtual Joystick
  39212. */
  39213. getLeftJoystick(): VirtualJoystick;
  39214. /**
  39215. * Gets the right stick of the virtual joystick.
  39216. * @returns The virtual Joystick
  39217. */
  39218. getRightJoystick(): VirtualJoystick;
  39219. /**
  39220. * Update the current camera state depending on the inputs that have been used this frame.
  39221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39222. */
  39223. checkInputs(): void;
  39224. /**
  39225. * Attach the input controls to a specific dom element to get the input from.
  39226. * @param element Defines the element the controls should be listened from
  39227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39228. */
  39229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39230. /**
  39231. * Detach the current controls from the specified dom element.
  39232. * @param element Defines the element to stop listening the inputs from
  39233. */
  39234. detachControl(element: Nullable<HTMLElement>): void;
  39235. /**
  39236. * Gets the class name of the current intput.
  39237. * @returns the class name
  39238. */
  39239. getClassName(): string;
  39240. /**
  39241. * Get the friendly name associated with the input class.
  39242. * @returns the input friendly name
  39243. */
  39244. getSimpleName(): string;
  39245. }
  39246. }
  39247. declare module "babylonjs/Cameras/Inputs/index" {
  39248. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39249. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39250. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39251. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39252. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39253. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39254. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39255. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39256. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39257. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39258. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39259. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39260. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39261. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39262. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39263. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39264. }
  39265. declare module "babylonjs/Cameras/touchCamera" {
  39266. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39267. import { Scene } from "babylonjs/scene";
  39268. import { Vector3 } from "babylonjs/Maths/math.vector";
  39269. /**
  39270. * This represents a FPS type of camera controlled by touch.
  39271. * This is like a universal camera minus the Gamepad controls.
  39272. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39273. */
  39274. export class TouchCamera extends FreeCamera {
  39275. /**
  39276. * Defines the touch sensibility for rotation.
  39277. * The higher the faster.
  39278. */
  39279. touchAngularSensibility: number;
  39280. /**
  39281. * Defines the touch sensibility for move.
  39282. * The higher the faster.
  39283. */
  39284. touchMoveSensibility: number;
  39285. /**
  39286. * Instantiates a new touch camera.
  39287. * This represents a FPS type of camera controlled by touch.
  39288. * This is like a universal camera minus the Gamepad controls.
  39289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39290. * @param name Define the name of the camera in the scene
  39291. * @param position Define the start position of the camera in the scene
  39292. * @param scene Define the scene the camera belongs to
  39293. */
  39294. constructor(name: string, position: Vector3, scene: Scene);
  39295. /**
  39296. * Gets the current object class name.
  39297. * @return the class name
  39298. */
  39299. getClassName(): string;
  39300. /** @hidden */
  39301. _setupInputs(): void;
  39302. }
  39303. }
  39304. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39305. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39306. import { Scene } from "babylonjs/scene";
  39307. import { Vector3 } from "babylonjs/Maths/math.vector";
  39308. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39309. import { Axis } from "babylonjs/Maths/math.axis";
  39310. /**
  39311. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39312. * being tilted forward or back and left or right.
  39313. */
  39314. export class DeviceOrientationCamera extends FreeCamera {
  39315. private _initialQuaternion;
  39316. private _quaternionCache;
  39317. private _tmpDragQuaternion;
  39318. /**
  39319. * Creates a new device orientation camera
  39320. * @param name The name of the camera
  39321. * @param position The start position camera
  39322. * @param scene The scene the camera belongs to
  39323. */
  39324. constructor(name: string, position: Vector3, scene: Scene);
  39325. /**
  39326. * @hidden
  39327. * Disabled pointer input on first orientation sensor update (Default: true)
  39328. */
  39329. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39330. private _dragFactor;
  39331. /**
  39332. * Enabled turning on the y axis when the orientation sensor is active
  39333. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39334. */
  39335. enableHorizontalDragging(dragFactor?: number): void;
  39336. /**
  39337. * Gets the current instance class name ("DeviceOrientationCamera").
  39338. * This helps avoiding instanceof at run time.
  39339. * @returns the class name
  39340. */
  39341. getClassName(): string;
  39342. /**
  39343. * @hidden
  39344. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39345. */
  39346. _checkInputs(): void;
  39347. /**
  39348. * Reset the camera to its default orientation on the specified axis only.
  39349. * @param axis The axis to reset
  39350. */
  39351. resetToCurrentRotation(axis?: Axis): void;
  39352. }
  39353. }
  39354. declare module "babylonjs/Gamepads/xboxGamepad" {
  39355. import { Observable } from "babylonjs/Misc/observable";
  39356. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39357. /**
  39358. * Defines supported buttons for XBox360 compatible gamepads
  39359. */
  39360. export enum Xbox360Button {
  39361. /** A */
  39362. A = 0,
  39363. /** B */
  39364. B = 1,
  39365. /** X */
  39366. X = 2,
  39367. /** Y */
  39368. Y = 3,
  39369. /** Start */
  39370. Start = 4,
  39371. /** Back */
  39372. Back = 5,
  39373. /** Left button */
  39374. LB = 6,
  39375. /** Right button */
  39376. RB = 7,
  39377. /** Left stick */
  39378. LeftStick = 8,
  39379. /** Right stick */
  39380. RightStick = 9
  39381. }
  39382. /** Defines values for XBox360 DPad */
  39383. export enum Xbox360Dpad {
  39384. /** Up */
  39385. Up = 0,
  39386. /** Down */
  39387. Down = 1,
  39388. /** Left */
  39389. Left = 2,
  39390. /** Right */
  39391. Right = 3
  39392. }
  39393. /**
  39394. * Defines a XBox360 gamepad
  39395. */
  39396. export class Xbox360Pad extends Gamepad {
  39397. private _leftTrigger;
  39398. private _rightTrigger;
  39399. private _onlefttriggerchanged;
  39400. private _onrighttriggerchanged;
  39401. private _onbuttondown;
  39402. private _onbuttonup;
  39403. private _ondpaddown;
  39404. private _ondpadup;
  39405. /** Observable raised when a button is pressed */
  39406. onButtonDownObservable: Observable<Xbox360Button>;
  39407. /** Observable raised when a button is released */
  39408. onButtonUpObservable: Observable<Xbox360Button>;
  39409. /** Observable raised when a pad is pressed */
  39410. onPadDownObservable: Observable<Xbox360Dpad>;
  39411. /** Observable raised when a pad is released */
  39412. onPadUpObservable: Observable<Xbox360Dpad>;
  39413. private _buttonA;
  39414. private _buttonB;
  39415. private _buttonX;
  39416. private _buttonY;
  39417. private _buttonBack;
  39418. private _buttonStart;
  39419. private _buttonLB;
  39420. private _buttonRB;
  39421. private _buttonLeftStick;
  39422. private _buttonRightStick;
  39423. private _dPadUp;
  39424. private _dPadDown;
  39425. private _dPadLeft;
  39426. private _dPadRight;
  39427. private _isXboxOnePad;
  39428. /**
  39429. * Creates a new XBox360 gamepad object
  39430. * @param id defines the id of this gamepad
  39431. * @param index defines its index
  39432. * @param gamepad defines the internal HTML gamepad object
  39433. * @param xboxOne defines if it is a XBox One gamepad
  39434. */
  39435. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39436. /**
  39437. * Defines the callback to call when left trigger is pressed
  39438. * @param callback defines the callback to use
  39439. */
  39440. onlefttriggerchanged(callback: (value: number) => void): void;
  39441. /**
  39442. * Defines the callback to call when right trigger is pressed
  39443. * @param callback defines the callback to use
  39444. */
  39445. onrighttriggerchanged(callback: (value: number) => void): void;
  39446. /**
  39447. * Gets the left trigger value
  39448. */
  39449. /**
  39450. * Sets the left trigger value
  39451. */
  39452. leftTrigger: number;
  39453. /**
  39454. * Gets the right trigger value
  39455. */
  39456. /**
  39457. * Sets the right trigger value
  39458. */
  39459. rightTrigger: number;
  39460. /**
  39461. * Defines the callback to call when a button is pressed
  39462. * @param callback defines the callback to use
  39463. */
  39464. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39465. /**
  39466. * Defines the callback to call when a button is released
  39467. * @param callback defines the callback to use
  39468. */
  39469. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39470. /**
  39471. * Defines the callback to call when a pad is pressed
  39472. * @param callback defines the callback to use
  39473. */
  39474. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39475. /**
  39476. * Defines the callback to call when a pad is released
  39477. * @param callback defines the callback to use
  39478. */
  39479. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39480. private _setButtonValue;
  39481. private _setDPadValue;
  39482. /**
  39483. * Gets the value of the `A` button
  39484. */
  39485. /**
  39486. * Sets the value of the `A` button
  39487. */
  39488. buttonA: number;
  39489. /**
  39490. * Gets the value of the `B` button
  39491. */
  39492. /**
  39493. * Sets the value of the `B` button
  39494. */
  39495. buttonB: number;
  39496. /**
  39497. * Gets the value of the `X` button
  39498. */
  39499. /**
  39500. * Sets the value of the `X` button
  39501. */
  39502. buttonX: number;
  39503. /**
  39504. * Gets the value of the `Y` button
  39505. */
  39506. /**
  39507. * Sets the value of the `Y` button
  39508. */
  39509. buttonY: number;
  39510. /**
  39511. * Gets the value of the `Start` button
  39512. */
  39513. /**
  39514. * Sets the value of the `Start` button
  39515. */
  39516. buttonStart: number;
  39517. /**
  39518. * Gets the value of the `Back` button
  39519. */
  39520. /**
  39521. * Sets the value of the `Back` button
  39522. */
  39523. buttonBack: number;
  39524. /**
  39525. * Gets the value of the `Left` button
  39526. */
  39527. /**
  39528. * Sets the value of the `Left` button
  39529. */
  39530. buttonLB: number;
  39531. /**
  39532. * Gets the value of the `Right` button
  39533. */
  39534. /**
  39535. * Sets the value of the `Right` button
  39536. */
  39537. buttonRB: number;
  39538. /**
  39539. * Gets the value of the Left joystick
  39540. */
  39541. /**
  39542. * Sets the value of the Left joystick
  39543. */
  39544. buttonLeftStick: number;
  39545. /**
  39546. * Gets the value of the Right joystick
  39547. */
  39548. /**
  39549. * Sets the value of the Right joystick
  39550. */
  39551. buttonRightStick: number;
  39552. /**
  39553. * Gets the value of D-pad up
  39554. */
  39555. /**
  39556. * Sets the value of D-pad up
  39557. */
  39558. dPadUp: number;
  39559. /**
  39560. * Gets the value of D-pad down
  39561. */
  39562. /**
  39563. * Sets the value of D-pad down
  39564. */
  39565. dPadDown: number;
  39566. /**
  39567. * Gets the value of D-pad left
  39568. */
  39569. /**
  39570. * Sets the value of D-pad left
  39571. */
  39572. dPadLeft: number;
  39573. /**
  39574. * Gets the value of D-pad right
  39575. */
  39576. /**
  39577. * Sets the value of D-pad right
  39578. */
  39579. dPadRight: number;
  39580. /**
  39581. * Force the gamepad to synchronize with device values
  39582. */
  39583. update(): void;
  39584. /**
  39585. * Disposes the gamepad
  39586. */
  39587. dispose(): void;
  39588. }
  39589. }
  39590. declare module "babylonjs/Gamepads/gamepadManager" {
  39591. import { Observable } from "babylonjs/Misc/observable";
  39592. import { Nullable } from "babylonjs/types";
  39593. import { Scene } from "babylonjs/scene";
  39594. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39595. /**
  39596. * Manager for handling gamepads
  39597. */
  39598. export class GamepadManager {
  39599. private _scene?;
  39600. private _babylonGamepads;
  39601. private _oneGamepadConnected;
  39602. /** @hidden */
  39603. _isMonitoring: boolean;
  39604. private _gamepadEventSupported;
  39605. private _gamepadSupport;
  39606. /**
  39607. * observable to be triggered when the gamepad controller has been connected
  39608. */
  39609. onGamepadConnectedObservable: Observable<Gamepad>;
  39610. /**
  39611. * observable to be triggered when the gamepad controller has been disconnected
  39612. */
  39613. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39614. private _onGamepadConnectedEvent;
  39615. private _onGamepadDisconnectedEvent;
  39616. /**
  39617. * Initializes the gamepad manager
  39618. * @param _scene BabylonJS scene
  39619. */
  39620. constructor(_scene?: Scene | undefined);
  39621. /**
  39622. * The gamepads in the game pad manager
  39623. */
  39624. readonly gamepads: Gamepad[];
  39625. /**
  39626. * Get the gamepad controllers based on type
  39627. * @param type The type of gamepad controller
  39628. * @returns Nullable gamepad
  39629. */
  39630. getGamepadByType(type?: number): Nullable<Gamepad>;
  39631. /**
  39632. * Disposes the gamepad manager
  39633. */
  39634. dispose(): void;
  39635. private _addNewGamepad;
  39636. private _startMonitoringGamepads;
  39637. private _stopMonitoringGamepads;
  39638. /** @hidden */
  39639. _checkGamepadsStatus(): void;
  39640. private _updateGamepadObjects;
  39641. }
  39642. }
  39643. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39644. import { Nullable } from "babylonjs/types";
  39645. import { Scene } from "babylonjs/scene";
  39646. import { ISceneComponent } from "babylonjs/sceneComponent";
  39647. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39648. module "babylonjs/scene" {
  39649. interface Scene {
  39650. /** @hidden */
  39651. _gamepadManager: Nullable<GamepadManager>;
  39652. /**
  39653. * Gets the gamepad manager associated with the scene
  39654. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39655. */
  39656. gamepadManager: GamepadManager;
  39657. }
  39658. }
  39659. module "babylonjs/Cameras/freeCameraInputsManager" {
  39660. /**
  39661. * Interface representing a free camera inputs manager
  39662. */
  39663. interface FreeCameraInputsManager {
  39664. /**
  39665. * Adds gamepad input support to the FreeCameraInputsManager.
  39666. * @returns the FreeCameraInputsManager
  39667. */
  39668. addGamepad(): FreeCameraInputsManager;
  39669. }
  39670. }
  39671. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39672. /**
  39673. * Interface representing an arc rotate camera inputs manager
  39674. */
  39675. interface ArcRotateCameraInputsManager {
  39676. /**
  39677. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39678. * @returns the camera inputs manager
  39679. */
  39680. addGamepad(): ArcRotateCameraInputsManager;
  39681. }
  39682. }
  39683. /**
  39684. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39685. */
  39686. export class GamepadSystemSceneComponent implements ISceneComponent {
  39687. /**
  39688. * The component name helpfull to identify the component in the list of scene components.
  39689. */
  39690. readonly name: string;
  39691. /**
  39692. * The scene the component belongs to.
  39693. */
  39694. scene: Scene;
  39695. /**
  39696. * Creates a new instance of the component for the given scene
  39697. * @param scene Defines the scene to register the component in
  39698. */
  39699. constructor(scene: Scene);
  39700. /**
  39701. * Registers the component in a given scene
  39702. */
  39703. register(): void;
  39704. /**
  39705. * Rebuilds the elements related to this component in case of
  39706. * context lost for instance.
  39707. */
  39708. rebuild(): void;
  39709. /**
  39710. * Disposes the component and the associated ressources
  39711. */
  39712. dispose(): void;
  39713. private _beforeCameraUpdate;
  39714. }
  39715. }
  39716. declare module "babylonjs/Cameras/universalCamera" {
  39717. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39718. import { Scene } from "babylonjs/scene";
  39719. import { Vector3 } from "babylonjs/Maths/math.vector";
  39720. import "babylonjs/Gamepads/gamepadSceneComponent";
  39721. /**
  39722. * 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,
  39723. * which still works and will still be found in many Playgrounds.
  39724. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39725. */
  39726. export class UniversalCamera extends TouchCamera {
  39727. /**
  39728. * Defines the gamepad rotation sensiblity.
  39729. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39730. */
  39731. gamepadAngularSensibility: number;
  39732. /**
  39733. * Defines the gamepad move sensiblity.
  39734. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39735. */
  39736. gamepadMoveSensibility: number;
  39737. /**
  39738. * 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,
  39739. * which still works and will still be found in many Playgrounds.
  39740. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39741. * @param name Define the name of the camera in the scene
  39742. * @param position Define the start position of the camera in the scene
  39743. * @param scene Define the scene the camera belongs to
  39744. */
  39745. constructor(name: string, position: Vector3, scene: Scene);
  39746. /**
  39747. * Gets the current object class name.
  39748. * @return the class name
  39749. */
  39750. getClassName(): string;
  39751. }
  39752. }
  39753. declare module "babylonjs/Cameras/gamepadCamera" {
  39754. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39755. import { Scene } from "babylonjs/scene";
  39756. import { Vector3 } from "babylonjs/Maths/math.vector";
  39757. /**
  39758. * This represents a FPS type of camera. This is only here for back compat purpose.
  39759. * Please use the UniversalCamera instead as both are identical.
  39760. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39761. */
  39762. export class GamepadCamera extends UniversalCamera {
  39763. /**
  39764. * Instantiates a new Gamepad Camera
  39765. * This represents a FPS type of camera. This is only here for back compat purpose.
  39766. * Please use the UniversalCamera instead as both are identical.
  39767. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39768. * @param name Define the name of the camera in the scene
  39769. * @param position Define the start position of the camera in the scene
  39770. * @param scene Define the scene the camera belongs to
  39771. */
  39772. constructor(name: string, position: Vector3, scene: Scene);
  39773. /**
  39774. * Gets the current object class name.
  39775. * @return the class name
  39776. */
  39777. getClassName(): string;
  39778. }
  39779. }
  39780. declare module "babylonjs/Shaders/pass.fragment" {
  39781. /** @hidden */
  39782. export var passPixelShader: {
  39783. name: string;
  39784. shader: string;
  39785. };
  39786. }
  39787. declare module "babylonjs/Shaders/passCube.fragment" {
  39788. /** @hidden */
  39789. export var passCubePixelShader: {
  39790. name: string;
  39791. shader: string;
  39792. };
  39793. }
  39794. declare module "babylonjs/PostProcesses/passPostProcess" {
  39795. import { Nullable } from "babylonjs/types";
  39796. import { Camera } from "babylonjs/Cameras/camera";
  39797. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39798. import { Engine } from "babylonjs/Engines/engine";
  39799. import "babylonjs/Shaders/pass.fragment";
  39800. import "babylonjs/Shaders/passCube.fragment";
  39801. /**
  39802. * PassPostProcess which produces an output the same as it's input
  39803. */
  39804. export class PassPostProcess extends PostProcess {
  39805. /**
  39806. * Creates the PassPostProcess
  39807. * @param name The name of the effect.
  39808. * @param options The required width/height ratio to downsize to before computing the render pass.
  39809. * @param camera The camera to apply the render pass to.
  39810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39811. * @param engine The engine which the post process will be applied. (default: current engine)
  39812. * @param reusable If the post process can be reused on the same frame. (default: false)
  39813. * @param textureType The type of texture to be used when performing the post processing.
  39814. * @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)
  39815. */
  39816. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39817. }
  39818. /**
  39819. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39820. */
  39821. export class PassCubePostProcess extends PostProcess {
  39822. private _face;
  39823. /**
  39824. * Gets or sets the cube face to display.
  39825. * * 0 is +X
  39826. * * 1 is -X
  39827. * * 2 is +Y
  39828. * * 3 is -Y
  39829. * * 4 is +Z
  39830. * * 5 is -Z
  39831. */
  39832. face: number;
  39833. /**
  39834. * Creates the PassCubePostProcess
  39835. * @param name The name of the effect.
  39836. * @param options The required width/height ratio to downsize to before computing the render pass.
  39837. * @param camera The camera to apply the render pass to.
  39838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39839. * @param engine The engine which the post process will be applied. (default: current engine)
  39840. * @param reusable If the post process can be reused on the same frame. (default: false)
  39841. * @param textureType The type of texture to be used when performing the post processing.
  39842. * @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)
  39843. */
  39844. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39845. }
  39846. }
  39847. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39848. /** @hidden */
  39849. export var anaglyphPixelShader: {
  39850. name: string;
  39851. shader: string;
  39852. };
  39853. }
  39854. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39855. import { Engine } from "babylonjs/Engines/engine";
  39856. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39857. import { Camera } from "babylonjs/Cameras/camera";
  39858. import "babylonjs/Shaders/anaglyph.fragment";
  39859. /**
  39860. * Postprocess used to generate anaglyphic rendering
  39861. */
  39862. export class AnaglyphPostProcess extends PostProcess {
  39863. private _passedProcess;
  39864. /**
  39865. * Creates a new AnaglyphPostProcess
  39866. * @param name defines postprocess name
  39867. * @param options defines creation options or target ratio scale
  39868. * @param rigCameras defines cameras using this postprocess
  39869. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39870. * @param engine defines hosting engine
  39871. * @param reusable defines if the postprocess will be reused multiple times per frame
  39872. */
  39873. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39874. }
  39875. }
  39876. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39877. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39878. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39879. import { Scene } from "babylonjs/scene";
  39880. import { Vector3 } from "babylonjs/Maths/math.vector";
  39881. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39882. /**
  39883. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39884. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39885. */
  39886. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39887. /**
  39888. * Creates a new AnaglyphArcRotateCamera
  39889. * @param name defines camera name
  39890. * @param alpha defines alpha angle (in radians)
  39891. * @param beta defines beta angle (in radians)
  39892. * @param radius defines radius
  39893. * @param target defines camera target
  39894. * @param interaxialDistance defines distance between each color axis
  39895. * @param scene defines the hosting scene
  39896. */
  39897. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39898. /**
  39899. * Gets camera class name
  39900. * @returns AnaglyphArcRotateCamera
  39901. */
  39902. getClassName(): string;
  39903. }
  39904. }
  39905. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39906. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39907. import { Scene } from "babylonjs/scene";
  39908. import { Vector3 } from "babylonjs/Maths/math.vector";
  39909. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39910. /**
  39911. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39912. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39913. */
  39914. export class AnaglyphFreeCamera extends FreeCamera {
  39915. /**
  39916. * Creates a new AnaglyphFreeCamera
  39917. * @param name defines camera name
  39918. * @param position defines initial position
  39919. * @param interaxialDistance defines distance between each color axis
  39920. * @param scene defines the hosting scene
  39921. */
  39922. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39923. /**
  39924. * Gets camera class name
  39925. * @returns AnaglyphFreeCamera
  39926. */
  39927. getClassName(): string;
  39928. }
  39929. }
  39930. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39931. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39932. import { Scene } from "babylonjs/scene";
  39933. import { Vector3 } from "babylonjs/Maths/math.vector";
  39934. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39935. /**
  39936. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39937. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39938. */
  39939. export class AnaglyphGamepadCamera extends GamepadCamera {
  39940. /**
  39941. * Creates a new AnaglyphGamepadCamera
  39942. * @param name defines camera name
  39943. * @param position defines initial position
  39944. * @param interaxialDistance defines distance between each color axis
  39945. * @param scene defines the hosting scene
  39946. */
  39947. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39948. /**
  39949. * Gets camera class name
  39950. * @returns AnaglyphGamepadCamera
  39951. */
  39952. getClassName(): string;
  39953. }
  39954. }
  39955. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39956. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39957. import { Scene } from "babylonjs/scene";
  39958. import { Vector3 } from "babylonjs/Maths/math.vector";
  39959. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39960. /**
  39961. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39962. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39963. */
  39964. export class AnaglyphUniversalCamera extends UniversalCamera {
  39965. /**
  39966. * Creates a new AnaglyphUniversalCamera
  39967. * @param name defines camera name
  39968. * @param position defines initial position
  39969. * @param interaxialDistance defines distance between each color axis
  39970. * @param scene defines the hosting scene
  39971. */
  39972. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39973. /**
  39974. * Gets camera class name
  39975. * @returns AnaglyphUniversalCamera
  39976. */
  39977. getClassName(): string;
  39978. }
  39979. }
  39980. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39981. /** @hidden */
  39982. export var stereoscopicInterlacePixelShader: {
  39983. name: string;
  39984. shader: string;
  39985. };
  39986. }
  39987. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39988. import { Camera } from "babylonjs/Cameras/camera";
  39989. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39990. import { Engine } from "babylonjs/Engines/engine";
  39991. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39992. /**
  39993. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39994. */
  39995. export class StereoscopicInterlacePostProcess extends PostProcess {
  39996. private _stepSize;
  39997. private _passedProcess;
  39998. /**
  39999. * Initializes a StereoscopicInterlacePostProcess
  40000. * @param name The name of the effect.
  40001. * @param rigCameras The rig cameras to be appled to the post process
  40002. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40004. * @param engine The engine which the post process will be applied. (default: current engine)
  40005. * @param reusable If the post process can be reused on the same frame. (default: false)
  40006. */
  40007. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40008. }
  40009. }
  40010. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40011. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40012. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40013. import { Scene } from "babylonjs/scene";
  40014. import { Vector3 } from "babylonjs/Maths/math.vector";
  40015. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40016. /**
  40017. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40018. * @see http://doc.babylonjs.com/features/cameras
  40019. */
  40020. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40021. /**
  40022. * Creates a new StereoscopicArcRotateCamera
  40023. * @param name defines camera name
  40024. * @param alpha defines alpha angle (in radians)
  40025. * @param beta defines beta angle (in radians)
  40026. * @param radius defines radius
  40027. * @param target defines camera target
  40028. * @param interaxialDistance defines distance between each color axis
  40029. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40030. * @param scene defines the hosting scene
  40031. */
  40032. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40033. /**
  40034. * Gets camera class name
  40035. * @returns StereoscopicArcRotateCamera
  40036. */
  40037. getClassName(): string;
  40038. }
  40039. }
  40040. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40041. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40042. import { Scene } from "babylonjs/scene";
  40043. import { Vector3 } from "babylonjs/Maths/math.vector";
  40044. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40045. /**
  40046. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40047. * @see http://doc.babylonjs.com/features/cameras
  40048. */
  40049. export class StereoscopicFreeCamera extends FreeCamera {
  40050. /**
  40051. * Creates a new StereoscopicFreeCamera
  40052. * @param name defines camera name
  40053. * @param position defines initial position
  40054. * @param interaxialDistance defines distance between each color axis
  40055. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40056. * @param scene defines the hosting scene
  40057. */
  40058. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40059. /**
  40060. * Gets camera class name
  40061. * @returns StereoscopicFreeCamera
  40062. */
  40063. getClassName(): string;
  40064. }
  40065. }
  40066. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40067. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40068. import { Scene } from "babylonjs/scene";
  40069. import { Vector3 } from "babylonjs/Maths/math.vector";
  40070. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40071. /**
  40072. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40073. * @see http://doc.babylonjs.com/features/cameras
  40074. */
  40075. export class StereoscopicGamepadCamera extends GamepadCamera {
  40076. /**
  40077. * Creates a new StereoscopicGamepadCamera
  40078. * @param name defines camera name
  40079. * @param position defines initial position
  40080. * @param interaxialDistance defines distance between each color axis
  40081. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40082. * @param scene defines the hosting scene
  40083. */
  40084. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40085. /**
  40086. * Gets camera class name
  40087. * @returns StereoscopicGamepadCamera
  40088. */
  40089. getClassName(): string;
  40090. }
  40091. }
  40092. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40093. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40094. import { Scene } from "babylonjs/scene";
  40095. import { Vector3 } from "babylonjs/Maths/math.vector";
  40096. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40097. /**
  40098. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40099. * @see http://doc.babylonjs.com/features/cameras
  40100. */
  40101. export class StereoscopicUniversalCamera extends UniversalCamera {
  40102. /**
  40103. * Creates a new StereoscopicUniversalCamera
  40104. * @param name defines camera name
  40105. * @param position defines initial position
  40106. * @param interaxialDistance defines distance between each color axis
  40107. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40108. * @param scene defines the hosting scene
  40109. */
  40110. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40111. /**
  40112. * Gets camera class name
  40113. * @returns StereoscopicUniversalCamera
  40114. */
  40115. getClassName(): string;
  40116. }
  40117. }
  40118. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40119. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40120. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40121. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40122. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40123. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40124. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40125. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40126. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40127. }
  40128. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40129. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40130. import { Scene } from "babylonjs/scene";
  40131. import { Vector3 } from "babylonjs/Maths/math.vector";
  40132. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40133. /**
  40134. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40135. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40136. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40137. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40138. */
  40139. export class VirtualJoysticksCamera extends FreeCamera {
  40140. /**
  40141. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40142. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40143. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40144. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40145. * @param name Define the name of the camera in the scene
  40146. * @param position Define the start position of the camera in the scene
  40147. * @param scene Define the scene the camera belongs to
  40148. */
  40149. constructor(name: string, position: Vector3, scene: Scene);
  40150. /**
  40151. * Gets the current object class name.
  40152. * @return the class name
  40153. */
  40154. getClassName(): string;
  40155. }
  40156. }
  40157. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40158. import { Matrix } from "babylonjs/Maths/math.vector";
  40159. /**
  40160. * This represents all the required metrics to create a VR camera.
  40161. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40162. */
  40163. export class VRCameraMetrics {
  40164. /**
  40165. * Define the horizontal resolution off the screen.
  40166. */
  40167. hResolution: number;
  40168. /**
  40169. * Define the vertical resolution off the screen.
  40170. */
  40171. vResolution: number;
  40172. /**
  40173. * Define the horizontal screen size.
  40174. */
  40175. hScreenSize: number;
  40176. /**
  40177. * Define the vertical screen size.
  40178. */
  40179. vScreenSize: number;
  40180. /**
  40181. * Define the vertical screen center position.
  40182. */
  40183. vScreenCenter: number;
  40184. /**
  40185. * Define the distance of the eyes to the screen.
  40186. */
  40187. eyeToScreenDistance: number;
  40188. /**
  40189. * Define the distance between both lenses
  40190. */
  40191. lensSeparationDistance: number;
  40192. /**
  40193. * Define the distance between both viewer's eyes.
  40194. */
  40195. interpupillaryDistance: number;
  40196. /**
  40197. * Define the distortion factor of the VR postprocess.
  40198. * Please, touch with care.
  40199. */
  40200. distortionK: number[];
  40201. /**
  40202. * Define the chromatic aberration correction factors for the VR post process.
  40203. */
  40204. chromaAbCorrection: number[];
  40205. /**
  40206. * Define the scale factor of the post process.
  40207. * The smaller the better but the slower.
  40208. */
  40209. postProcessScaleFactor: number;
  40210. /**
  40211. * Define an offset for the lens center.
  40212. */
  40213. lensCenterOffset: number;
  40214. /**
  40215. * Define if the current vr camera should compensate the distortion of the lense or not.
  40216. */
  40217. compensateDistortion: boolean;
  40218. /**
  40219. * Defines if multiview should be enabled when rendering (Default: false)
  40220. */
  40221. multiviewEnabled: boolean;
  40222. /**
  40223. * Gets the rendering aspect ratio based on the provided resolutions.
  40224. */
  40225. readonly aspectRatio: number;
  40226. /**
  40227. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40228. */
  40229. readonly aspectRatioFov: number;
  40230. /**
  40231. * @hidden
  40232. */
  40233. readonly leftHMatrix: Matrix;
  40234. /**
  40235. * @hidden
  40236. */
  40237. readonly rightHMatrix: Matrix;
  40238. /**
  40239. * @hidden
  40240. */
  40241. readonly leftPreViewMatrix: Matrix;
  40242. /**
  40243. * @hidden
  40244. */
  40245. readonly rightPreViewMatrix: Matrix;
  40246. /**
  40247. * Get the default VRMetrics based on the most generic setup.
  40248. * @returns the default vr metrics
  40249. */
  40250. static GetDefault(): VRCameraMetrics;
  40251. }
  40252. }
  40253. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40254. /** @hidden */
  40255. export var vrDistortionCorrectionPixelShader: {
  40256. name: string;
  40257. shader: string;
  40258. };
  40259. }
  40260. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40261. import { Camera } from "babylonjs/Cameras/camera";
  40262. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40263. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40264. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40265. /**
  40266. * VRDistortionCorrectionPostProcess used for mobile VR
  40267. */
  40268. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40269. private _isRightEye;
  40270. private _distortionFactors;
  40271. private _postProcessScaleFactor;
  40272. private _lensCenterOffset;
  40273. private _scaleIn;
  40274. private _scaleFactor;
  40275. private _lensCenter;
  40276. /**
  40277. * Initializes the VRDistortionCorrectionPostProcess
  40278. * @param name The name of the effect.
  40279. * @param camera The camera to apply the render pass to.
  40280. * @param isRightEye If this is for the right eye distortion
  40281. * @param vrMetrics All the required metrics for the VR camera
  40282. */
  40283. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40284. }
  40285. }
  40286. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40287. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40288. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40289. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40290. import { Scene } from "babylonjs/scene";
  40291. import { Vector3 } from "babylonjs/Maths/math.vector";
  40292. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40293. import "babylonjs/Cameras/RigModes/vrRigMode";
  40294. /**
  40295. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40296. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40297. */
  40298. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40299. /**
  40300. * Creates a new VRDeviceOrientationArcRotateCamera
  40301. * @param name defines camera name
  40302. * @param alpha defines the camera rotation along the logitudinal axis
  40303. * @param beta defines the camera rotation along the latitudinal axis
  40304. * @param radius defines the camera distance from its target
  40305. * @param target defines the camera target
  40306. * @param scene defines the scene the camera belongs to
  40307. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40308. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40309. */
  40310. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40311. /**
  40312. * Gets camera class name
  40313. * @returns VRDeviceOrientationArcRotateCamera
  40314. */
  40315. getClassName(): string;
  40316. }
  40317. }
  40318. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40319. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40320. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40321. import { Scene } from "babylonjs/scene";
  40322. import { Vector3 } from "babylonjs/Maths/math.vector";
  40323. import "babylonjs/Cameras/RigModes/vrRigMode";
  40324. /**
  40325. * Camera used to simulate VR rendering (based on FreeCamera)
  40326. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40327. */
  40328. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40329. /**
  40330. * Creates a new VRDeviceOrientationFreeCamera
  40331. * @param name defines camera name
  40332. * @param position defines the start position of the camera
  40333. * @param scene defines the scene the camera belongs to
  40334. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40335. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40336. */
  40337. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40338. /**
  40339. * Gets camera class name
  40340. * @returns VRDeviceOrientationFreeCamera
  40341. */
  40342. getClassName(): string;
  40343. }
  40344. }
  40345. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40346. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40347. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40348. import { Scene } from "babylonjs/scene";
  40349. import { Vector3 } from "babylonjs/Maths/math.vector";
  40350. import "babylonjs/Gamepads/gamepadSceneComponent";
  40351. /**
  40352. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40353. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40354. */
  40355. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40356. /**
  40357. * Creates a new VRDeviceOrientationGamepadCamera
  40358. * @param name defines camera name
  40359. * @param position defines the start position of the camera
  40360. * @param scene defines the scene the camera belongs to
  40361. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40362. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40363. */
  40364. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40365. /**
  40366. * Gets camera class name
  40367. * @returns VRDeviceOrientationGamepadCamera
  40368. */
  40369. getClassName(): string;
  40370. }
  40371. }
  40372. declare module "babylonjs/Materials/pushMaterial" {
  40373. import { Nullable } from "babylonjs/types";
  40374. import { Scene } from "babylonjs/scene";
  40375. import { Matrix } from "babylonjs/Maths/math.vector";
  40376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40377. import { Mesh } from "babylonjs/Meshes/mesh";
  40378. import { Material } from "babylonjs/Materials/material";
  40379. import { Effect } from "babylonjs/Materials/effect";
  40380. /**
  40381. * Base class of materials working in push mode in babylon JS
  40382. * @hidden
  40383. */
  40384. export class PushMaterial extends Material {
  40385. protected _activeEffect: Effect;
  40386. protected _normalMatrix: Matrix;
  40387. /**
  40388. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40389. * This means that the material can keep using a previous shader while a new one is being compiled.
  40390. * This is mostly used when shader parallel compilation is supported (true by default)
  40391. */
  40392. allowShaderHotSwapping: boolean;
  40393. constructor(name: string, scene: Scene);
  40394. getEffect(): Effect;
  40395. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40396. /**
  40397. * Binds the given world matrix to the active effect
  40398. *
  40399. * @param world the matrix to bind
  40400. */
  40401. bindOnlyWorldMatrix(world: Matrix): void;
  40402. /**
  40403. * Binds the given normal matrix to the active effect
  40404. *
  40405. * @param normalMatrix the matrix to bind
  40406. */
  40407. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40408. bind(world: Matrix, mesh?: Mesh): void;
  40409. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40410. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40411. }
  40412. }
  40413. declare module "babylonjs/Materials/materialFlags" {
  40414. /**
  40415. * This groups all the flags used to control the materials channel.
  40416. */
  40417. export class MaterialFlags {
  40418. private static _DiffuseTextureEnabled;
  40419. /**
  40420. * Are diffuse textures enabled in the application.
  40421. */
  40422. static DiffuseTextureEnabled: boolean;
  40423. private static _AmbientTextureEnabled;
  40424. /**
  40425. * Are ambient textures enabled in the application.
  40426. */
  40427. static AmbientTextureEnabled: boolean;
  40428. private static _OpacityTextureEnabled;
  40429. /**
  40430. * Are opacity textures enabled in the application.
  40431. */
  40432. static OpacityTextureEnabled: boolean;
  40433. private static _ReflectionTextureEnabled;
  40434. /**
  40435. * Are reflection textures enabled in the application.
  40436. */
  40437. static ReflectionTextureEnabled: boolean;
  40438. private static _EmissiveTextureEnabled;
  40439. /**
  40440. * Are emissive textures enabled in the application.
  40441. */
  40442. static EmissiveTextureEnabled: boolean;
  40443. private static _SpecularTextureEnabled;
  40444. /**
  40445. * Are specular textures enabled in the application.
  40446. */
  40447. static SpecularTextureEnabled: boolean;
  40448. private static _BumpTextureEnabled;
  40449. /**
  40450. * Are bump textures enabled in the application.
  40451. */
  40452. static BumpTextureEnabled: boolean;
  40453. private static _LightmapTextureEnabled;
  40454. /**
  40455. * Are lightmap textures enabled in the application.
  40456. */
  40457. static LightmapTextureEnabled: boolean;
  40458. private static _RefractionTextureEnabled;
  40459. /**
  40460. * Are refraction textures enabled in the application.
  40461. */
  40462. static RefractionTextureEnabled: boolean;
  40463. private static _ColorGradingTextureEnabled;
  40464. /**
  40465. * Are color grading textures enabled in the application.
  40466. */
  40467. static ColorGradingTextureEnabled: boolean;
  40468. private static _FresnelEnabled;
  40469. /**
  40470. * Are fresnels enabled in the application.
  40471. */
  40472. static FresnelEnabled: boolean;
  40473. private static _ClearCoatTextureEnabled;
  40474. /**
  40475. * Are clear coat textures enabled in the application.
  40476. */
  40477. static ClearCoatTextureEnabled: boolean;
  40478. private static _ClearCoatBumpTextureEnabled;
  40479. /**
  40480. * Are clear coat bump textures enabled in the application.
  40481. */
  40482. static ClearCoatBumpTextureEnabled: boolean;
  40483. private static _ClearCoatTintTextureEnabled;
  40484. /**
  40485. * Are clear coat tint textures enabled in the application.
  40486. */
  40487. static ClearCoatTintTextureEnabled: boolean;
  40488. private static _SheenTextureEnabled;
  40489. /**
  40490. * Are sheen textures enabled in the application.
  40491. */
  40492. static SheenTextureEnabled: boolean;
  40493. private static _AnisotropicTextureEnabled;
  40494. /**
  40495. * Are anisotropic textures enabled in the application.
  40496. */
  40497. static AnisotropicTextureEnabled: boolean;
  40498. private static _ThicknessTextureEnabled;
  40499. /**
  40500. * Are thickness textures enabled in the application.
  40501. */
  40502. static ThicknessTextureEnabled: boolean;
  40503. }
  40504. }
  40505. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40506. /** @hidden */
  40507. export var defaultFragmentDeclaration: {
  40508. name: string;
  40509. shader: string;
  40510. };
  40511. }
  40512. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40513. /** @hidden */
  40514. export var defaultUboDeclaration: {
  40515. name: string;
  40516. shader: string;
  40517. };
  40518. }
  40519. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40520. /** @hidden */
  40521. export var lightFragmentDeclaration: {
  40522. name: string;
  40523. shader: string;
  40524. };
  40525. }
  40526. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40527. /** @hidden */
  40528. export var lightUboDeclaration: {
  40529. name: string;
  40530. shader: string;
  40531. };
  40532. }
  40533. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40534. /** @hidden */
  40535. export var lightsFragmentFunctions: {
  40536. name: string;
  40537. shader: string;
  40538. };
  40539. }
  40540. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40541. /** @hidden */
  40542. export var shadowsFragmentFunctions: {
  40543. name: string;
  40544. shader: string;
  40545. };
  40546. }
  40547. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40548. /** @hidden */
  40549. export var fresnelFunction: {
  40550. name: string;
  40551. shader: string;
  40552. };
  40553. }
  40554. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40555. /** @hidden */
  40556. export var reflectionFunction: {
  40557. name: string;
  40558. shader: string;
  40559. };
  40560. }
  40561. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40562. /** @hidden */
  40563. export var bumpFragmentFunctions: {
  40564. name: string;
  40565. shader: string;
  40566. };
  40567. }
  40568. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40569. /** @hidden */
  40570. export var logDepthDeclaration: {
  40571. name: string;
  40572. shader: string;
  40573. };
  40574. }
  40575. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40576. /** @hidden */
  40577. export var bumpFragment: {
  40578. name: string;
  40579. shader: string;
  40580. };
  40581. }
  40582. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40583. /** @hidden */
  40584. export var depthPrePass: {
  40585. name: string;
  40586. shader: string;
  40587. };
  40588. }
  40589. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40590. /** @hidden */
  40591. export var lightFragment: {
  40592. name: string;
  40593. shader: string;
  40594. };
  40595. }
  40596. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40597. /** @hidden */
  40598. export var logDepthFragment: {
  40599. name: string;
  40600. shader: string;
  40601. };
  40602. }
  40603. declare module "babylonjs/Shaders/default.fragment" {
  40604. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40605. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40606. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40607. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40608. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40609. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40610. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40611. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40612. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40613. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40614. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40615. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40616. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40617. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40618. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40619. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40620. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40621. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40622. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40623. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40624. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40625. /** @hidden */
  40626. export var defaultPixelShader: {
  40627. name: string;
  40628. shader: string;
  40629. };
  40630. }
  40631. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40632. /** @hidden */
  40633. export var defaultVertexDeclaration: {
  40634. name: string;
  40635. shader: string;
  40636. };
  40637. }
  40638. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40639. /** @hidden */
  40640. export var bumpVertexDeclaration: {
  40641. name: string;
  40642. shader: string;
  40643. };
  40644. }
  40645. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40646. /** @hidden */
  40647. export var bumpVertex: {
  40648. name: string;
  40649. shader: string;
  40650. };
  40651. }
  40652. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40653. /** @hidden */
  40654. export var fogVertex: {
  40655. name: string;
  40656. shader: string;
  40657. };
  40658. }
  40659. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40660. /** @hidden */
  40661. export var shadowsVertex: {
  40662. name: string;
  40663. shader: string;
  40664. };
  40665. }
  40666. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40667. /** @hidden */
  40668. export var pointCloudVertex: {
  40669. name: string;
  40670. shader: string;
  40671. };
  40672. }
  40673. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40674. /** @hidden */
  40675. export var logDepthVertex: {
  40676. name: string;
  40677. shader: string;
  40678. };
  40679. }
  40680. declare module "babylonjs/Shaders/default.vertex" {
  40681. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40682. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40683. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40684. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40685. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40686. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40687. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40688. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40689. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40690. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40691. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40692. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40693. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40694. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40695. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40696. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40697. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40698. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40699. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40700. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40701. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40702. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40703. /** @hidden */
  40704. export var defaultVertexShader: {
  40705. name: string;
  40706. shader: string;
  40707. };
  40708. }
  40709. declare module "babylonjs/Materials/standardMaterial" {
  40710. import { SmartArray } from "babylonjs/Misc/smartArray";
  40711. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40712. import { Nullable } from "babylonjs/types";
  40713. import { Scene } from "babylonjs/scene";
  40714. import { Matrix } from "babylonjs/Maths/math.vector";
  40715. import { Color3 } from "babylonjs/Maths/math.color";
  40716. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40718. import { Mesh } from "babylonjs/Meshes/mesh";
  40719. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40720. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40721. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40722. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40723. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40725. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40726. import "babylonjs/Shaders/default.fragment";
  40727. import "babylonjs/Shaders/default.vertex";
  40728. /** @hidden */
  40729. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40730. MAINUV1: boolean;
  40731. MAINUV2: boolean;
  40732. DIFFUSE: boolean;
  40733. DIFFUSEDIRECTUV: number;
  40734. AMBIENT: boolean;
  40735. AMBIENTDIRECTUV: number;
  40736. OPACITY: boolean;
  40737. OPACITYDIRECTUV: number;
  40738. OPACITYRGB: boolean;
  40739. REFLECTION: boolean;
  40740. EMISSIVE: boolean;
  40741. EMISSIVEDIRECTUV: number;
  40742. SPECULAR: boolean;
  40743. SPECULARDIRECTUV: number;
  40744. BUMP: boolean;
  40745. BUMPDIRECTUV: number;
  40746. PARALLAX: boolean;
  40747. PARALLAXOCCLUSION: boolean;
  40748. SPECULAROVERALPHA: boolean;
  40749. CLIPPLANE: boolean;
  40750. CLIPPLANE2: boolean;
  40751. CLIPPLANE3: boolean;
  40752. CLIPPLANE4: boolean;
  40753. ALPHATEST: boolean;
  40754. DEPTHPREPASS: boolean;
  40755. ALPHAFROMDIFFUSE: boolean;
  40756. POINTSIZE: boolean;
  40757. FOG: boolean;
  40758. SPECULARTERM: boolean;
  40759. DIFFUSEFRESNEL: boolean;
  40760. OPACITYFRESNEL: boolean;
  40761. REFLECTIONFRESNEL: boolean;
  40762. REFRACTIONFRESNEL: boolean;
  40763. EMISSIVEFRESNEL: boolean;
  40764. FRESNEL: boolean;
  40765. NORMAL: boolean;
  40766. UV1: boolean;
  40767. UV2: boolean;
  40768. VERTEXCOLOR: boolean;
  40769. VERTEXALPHA: boolean;
  40770. NUM_BONE_INFLUENCERS: number;
  40771. BonesPerMesh: number;
  40772. BONETEXTURE: boolean;
  40773. INSTANCES: boolean;
  40774. GLOSSINESS: boolean;
  40775. ROUGHNESS: boolean;
  40776. EMISSIVEASILLUMINATION: boolean;
  40777. LINKEMISSIVEWITHDIFFUSE: boolean;
  40778. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40779. LIGHTMAP: boolean;
  40780. LIGHTMAPDIRECTUV: number;
  40781. OBJECTSPACE_NORMALMAP: boolean;
  40782. USELIGHTMAPASSHADOWMAP: boolean;
  40783. REFLECTIONMAP_3D: boolean;
  40784. REFLECTIONMAP_SPHERICAL: boolean;
  40785. REFLECTIONMAP_PLANAR: boolean;
  40786. REFLECTIONMAP_CUBIC: boolean;
  40787. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40788. REFLECTIONMAP_PROJECTION: boolean;
  40789. REFLECTIONMAP_SKYBOX: boolean;
  40790. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40791. REFLECTIONMAP_EXPLICIT: boolean;
  40792. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40793. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40794. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40795. INVERTCUBICMAP: boolean;
  40796. LOGARITHMICDEPTH: boolean;
  40797. REFRACTION: boolean;
  40798. REFRACTIONMAP_3D: boolean;
  40799. REFLECTIONOVERALPHA: boolean;
  40800. TWOSIDEDLIGHTING: boolean;
  40801. SHADOWFLOAT: boolean;
  40802. MORPHTARGETS: boolean;
  40803. MORPHTARGETS_NORMAL: boolean;
  40804. MORPHTARGETS_TANGENT: boolean;
  40805. MORPHTARGETS_UV: boolean;
  40806. NUM_MORPH_INFLUENCERS: number;
  40807. NONUNIFORMSCALING: boolean;
  40808. PREMULTIPLYALPHA: boolean;
  40809. IMAGEPROCESSING: boolean;
  40810. VIGNETTE: boolean;
  40811. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40812. VIGNETTEBLENDMODEOPAQUE: boolean;
  40813. TONEMAPPING: boolean;
  40814. TONEMAPPING_ACES: boolean;
  40815. CONTRAST: boolean;
  40816. COLORCURVES: boolean;
  40817. COLORGRADING: boolean;
  40818. COLORGRADING3D: boolean;
  40819. SAMPLER3DGREENDEPTH: boolean;
  40820. SAMPLER3DBGRMAP: boolean;
  40821. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40822. MULTIVIEW: boolean;
  40823. /**
  40824. * If the reflection texture on this material is in linear color space
  40825. * @hidden
  40826. */
  40827. IS_REFLECTION_LINEAR: boolean;
  40828. /**
  40829. * If the refraction texture on this material is in linear color space
  40830. * @hidden
  40831. */
  40832. IS_REFRACTION_LINEAR: boolean;
  40833. EXPOSURE: boolean;
  40834. constructor();
  40835. setReflectionMode(modeToEnable: string): void;
  40836. }
  40837. /**
  40838. * This is the default material used in Babylon. It is the best trade off between quality
  40839. * and performances.
  40840. * @see http://doc.babylonjs.com/babylon101/materials
  40841. */
  40842. export class StandardMaterial extends PushMaterial {
  40843. private _diffuseTexture;
  40844. /**
  40845. * The basic texture of the material as viewed under a light.
  40846. */
  40847. diffuseTexture: Nullable<BaseTexture>;
  40848. private _ambientTexture;
  40849. /**
  40850. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40851. */
  40852. ambientTexture: Nullable<BaseTexture>;
  40853. private _opacityTexture;
  40854. /**
  40855. * Define the transparency of the material from a texture.
  40856. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40857. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40858. */
  40859. opacityTexture: Nullable<BaseTexture>;
  40860. private _reflectionTexture;
  40861. /**
  40862. * Define the texture used to display the reflection.
  40863. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40864. */
  40865. reflectionTexture: Nullable<BaseTexture>;
  40866. private _emissiveTexture;
  40867. /**
  40868. * Define texture of the material as if self lit.
  40869. * This will be mixed in the final result even in the absence of light.
  40870. */
  40871. emissiveTexture: Nullable<BaseTexture>;
  40872. private _specularTexture;
  40873. /**
  40874. * Define how the color and intensity of the highlight given by the light in the material.
  40875. */
  40876. specularTexture: Nullable<BaseTexture>;
  40877. private _bumpTexture;
  40878. /**
  40879. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40880. * 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.
  40881. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40882. */
  40883. bumpTexture: Nullable<BaseTexture>;
  40884. private _lightmapTexture;
  40885. /**
  40886. * Complex lighting can be computationally expensive to compute at runtime.
  40887. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40888. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40889. */
  40890. lightmapTexture: Nullable<BaseTexture>;
  40891. private _refractionTexture;
  40892. /**
  40893. * Define the texture used to display the refraction.
  40894. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40895. */
  40896. refractionTexture: Nullable<BaseTexture>;
  40897. /**
  40898. * The color of the material lit by the environmental background lighting.
  40899. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40900. */
  40901. ambientColor: Color3;
  40902. /**
  40903. * The basic color of the material as viewed under a light.
  40904. */
  40905. diffuseColor: Color3;
  40906. /**
  40907. * Define how the color and intensity of the highlight given by the light in the material.
  40908. */
  40909. specularColor: Color3;
  40910. /**
  40911. * Define the color of the material as if self lit.
  40912. * This will be mixed in the final result even in the absence of light.
  40913. */
  40914. emissiveColor: Color3;
  40915. /**
  40916. * Defines how sharp are the highlights in the material.
  40917. * The bigger the value the sharper giving a more glossy feeling to the result.
  40918. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40919. */
  40920. specularPower: number;
  40921. private _useAlphaFromDiffuseTexture;
  40922. /**
  40923. * Does the transparency come from the diffuse texture alpha channel.
  40924. */
  40925. useAlphaFromDiffuseTexture: boolean;
  40926. private _useEmissiveAsIllumination;
  40927. /**
  40928. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40929. */
  40930. useEmissiveAsIllumination: boolean;
  40931. private _linkEmissiveWithDiffuse;
  40932. /**
  40933. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40934. * the emissive level when the final color is close to one.
  40935. */
  40936. linkEmissiveWithDiffuse: boolean;
  40937. private _useSpecularOverAlpha;
  40938. /**
  40939. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40940. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40941. */
  40942. useSpecularOverAlpha: boolean;
  40943. private _useReflectionOverAlpha;
  40944. /**
  40945. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40946. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40947. */
  40948. useReflectionOverAlpha: boolean;
  40949. private _disableLighting;
  40950. /**
  40951. * Does lights from the scene impacts this material.
  40952. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40953. */
  40954. disableLighting: boolean;
  40955. private _useObjectSpaceNormalMap;
  40956. /**
  40957. * Allows using an object space normal map (instead of tangent space).
  40958. */
  40959. useObjectSpaceNormalMap: boolean;
  40960. private _useParallax;
  40961. /**
  40962. * Is parallax enabled or not.
  40963. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40964. */
  40965. useParallax: boolean;
  40966. private _useParallaxOcclusion;
  40967. /**
  40968. * Is parallax occlusion enabled or not.
  40969. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40970. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40971. */
  40972. useParallaxOcclusion: boolean;
  40973. /**
  40974. * 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.
  40975. */
  40976. parallaxScaleBias: number;
  40977. private _roughness;
  40978. /**
  40979. * Helps to define how blurry the reflections should appears in the material.
  40980. */
  40981. roughness: number;
  40982. /**
  40983. * In case of refraction, define the value of the index of refraction.
  40984. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40985. */
  40986. indexOfRefraction: number;
  40987. /**
  40988. * Invert the refraction texture alongside the y axis.
  40989. * It can be useful with procedural textures or probe for instance.
  40990. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40991. */
  40992. invertRefractionY: boolean;
  40993. /**
  40994. * Defines the alpha limits in alpha test mode.
  40995. */
  40996. alphaCutOff: number;
  40997. private _useLightmapAsShadowmap;
  40998. /**
  40999. * In case of light mapping, define whether the map contains light or shadow informations.
  41000. */
  41001. useLightmapAsShadowmap: boolean;
  41002. private _diffuseFresnelParameters;
  41003. /**
  41004. * Define the diffuse fresnel parameters of the material.
  41005. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41006. */
  41007. diffuseFresnelParameters: FresnelParameters;
  41008. private _opacityFresnelParameters;
  41009. /**
  41010. * Define the opacity fresnel parameters of the material.
  41011. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41012. */
  41013. opacityFresnelParameters: FresnelParameters;
  41014. private _reflectionFresnelParameters;
  41015. /**
  41016. * Define the reflection fresnel parameters of the material.
  41017. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41018. */
  41019. reflectionFresnelParameters: FresnelParameters;
  41020. private _refractionFresnelParameters;
  41021. /**
  41022. * Define the refraction fresnel parameters of the material.
  41023. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41024. */
  41025. refractionFresnelParameters: FresnelParameters;
  41026. private _emissiveFresnelParameters;
  41027. /**
  41028. * Define the emissive fresnel parameters of the material.
  41029. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41030. */
  41031. emissiveFresnelParameters: FresnelParameters;
  41032. private _useReflectionFresnelFromSpecular;
  41033. /**
  41034. * If true automatically deducts the fresnels values from the material specularity.
  41035. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41036. */
  41037. useReflectionFresnelFromSpecular: boolean;
  41038. private _useGlossinessFromSpecularMapAlpha;
  41039. /**
  41040. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41041. */
  41042. useGlossinessFromSpecularMapAlpha: boolean;
  41043. private _maxSimultaneousLights;
  41044. /**
  41045. * Defines the maximum number of lights that can be used in the material
  41046. */
  41047. maxSimultaneousLights: number;
  41048. private _invertNormalMapX;
  41049. /**
  41050. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41051. */
  41052. invertNormalMapX: boolean;
  41053. private _invertNormalMapY;
  41054. /**
  41055. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41056. */
  41057. invertNormalMapY: boolean;
  41058. private _twoSidedLighting;
  41059. /**
  41060. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41061. */
  41062. twoSidedLighting: boolean;
  41063. /**
  41064. * Default configuration related to image processing available in the standard Material.
  41065. */
  41066. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41067. /**
  41068. * Gets the image processing configuration used either in this material.
  41069. */
  41070. /**
  41071. * Sets the Default image processing configuration used either in the this material.
  41072. *
  41073. * If sets to null, the scene one is in use.
  41074. */
  41075. imageProcessingConfiguration: ImageProcessingConfiguration;
  41076. /**
  41077. * Keep track of the image processing observer to allow dispose and replace.
  41078. */
  41079. private _imageProcessingObserver;
  41080. /**
  41081. * Attaches a new image processing configuration to the Standard Material.
  41082. * @param configuration
  41083. */
  41084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41085. /**
  41086. * Gets wether the color curves effect is enabled.
  41087. */
  41088. /**
  41089. * Sets wether the color curves effect is enabled.
  41090. */
  41091. cameraColorCurvesEnabled: boolean;
  41092. /**
  41093. * Gets wether the color grading effect is enabled.
  41094. */
  41095. /**
  41096. * Gets wether the color grading effect is enabled.
  41097. */
  41098. cameraColorGradingEnabled: boolean;
  41099. /**
  41100. * Gets wether tonemapping is enabled or not.
  41101. */
  41102. /**
  41103. * Sets wether tonemapping is enabled or not
  41104. */
  41105. cameraToneMappingEnabled: boolean;
  41106. /**
  41107. * The camera exposure used on this material.
  41108. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41109. * This corresponds to a photographic exposure.
  41110. */
  41111. /**
  41112. * The camera exposure used on this material.
  41113. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41114. * This corresponds to a photographic exposure.
  41115. */
  41116. cameraExposure: number;
  41117. /**
  41118. * Gets The camera contrast used on this material.
  41119. */
  41120. /**
  41121. * Sets The camera contrast used on this material.
  41122. */
  41123. cameraContrast: number;
  41124. /**
  41125. * Gets the Color Grading 2D Lookup Texture.
  41126. */
  41127. /**
  41128. * Sets the Color Grading 2D Lookup Texture.
  41129. */
  41130. cameraColorGradingTexture: Nullable<BaseTexture>;
  41131. /**
  41132. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41133. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41134. * 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;
  41135. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41136. */
  41137. /**
  41138. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41139. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41140. * 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;
  41141. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41142. */
  41143. cameraColorCurves: Nullable<ColorCurves>;
  41144. /**
  41145. * Custom callback helping to override the default shader used in the material.
  41146. */
  41147. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41148. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41149. protected _worldViewProjectionMatrix: Matrix;
  41150. protected _globalAmbientColor: Color3;
  41151. protected _useLogarithmicDepth: boolean;
  41152. /**
  41153. * Instantiates a new standard material.
  41154. * This is the default material used in Babylon. It is the best trade off between quality
  41155. * and performances.
  41156. * @see http://doc.babylonjs.com/babylon101/materials
  41157. * @param name Define the name of the material in the scene
  41158. * @param scene Define the scene the material belong to
  41159. */
  41160. constructor(name: string, scene: Scene);
  41161. /**
  41162. * Gets a boolean indicating that current material needs to register RTT
  41163. */
  41164. readonly hasRenderTargetTextures: boolean;
  41165. /**
  41166. * Gets the current class name of the material e.g. "StandardMaterial"
  41167. * Mainly use in serialization.
  41168. * @returns the class name
  41169. */
  41170. getClassName(): string;
  41171. /**
  41172. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41173. * You can try switching to logarithmic depth.
  41174. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41175. */
  41176. useLogarithmicDepth: boolean;
  41177. /**
  41178. * Specifies if the material will require alpha blending
  41179. * @returns a boolean specifying if alpha blending is needed
  41180. */
  41181. needAlphaBlending(): boolean;
  41182. /**
  41183. * Specifies if this material should be rendered in alpha test mode
  41184. * @returns a boolean specifying if an alpha test is needed.
  41185. */
  41186. needAlphaTesting(): boolean;
  41187. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41188. /**
  41189. * Get the texture used for alpha test purpose.
  41190. * @returns the diffuse texture in case of the standard material.
  41191. */
  41192. getAlphaTestTexture(): Nullable<BaseTexture>;
  41193. /**
  41194. * Get if the submesh is ready to be used and all its information available.
  41195. * Child classes can use it to update shaders
  41196. * @param mesh defines the mesh to check
  41197. * @param subMesh defines which submesh to check
  41198. * @param useInstances specifies that instances should be used
  41199. * @returns a boolean indicating that the submesh is ready or not
  41200. */
  41201. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41202. /**
  41203. * Builds the material UBO layouts.
  41204. * Used internally during the effect preparation.
  41205. */
  41206. buildUniformLayout(): void;
  41207. /**
  41208. * Unbinds the material from the mesh
  41209. */
  41210. unbind(): void;
  41211. /**
  41212. * Binds the submesh to this material by preparing the effect and shader to draw
  41213. * @param world defines the world transformation matrix
  41214. * @param mesh defines the mesh containing the submesh
  41215. * @param subMesh defines the submesh to bind the material to
  41216. */
  41217. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41218. /**
  41219. * Get the list of animatables in the material.
  41220. * @returns the list of animatables object used in the material
  41221. */
  41222. getAnimatables(): IAnimatable[];
  41223. /**
  41224. * Gets the active textures from the material
  41225. * @returns an array of textures
  41226. */
  41227. getActiveTextures(): BaseTexture[];
  41228. /**
  41229. * Specifies if the material uses a texture
  41230. * @param texture defines the texture to check against the material
  41231. * @returns a boolean specifying if the material uses the texture
  41232. */
  41233. hasTexture(texture: BaseTexture): boolean;
  41234. /**
  41235. * Disposes the material
  41236. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41237. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41238. */
  41239. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41240. /**
  41241. * Makes a duplicate of the material, and gives it a new name
  41242. * @param name defines the new name for the duplicated material
  41243. * @returns the cloned material
  41244. */
  41245. clone(name: string): StandardMaterial;
  41246. /**
  41247. * Serializes this material in a JSON representation
  41248. * @returns the serialized material object
  41249. */
  41250. serialize(): any;
  41251. /**
  41252. * Creates a standard material from parsed material data
  41253. * @param source defines the JSON representation of the material
  41254. * @param scene defines the hosting scene
  41255. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41256. * @returns a new standard material
  41257. */
  41258. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41259. /**
  41260. * Are diffuse textures enabled in the application.
  41261. */
  41262. static DiffuseTextureEnabled: boolean;
  41263. /**
  41264. * Are ambient textures enabled in the application.
  41265. */
  41266. static AmbientTextureEnabled: boolean;
  41267. /**
  41268. * Are opacity textures enabled in the application.
  41269. */
  41270. static OpacityTextureEnabled: boolean;
  41271. /**
  41272. * Are reflection textures enabled in the application.
  41273. */
  41274. static ReflectionTextureEnabled: boolean;
  41275. /**
  41276. * Are emissive textures enabled in the application.
  41277. */
  41278. static EmissiveTextureEnabled: boolean;
  41279. /**
  41280. * Are specular textures enabled in the application.
  41281. */
  41282. static SpecularTextureEnabled: boolean;
  41283. /**
  41284. * Are bump textures enabled in the application.
  41285. */
  41286. static BumpTextureEnabled: boolean;
  41287. /**
  41288. * Are lightmap textures enabled in the application.
  41289. */
  41290. static LightmapTextureEnabled: boolean;
  41291. /**
  41292. * Are refraction textures enabled in the application.
  41293. */
  41294. static RefractionTextureEnabled: boolean;
  41295. /**
  41296. * Are color grading textures enabled in the application.
  41297. */
  41298. static ColorGradingTextureEnabled: boolean;
  41299. /**
  41300. * Are fresnels enabled in the application.
  41301. */
  41302. static FresnelEnabled: boolean;
  41303. }
  41304. }
  41305. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41306. import { Scene } from "babylonjs/scene";
  41307. import { Texture } from "babylonjs/Materials/Textures/texture";
  41308. /**
  41309. * A class extending Texture allowing drawing on a texture
  41310. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41311. */
  41312. export class DynamicTexture extends Texture {
  41313. private _generateMipMaps;
  41314. private _canvas;
  41315. private _context;
  41316. private _engine;
  41317. /**
  41318. * Creates a DynamicTexture
  41319. * @param name defines the name of the texture
  41320. * @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
  41321. * @param scene defines the scene where you want the texture
  41322. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41323. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41324. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41325. */
  41326. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41327. /**
  41328. * Get the current class name of the texture useful for serialization or dynamic coding.
  41329. * @returns "DynamicTexture"
  41330. */
  41331. getClassName(): string;
  41332. /**
  41333. * Gets the current state of canRescale
  41334. */
  41335. readonly canRescale: boolean;
  41336. private _recreate;
  41337. /**
  41338. * Scales the texture
  41339. * @param ratio the scale factor to apply to both width and height
  41340. */
  41341. scale(ratio: number): void;
  41342. /**
  41343. * Resizes the texture
  41344. * @param width the new width
  41345. * @param height the new height
  41346. */
  41347. scaleTo(width: number, height: number): void;
  41348. /**
  41349. * Gets the context of the canvas used by the texture
  41350. * @returns the canvas context of the dynamic texture
  41351. */
  41352. getContext(): CanvasRenderingContext2D;
  41353. /**
  41354. * Clears the texture
  41355. */
  41356. clear(): void;
  41357. /**
  41358. * Updates the texture
  41359. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41360. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41361. */
  41362. update(invertY?: boolean, premulAlpha?: boolean): void;
  41363. /**
  41364. * Draws text onto the texture
  41365. * @param text defines the text to be drawn
  41366. * @param x defines the placement of the text from the left
  41367. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41368. * @param font defines the font to be used with font-style, font-size, font-name
  41369. * @param color defines the color used for the text
  41370. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41371. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41372. * @param update defines whether texture is immediately update (default is true)
  41373. */
  41374. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41375. /**
  41376. * Clones the texture
  41377. * @returns the clone of the texture.
  41378. */
  41379. clone(): DynamicTexture;
  41380. /**
  41381. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41382. * @returns a serialized dynamic texture object
  41383. */
  41384. serialize(): any;
  41385. /** @hidden */
  41386. _rebuild(): void;
  41387. }
  41388. }
  41389. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41390. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41391. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41392. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41393. /** @hidden */
  41394. export var imageProcessingPixelShader: {
  41395. name: string;
  41396. shader: string;
  41397. };
  41398. }
  41399. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41400. import { Nullable } from "babylonjs/types";
  41401. import { Color4 } from "babylonjs/Maths/math.color";
  41402. import { Camera } from "babylonjs/Cameras/camera";
  41403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41404. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41405. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41406. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41407. import { Engine } from "babylonjs/Engines/engine";
  41408. import "babylonjs/Shaders/imageProcessing.fragment";
  41409. import "babylonjs/Shaders/postprocess.vertex";
  41410. /**
  41411. * ImageProcessingPostProcess
  41412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41413. */
  41414. export class ImageProcessingPostProcess extends PostProcess {
  41415. /**
  41416. * Default configuration related to image processing available in the PBR Material.
  41417. */
  41418. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41419. /**
  41420. * Gets the image processing configuration used either in this material.
  41421. */
  41422. /**
  41423. * Sets the Default image processing configuration used either in the this material.
  41424. *
  41425. * If sets to null, the scene one is in use.
  41426. */
  41427. imageProcessingConfiguration: ImageProcessingConfiguration;
  41428. /**
  41429. * Keep track of the image processing observer to allow dispose and replace.
  41430. */
  41431. private _imageProcessingObserver;
  41432. /**
  41433. * Attaches a new image processing configuration to the PBR Material.
  41434. * @param configuration
  41435. */
  41436. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41437. /**
  41438. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41439. */
  41440. /**
  41441. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41442. */
  41443. colorCurves: Nullable<ColorCurves>;
  41444. /**
  41445. * Gets wether the color curves effect is enabled.
  41446. */
  41447. /**
  41448. * Sets wether the color curves effect is enabled.
  41449. */
  41450. colorCurvesEnabled: boolean;
  41451. /**
  41452. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41453. */
  41454. /**
  41455. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41456. */
  41457. colorGradingTexture: Nullable<BaseTexture>;
  41458. /**
  41459. * Gets wether the color grading effect is enabled.
  41460. */
  41461. /**
  41462. * Gets wether the color grading effect is enabled.
  41463. */
  41464. colorGradingEnabled: boolean;
  41465. /**
  41466. * Gets exposure used in the effect.
  41467. */
  41468. /**
  41469. * Sets exposure used in the effect.
  41470. */
  41471. exposure: number;
  41472. /**
  41473. * Gets wether tonemapping is enabled or not.
  41474. */
  41475. /**
  41476. * Sets wether tonemapping is enabled or not
  41477. */
  41478. toneMappingEnabled: boolean;
  41479. /**
  41480. * Gets the type of tone mapping effect.
  41481. */
  41482. /**
  41483. * Sets the type of tone mapping effect.
  41484. */
  41485. toneMappingType: number;
  41486. /**
  41487. * Gets contrast used in the effect.
  41488. */
  41489. /**
  41490. * Sets contrast used in the effect.
  41491. */
  41492. contrast: number;
  41493. /**
  41494. * Gets Vignette stretch size.
  41495. */
  41496. /**
  41497. * Sets Vignette stretch size.
  41498. */
  41499. vignetteStretch: number;
  41500. /**
  41501. * Gets Vignette centre X Offset.
  41502. */
  41503. /**
  41504. * Sets Vignette centre X Offset.
  41505. */
  41506. vignetteCentreX: number;
  41507. /**
  41508. * Gets Vignette centre Y Offset.
  41509. */
  41510. /**
  41511. * Sets Vignette centre Y Offset.
  41512. */
  41513. vignetteCentreY: number;
  41514. /**
  41515. * Gets Vignette weight or intensity of the vignette effect.
  41516. */
  41517. /**
  41518. * Sets Vignette weight or intensity of the vignette effect.
  41519. */
  41520. vignetteWeight: number;
  41521. /**
  41522. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41523. * if vignetteEnabled is set to true.
  41524. */
  41525. /**
  41526. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41527. * if vignetteEnabled is set to true.
  41528. */
  41529. vignetteColor: Color4;
  41530. /**
  41531. * Gets Camera field of view used by the Vignette effect.
  41532. */
  41533. /**
  41534. * Sets Camera field of view used by the Vignette effect.
  41535. */
  41536. vignetteCameraFov: number;
  41537. /**
  41538. * Gets the vignette blend mode allowing different kind of effect.
  41539. */
  41540. /**
  41541. * Sets the vignette blend mode allowing different kind of effect.
  41542. */
  41543. vignetteBlendMode: number;
  41544. /**
  41545. * Gets wether the vignette effect is enabled.
  41546. */
  41547. /**
  41548. * Sets wether the vignette effect is enabled.
  41549. */
  41550. vignetteEnabled: boolean;
  41551. private _fromLinearSpace;
  41552. /**
  41553. * Gets wether the input of the processing is in Gamma or Linear Space.
  41554. */
  41555. /**
  41556. * Sets wether the input of the processing is in Gamma or Linear Space.
  41557. */
  41558. fromLinearSpace: boolean;
  41559. /**
  41560. * Defines cache preventing GC.
  41561. */
  41562. private _defines;
  41563. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41564. /**
  41565. * "ImageProcessingPostProcess"
  41566. * @returns "ImageProcessingPostProcess"
  41567. */
  41568. getClassName(): string;
  41569. protected _updateParameters(): void;
  41570. dispose(camera?: Camera): void;
  41571. }
  41572. }
  41573. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41574. import { Scene } from "babylonjs/scene";
  41575. import { Color3 } from "babylonjs/Maths/math.color";
  41576. import { Mesh } from "babylonjs/Meshes/mesh";
  41577. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41578. import { Nullable } from "babylonjs/types";
  41579. /**
  41580. * Class containing static functions to help procedurally build meshes
  41581. */
  41582. export class GroundBuilder {
  41583. /**
  41584. * Creates a ground mesh
  41585. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41586. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41588. * @param name defines the name of the mesh
  41589. * @param options defines the options used to create the mesh
  41590. * @param scene defines the hosting scene
  41591. * @returns the ground mesh
  41592. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41593. */
  41594. static CreateGround(name: string, options: {
  41595. width?: number;
  41596. height?: number;
  41597. subdivisions?: number;
  41598. subdivisionsX?: number;
  41599. subdivisionsY?: number;
  41600. updatable?: boolean;
  41601. }, scene: any): Mesh;
  41602. /**
  41603. * Creates a tiled ground mesh
  41604. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41605. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41606. * * 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
  41607. * * 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
  41608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41609. * @param name defines the name of the mesh
  41610. * @param options defines the options used to create the mesh
  41611. * @param scene defines the hosting scene
  41612. * @returns the tiled ground mesh
  41613. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41614. */
  41615. static CreateTiledGround(name: string, options: {
  41616. xmin: number;
  41617. zmin: number;
  41618. xmax: number;
  41619. zmax: number;
  41620. subdivisions?: {
  41621. w: number;
  41622. h: number;
  41623. };
  41624. precision?: {
  41625. w: number;
  41626. h: number;
  41627. };
  41628. updatable?: boolean;
  41629. }, scene?: Nullable<Scene>): Mesh;
  41630. /**
  41631. * Creates a ground mesh from a height map
  41632. * * The parameter `url` sets the URL of the height map image resource.
  41633. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41634. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41635. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41636. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41637. * * 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.
  41638. * * 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).
  41639. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41641. * @param name defines the name of the mesh
  41642. * @param url defines the url to the height map
  41643. * @param options defines the options used to create the mesh
  41644. * @param scene defines the hosting scene
  41645. * @returns the ground mesh
  41646. * @see https://doc.babylonjs.com/babylon101/height_map
  41647. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41648. */
  41649. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41650. width?: number;
  41651. height?: number;
  41652. subdivisions?: number;
  41653. minHeight?: number;
  41654. maxHeight?: number;
  41655. colorFilter?: Color3;
  41656. alphaFilter?: number;
  41657. updatable?: boolean;
  41658. onReady?: (mesh: GroundMesh) => void;
  41659. }, scene?: Nullable<Scene>): GroundMesh;
  41660. }
  41661. }
  41662. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41663. import { Vector4 } from "babylonjs/Maths/math.vector";
  41664. import { Mesh } from "babylonjs/Meshes/mesh";
  41665. /**
  41666. * Class containing static functions to help procedurally build meshes
  41667. */
  41668. export class TorusBuilder {
  41669. /**
  41670. * Creates a torus mesh
  41671. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41672. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41673. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41677. * @param name defines the name of the mesh
  41678. * @param options defines the options used to create the mesh
  41679. * @param scene defines the hosting scene
  41680. * @returns the torus mesh
  41681. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41682. */
  41683. static CreateTorus(name: string, options: {
  41684. diameter?: number;
  41685. thickness?: number;
  41686. tessellation?: number;
  41687. updatable?: boolean;
  41688. sideOrientation?: number;
  41689. frontUVs?: Vector4;
  41690. backUVs?: Vector4;
  41691. }, scene: any): Mesh;
  41692. }
  41693. }
  41694. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41695. import { Vector4 } from "babylonjs/Maths/math.vector";
  41696. import { Color4 } from "babylonjs/Maths/math.color";
  41697. import { Mesh } from "babylonjs/Meshes/mesh";
  41698. /**
  41699. * Class containing static functions to help procedurally build meshes
  41700. */
  41701. export class CylinderBuilder {
  41702. /**
  41703. * Creates a cylinder or a cone mesh
  41704. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41705. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41706. * * 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.
  41707. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41708. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41709. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41710. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41711. * * 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).
  41712. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41713. * * 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).
  41714. * * 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
  41715. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41716. * * 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
  41717. * * 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.
  41718. * * If `enclose` is false, a ring surface is one element.
  41719. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41720. * * 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
  41721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41724. * @param name defines the name of the mesh
  41725. * @param options defines the options used to create the mesh
  41726. * @param scene defines the hosting scene
  41727. * @returns the cylinder mesh
  41728. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41729. */
  41730. static CreateCylinder(name: string, options: {
  41731. height?: number;
  41732. diameterTop?: number;
  41733. diameterBottom?: number;
  41734. diameter?: number;
  41735. tessellation?: number;
  41736. subdivisions?: number;
  41737. arc?: number;
  41738. faceColors?: Color4[];
  41739. faceUV?: Vector4[];
  41740. updatable?: boolean;
  41741. hasRings?: boolean;
  41742. enclose?: boolean;
  41743. cap?: number;
  41744. sideOrientation?: number;
  41745. frontUVs?: Vector4;
  41746. backUVs?: Vector4;
  41747. }, scene: any): Mesh;
  41748. }
  41749. }
  41750. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41751. import { Observable } from "babylonjs/Misc/observable";
  41752. import { Nullable } from "babylonjs/types";
  41753. import { Camera } from "babylonjs/Cameras/camera";
  41754. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41755. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41756. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41757. import { Scene } from "babylonjs/scene";
  41758. import { Vector3 } from "babylonjs/Maths/math.vector";
  41759. import { Color3 } from "babylonjs/Maths/math.color";
  41760. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41762. import { Mesh } from "babylonjs/Meshes/mesh";
  41763. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41764. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41765. import "babylonjs/Meshes/Builders/groundBuilder";
  41766. import "babylonjs/Meshes/Builders/torusBuilder";
  41767. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41768. import "babylonjs/Gamepads/gamepadSceneComponent";
  41769. import "babylonjs/Animations/animatable";
  41770. /**
  41771. * Options to modify the vr teleportation behavior.
  41772. */
  41773. export interface VRTeleportationOptions {
  41774. /**
  41775. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41776. */
  41777. floorMeshName?: string;
  41778. /**
  41779. * A list of meshes to be used as the teleportation floor. (default: empty)
  41780. */
  41781. floorMeshes?: Mesh[];
  41782. }
  41783. /**
  41784. * Options to modify the vr experience helper's behavior.
  41785. */
  41786. export interface VRExperienceHelperOptions extends WebVROptions {
  41787. /**
  41788. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41789. */
  41790. createDeviceOrientationCamera?: boolean;
  41791. /**
  41792. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41793. */
  41794. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41795. /**
  41796. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41797. */
  41798. laserToggle?: boolean;
  41799. /**
  41800. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41801. */
  41802. floorMeshes?: Mesh[];
  41803. /**
  41804. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41805. */
  41806. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41807. }
  41808. /**
  41809. * Event containing information after VR has been entered
  41810. */
  41811. export class OnAfterEnteringVRObservableEvent {
  41812. /**
  41813. * If entering vr was successful
  41814. */
  41815. success: boolean;
  41816. }
  41817. /**
  41818. * Helps to quickly add VR support to an existing scene.
  41819. * See http://doc.babylonjs.com/how_to/webvr_helper
  41820. */
  41821. export class VRExperienceHelper {
  41822. /** Options to modify the vr experience helper's behavior. */
  41823. webVROptions: VRExperienceHelperOptions;
  41824. private _scene;
  41825. private _position;
  41826. private _btnVR;
  41827. private _btnVRDisplayed;
  41828. private _webVRsupported;
  41829. private _webVRready;
  41830. private _webVRrequesting;
  41831. private _webVRpresenting;
  41832. private _hasEnteredVR;
  41833. private _fullscreenVRpresenting;
  41834. private _canvas;
  41835. private _webVRCamera;
  41836. private _vrDeviceOrientationCamera;
  41837. private _deviceOrientationCamera;
  41838. private _existingCamera;
  41839. private _onKeyDown;
  41840. private _onVrDisplayPresentChange;
  41841. private _onVRDisplayChanged;
  41842. private _onVRRequestPresentStart;
  41843. private _onVRRequestPresentComplete;
  41844. /**
  41845. * Observable raised right before entering VR.
  41846. */
  41847. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41848. /**
  41849. * Observable raised when entering VR has completed.
  41850. */
  41851. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41852. /**
  41853. * Observable raised when exiting VR.
  41854. */
  41855. onExitingVRObservable: Observable<VRExperienceHelper>;
  41856. /**
  41857. * Observable raised when controller mesh is loaded.
  41858. */
  41859. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41860. /** Return this.onEnteringVRObservable
  41861. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41862. */
  41863. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41864. /** Return this.onExitingVRObservable
  41865. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41866. */
  41867. readonly onExitingVR: Observable<VRExperienceHelper>;
  41868. /** Return this.onControllerMeshLoadedObservable
  41869. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41870. */
  41871. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41872. private _rayLength;
  41873. private _useCustomVRButton;
  41874. private _teleportationRequested;
  41875. private _teleportActive;
  41876. private _floorMeshName;
  41877. private _floorMeshesCollection;
  41878. private _rotationAllowed;
  41879. private _teleportBackwardsVector;
  41880. private _teleportationTarget;
  41881. private _isDefaultTeleportationTarget;
  41882. private _postProcessMove;
  41883. private _teleportationFillColor;
  41884. private _teleportationBorderColor;
  41885. private _rotationAngle;
  41886. private _haloCenter;
  41887. private _cameraGazer;
  41888. private _padSensibilityUp;
  41889. private _padSensibilityDown;
  41890. private _leftController;
  41891. private _rightController;
  41892. /**
  41893. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41894. */
  41895. onNewMeshSelected: Observable<AbstractMesh>;
  41896. /**
  41897. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41898. */
  41899. onNewMeshPicked: Observable<PickingInfo>;
  41900. private _circleEase;
  41901. /**
  41902. * Observable raised before camera teleportation
  41903. */
  41904. onBeforeCameraTeleport: Observable<Vector3>;
  41905. /**
  41906. * Observable raised after camera teleportation
  41907. */
  41908. onAfterCameraTeleport: Observable<Vector3>;
  41909. /**
  41910. * Observable raised when current selected mesh gets unselected
  41911. */
  41912. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41913. private _raySelectionPredicate;
  41914. /**
  41915. * To be optionaly changed by user to define custom ray selection
  41916. */
  41917. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41918. /**
  41919. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41920. */
  41921. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41922. /**
  41923. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41924. */
  41925. teleportationEnabled: boolean;
  41926. private _defaultHeight;
  41927. private _teleportationInitialized;
  41928. private _interactionsEnabled;
  41929. private _interactionsRequested;
  41930. private _displayGaze;
  41931. private _displayLaserPointer;
  41932. /**
  41933. * The mesh used to display where the user is going to teleport.
  41934. */
  41935. /**
  41936. * Sets the mesh to be used to display where the user is going to teleport.
  41937. */
  41938. teleportationTarget: Mesh;
  41939. /**
  41940. * 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
  41941. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41942. * See http://doc.babylonjs.com/resources/baking_transformations
  41943. */
  41944. gazeTrackerMesh: Mesh;
  41945. /**
  41946. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41947. */
  41948. updateGazeTrackerScale: boolean;
  41949. /**
  41950. * If the gaze trackers color should be updated when selecting meshes
  41951. */
  41952. updateGazeTrackerColor: boolean;
  41953. /**
  41954. * The gaze tracking mesh corresponding to the left controller
  41955. */
  41956. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41957. /**
  41958. * The gaze tracking mesh corresponding to the right controller
  41959. */
  41960. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41961. /**
  41962. * If the ray of the gaze should be displayed.
  41963. */
  41964. /**
  41965. * Sets if the ray of the gaze should be displayed.
  41966. */
  41967. displayGaze: boolean;
  41968. /**
  41969. * If the ray of the LaserPointer should be displayed.
  41970. */
  41971. /**
  41972. * Sets if the ray of the LaserPointer should be displayed.
  41973. */
  41974. displayLaserPointer: boolean;
  41975. /**
  41976. * The deviceOrientationCamera used as the camera when not in VR.
  41977. */
  41978. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41979. /**
  41980. * Based on the current WebVR support, returns the current VR camera used.
  41981. */
  41982. readonly currentVRCamera: Nullable<Camera>;
  41983. /**
  41984. * The webVRCamera which is used when in VR.
  41985. */
  41986. readonly webVRCamera: WebVRFreeCamera;
  41987. /**
  41988. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41989. */
  41990. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41991. private readonly _teleportationRequestInitiated;
  41992. /**
  41993. * Defines wether or not Pointer lock should be requested when switching to
  41994. * full screen.
  41995. */
  41996. requestPointerLockOnFullScreen: boolean;
  41997. /**
  41998. * Instantiates a VRExperienceHelper.
  41999. * Helps to quickly add VR support to an existing scene.
  42000. * @param scene The scene the VRExperienceHelper belongs to.
  42001. * @param webVROptions Options to modify the vr experience helper's behavior.
  42002. */
  42003. constructor(scene: Scene,
  42004. /** Options to modify the vr experience helper's behavior. */
  42005. webVROptions?: VRExperienceHelperOptions);
  42006. private _onDefaultMeshLoaded;
  42007. private _onResize;
  42008. private _onFullscreenChange;
  42009. /**
  42010. * Gets a value indicating if we are currently in VR mode.
  42011. */
  42012. readonly isInVRMode: boolean;
  42013. private onVrDisplayPresentChange;
  42014. private onVRDisplayChanged;
  42015. private moveButtonToBottomRight;
  42016. private displayVRButton;
  42017. private updateButtonVisibility;
  42018. private _cachedAngularSensibility;
  42019. /**
  42020. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42021. * Otherwise, will use the fullscreen API.
  42022. */
  42023. enterVR(): void;
  42024. /**
  42025. * Attempt to exit VR, or fullscreen.
  42026. */
  42027. exitVR(): void;
  42028. /**
  42029. * The position of the vr experience helper.
  42030. */
  42031. /**
  42032. * Sets the position of the vr experience helper.
  42033. */
  42034. position: Vector3;
  42035. /**
  42036. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42037. */
  42038. enableInteractions(): void;
  42039. private readonly _noControllerIsActive;
  42040. private beforeRender;
  42041. private _isTeleportationFloor;
  42042. /**
  42043. * Adds a floor mesh to be used for teleportation.
  42044. * @param floorMesh the mesh to be used for teleportation.
  42045. */
  42046. addFloorMesh(floorMesh: Mesh): void;
  42047. /**
  42048. * Removes a floor mesh from being used for teleportation.
  42049. * @param floorMesh the mesh to be removed.
  42050. */
  42051. removeFloorMesh(floorMesh: Mesh): void;
  42052. /**
  42053. * Enables interactions and teleportation using the VR controllers and gaze.
  42054. * @param vrTeleportationOptions options to modify teleportation behavior.
  42055. */
  42056. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42057. private _onNewGamepadConnected;
  42058. private _tryEnableInteractionOnController;
  42059. private _onNewGamepadDisconnected;
  42060. private _enableInteractionOnController;
  42061. private _checkTeleportWithRay;
  42062. private _checkRotate;
  42063. private _checkTeleportBackwards;
  42064. private _enableTeleportationOnController;
  42065. private _createTeleportationCircles;
  42066. private _displayTeleportationTarget;
  42067. private _hideTeleportationTarget;
  42068. private _rotateCamera;
  42069. private _moveTeleportationSelectorTo;
  42070. private _workingVector;
  42071. private _workingQuaternion;
  42072. private _workingMatrix;
  42073. /**
  42074. * Teleports the users feet to the desired location
  42075. * @param location The location where the user's feet should be placed
  42076. */
  42077. teleportCamera(location: Vector3): void;
  42078. private _convertNormalToDirectionOfRay;
  42079. private _castRayAndSelectObject;
  42080. private _notifySelectedMeshUnselected;
  42081. /**
  42082. * Sets the color of the laser ray from the vr controllers.
  42083. * @param color new color for the ray.
  42084. */
  42085. changeLaserColor(color: Color3): void;
  42086. /**
  42087. * Sets the color of the ray from the vr headsets gaze.
  42088. * @param color new color for the ray.
  42089. */
  42090. changeGazeColor(color: Color3): void;
  42091. /**
  42092. * Exits VR and disposes of the vr experience helper
  42093. */
  42094. dispose(): void;
  42095. /**
  42096. * Gets the name of the VRExperienceHelper class
  42097. * @returns "VRExperienceHelper"
  42098. */
  42099. getClassName(): string;
  42100. }
  42101. }
  42102. declare module "babylonjs/Cameras/VR/index" {
  42103. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42104. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42105. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42106. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42107. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42108. export * from "babylonjs/Cameras/VR/webVRCamera";
  42109. }
  42110. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42111. import { Observable } from "babylonjs/Misc/observable";
  42112. import { Nullable } from "babylonjs/types";
  42113. import { IDisposable, Scene } from "babylonjs/scene";
  42114. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42115. /**
  42116. * Manages an XRSession to work with Babylon's engine
  42117. * @see https://doc.babylonjs.com/how_to/webxr
  42118. */
  42119. export class WebXRSessionManager implements IDisposable {
  42120. private scene;
  42121. /**
  42122. * Fires every time a new xrFrame arrives which can be used to update the camera
  42123. */
  42124. onXRFrameObservable: Observable<any>;
  42125. /**
  42126. * Fires when the xr session is ended either by the device or manually done
  42127. */
  42128. onXRSessionEnded: Observable<any>;
  42129. /**
  42130. * Underlying xr session
  42131. */
  42132. session: XRSession;
  42133. /**
  42134. * Type of reference space used when creating the session
  42135. */
  42136. referenceSpace: XRReferenceSpace;
  42137. /** @hidden */
  42138. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42139. /**
  42140. * Current XR frame
  42141. */
  42142. currentFrame: Nullable<XRFrame>;
  42143. private _xrNavigator;
  42144. private baseLayer;
  42145. /**
  42146. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42147. * @param scene The scene which the session should be created for
  42148. */
  42149. constructor(scene: Scene);
  42150. /**
  42151. * Initializes the manager
  42152. * After initialization enterXR can be called to start an XR session
  42153. * @returns Promise which resolves after it is initialized
  42154. */
  42155. initializeAsync(): Promise<void>;
  42156. /**
  42157. * Initializes an xr session
  42158. * @param xrSessionMode mode to initialize
  42159. * @returns a promise which will resolve once the session has been initialized
  42160. */
  42161. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42162. /**
  42163. * Sets the reference space on the xr session
  42164. * @param referenceSpace space to set
  42165. * @returns a promise that will resolve once the reference space has been set
  42166. */
  42167. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42168. /**
  42169. * Updates the render state of the session
  42170. * @param state state to set
  42171. * @returns a promise that resolves once the render state has been updated
  42172. */
  42173. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42174. /**
  42175. * Starts rendering to the xr layer
  42176. * @returns a promise that will resolve once rendering has started
  42177. */
  42178. startRenderingToXRAsync(): Promise<void>;
  42179. /**
  42180. * Stops the xrSession and restores the renderloop
  42181. * @returns Promise which resolves after it exits XR
  42182. */
  42183. exitXRAsync(): Promise<unknown>;
  42184. /**
  42185. * Checks if a session would be supported for the creation options specified
  42186. * @param sessionMode session mode to check if supported eg. immersive-vr
  42187. * @returns true if supported
  42188. */
  42189. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42190. /**
  42191. * @hidden
  42192. * Converts the render layer of xrSession to a render target
  42193. * @param session session to create render target for
  42194. * @param scene scene the new render target should be created for
  42195. */
  42196. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42197. /**
  42198. * Disposes of the session manager
  42199. */
  42200. dispose(): void;
  42201. }
  42202. }
  42203. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42204. import { Scene } from "babylonjs/scene";
  42205. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42206. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42207. /**
  42208. * WebXR Camera which holds the views for the xrSession
  42209. * @see https://doc.babylonjs.com/how_to/webxr
  42210. */
  42211. export class WebXRCamera extends FreeCamera {
  42212. private static _TmpMatrix;
  42213. /**
  42214. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42215. * @param name the name of the camera
  42216. * @param scene the scene to add the camera to
  42217. */
  42218. constructor(name: string, scene: Scene);
  42219. private _updateNumberOfRigCameras;
  42220. /** @hidden */
  42221. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42222. /**
  42223. * Updates the cameras position from the current pose information of the XR session
  42224. * @param xrSessionManager the session containing pose information
  42225. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42226. */
  42227. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42228. }
  42229. }
  42230. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42231. import { Nullable } from "babylonjs/types";
  42232. import { IDisposable } from "babylonjs/scene";
  42233. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42234. /**
  42235. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42236. */
  42237. export class WebXRManagedOutputCanvas implements IDisposable {
  42238. private helper;
  42239. private _canvas;
  42240. /**
  42241. * xrpresent context of the canvas which can be used to display/mirror xr content
  42242. */
  42243. canvasContext: WebGLRenderingContext;
  42244. /**
  42245. * xr layer for the canvas
  42246. */
  42247. xrLayer: Nullable<XRWebGLLayer>;
  42248. /**
  42249. * Initializes the xr layer for the session
  42250. * @param xrSession xr session
  42251. * @returns a promise that will resolve once the XR Layer has been created
  42252. */
  42253. initializeXRLayerAsync(xrSession: any): any;
  42254. /**
  42255. * Initializes the canvas to be added/removed upon entering/exiting xr
  42256. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42257. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42258. */
  42259. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42260. /**
  42261. * Disposes of the object
  42262. */
  42263. dispose(): void;
  42264. private _setManagedOutputCanvas;
  42265. private _addCanvas;
  42266. private _removeCanvas;
  42267. }
  42268. }
  42269. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42270. import { Observable } from "babylonjs/Misc/observable";
  42271. import { IDisposable, Scene } from "babylonjs/scene";
  42272. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42274. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42275. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42276. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42277. /**
  42278. * States of the webXR experience
  42279. */
  42280. export enum WebXRState {
  42281. /**
  42282. * Transitioning to being in XR mode
  42283. */
  42284. ENTERING_XR = 0,
  42285. /**
  42286. * Transitioning to non XR mode
  42287. */
  42288. EXITING_XR = 1,
  42289. /**
  42290. * In XR mode and presenting
  42291. */
  42292. IN_XR = 2,
  42293. /**
  42294. * Not entered XR mode
  42295. */
  42296. NOT_IN_XR = 3
  42297. }
  42298. /**
  42299. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42300. * @see https://doc.babylonjs.com/how_to/webxr
  42301. */
  42302. export class WebXRExperienceHelper implements IDisposable {
  42303. private scene;
  42304. /**
  42305. * 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
  42306. */
  42307. container: AbstractMesh;
  42308. /**
  42309. * Camera used to render xr content
  42310. */
  42311. camera: WebXRCamera;
  42312. /**
  42313. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42314. */
  42315. state: WebXRState;
  42316. private _setState;
  42317. private static _TmpVector;
  42318. /**
  42319. * Fires when the state of the experience helper has changed
  42320. */
  42321. onStateChangedObservable: Observable<WebXRState>;
  42322. /** Session manager used to keep track of xr session */
  42323. sessionManager: WebXRSessionManager;
  42324. private _nonVRCamera;
  42325. private _originalSceneAutoClear;
  42326. private _supported;
  42327. /**
  42328. * Creates the experience helper
  42329. * @param scene the scene to attach the experience helper to
  42330. * @returns a promise for the experience helper
  42331. */
  42332. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42333. /**
  42334. * Creates a WebXRExperienceHelper
  42335. * @param scene The scene the helper should be created in
  42336. */
  42337. private constructor();
  42338. /**
  42339. * Exits XR mode and returns the scene to its original state
  42340. * @returns promise that resolves after xr mode has exited
  42341. */
  42342. exitXRAsync(): Promise<unknown>;
  42343. /**
  42344. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42345. * @param sessionCreationOptions options for the XR session
  42346. * @param referenceSpaceType frame of reference of the XR session
  42347. * @param outputCanvas the output canvas that will be used to enter XR mode
  42348. * @returns promise that resolves after xr mode has entered
  42349. */
  42350. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42351. /**
  42352. * Updates the global position of the camera by moving the camera's container
  42353. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42354. * @param position The desired global position of the camera
  42355. */
  42356. setPositionOfCameraUsingContainer(position: Vector3): void;
  42357. /**
  42358. * Rotates the xr camera by rotating the camera's container around the camera's position
  42359. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42360. * @param rotation the desired quaternion rotation to apply to the camera
  42361. */
  42362. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42363. /**
  42364. * Disposes of the experience helper
  42365. */
  42366. dispose(): void;
  42367. }
  42368. }
  42369. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42370. import { Nullable } from "babylonjs/types";
  42371. import { Observable } from "babylonjs/Misc/observable";
  42372. import { IDisposable, Scene } from "babylonjs/scene";
  42373. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42374. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42375. /**
  42376. * Button which can be used to enter a different mode of XR
  42377. */
  42378. export class WebXREnterExitUIButton {
  42379. /** button element */
  42380. element: HTMLElement;
  42381. /** XR initialization options for the button */
  42382. sessionMode: XRSessionMode;
  42383. /** Reference space type */
  42384. referenceSpaceType: XRReferenceSpaceType;
  42385. /**
  42386. * Creates a WebXREnterExitUIButton
  42387. * @param element button element
  42388. * @param sessionMode XR initialization session mode
  42389. * @param referenceSpaceType the type of reference space to be used
  42390. */
  42391. constructor(
  42392. /** button element */
  42393. element: HTMLElement,
  42394. /** XR initialization options for the button */
  42395. sessionMode: XRSessionMode,
  42396. /** Reference space type */
  42397. referenceSpaceType: XRReferenceSpaceType);
  42398. /**
  42399. * Overwritable function which can be used to update the button's visuals when the state changes
  42400. * @param activeButton the current active button in the UI
  42401. */
  42402. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42403. }
  42404. /**
  42405. * Options to create the webXR UI
  42406. */
  42407. export class WebXREnterExitUIOptions {
  42408. /**
  42409. * Context to enter xr with
  42410. */
  42411. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42412. /**
  42413. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42414. */
  42415. customButtons?: Array<WebXREnterExitUIButton>;
  42416. }
  42417. /**
  42418. * UI to allow the user to enter/exit XR mode
  42419. */
  42420. export class WebXREnterExitUI implements IDisposable {
  42421. private scene;
  42422. private _overlay;
  42423. private _buttons;
  42424. private _activeButton;
  42425. /**
  42426. * Fired every time the active button is changed.
  42427. *
  42428. * When xr is entered via a button that launches xr that button will be the callback parameter
  42429. *
  42430. * When exiting xr the callback parameter will be null)
  42431. */
  42432. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42433. /**
  42434. * Creates UI to allow the user to enter/exit XR mode
  42435. * @param scene the scene to add the ui to
  42436. * @param helper the xr experience helper to enter/exit xr with
  42437. * @param options options to configure the UI
  42438. * @returns the created ui
  42439. */
  42440. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42441. private constructor();
  42442. private _updateButtons;
  42443. /**
  42444. * Disposes of the object
  42445. */
  42446. dispose(): void;
  42447. }
  42448. }
  42449. declare module "babylonjs/Cameras/XR/webXRController" {
  42450. import { Nullable } from "babylonjs/types";
  42451. import { Observable } from "babylonjs/Misc/observable";
  42452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42453. import { Ray } from "babylonjs/Culling/ray";
  42454. import { Scene } from "babylonjs/scene";
  42455. /**
  42456. * Represents an XR input
  42457. */
  42458. export class WebXRController {
  42459. private scene;
  42460. /** The underlying input source for the controller */
  42461. inputSource: XRInputSource;
  42462. private parentContainer;
  42463. /**
  42464. * 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
  42465. */
  42466. grip?: AbstractMesh;
  42467. /**
  42468. * Pointer which can be used to select objects or attach a visible laser to
  42469. */
  42470. pointer: AbstractMesh;
  42471. /**
  42472. * Event that fires when the controller is removed/disposed
  42473. */
  42474. onDisposeObservable: Observable<{}>;
  42475. private _tmpMatrix;
  42476. private _tmpQuaternion;
  42477. private _tmpVector;
  42478. /**
  42479. * Creates the controller
  42480. * @see https://doc.babylonjs.com/how_to/webxr
  42481. * @param scene the scene which the controller should be associated to
  42482. * @param inputSource the underlying input source for the controller
  42483. * @param parentContainer parent that the controller meshes should be children of
  42484. */
  42485. constructor(scene: Scene,
  42486. /** The underlying input source for the controller */
  42487. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42488. /**
  42489. * Updates the controller pose based on the given XRFrame
  42490. * @param xrFrame xr frame to update the pose with
  42491. * @param referenceSpace reference space to use
  42492. */
  42493. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42494. /**
  42495. * Gets a world space ray coming from the controller
  42496. * @param result the resulting ray
  42497. */
  42498. getWorldPointerRayToRef(result: Ray): void;
  42499. /**
  42500. * Disposes of the object
  42501. */
  42502. dispose(): void;
  42503. }
  42504. }
  42505. declare module "babylonjs/Cameras/XR/webXRInput" {
  42506. import { Observable } from "babylonjs/Misc/observable";
  42507. import { IDisposable } from "babylonjs/scene";
  42508. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42509. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42510. /**
  42511. * XR input used to track XR inputs such as controllers/rays
  42512. */
  42513. export class WebXRInput implements IDisposable {
  42514. /**
  42515. * Base experience the input listens to
  42516. */
  42517. baseExperience: WebXRExperienceHelper;
  42518. /**
  42519. * XR controllers being tracked
  42520. */
  42521. controllers: Array<WebXRController>;
  42522. private _frameObserver;
  42523. private _stateObserver;
  42524. /**
  42525. * Event when a controller has been connected/added
  42526. */
  42527. onControllerAddedObservable: Observable<WebXRController>;
  42528. /**
  42529. * Event when a controller has been removed/disconnected
  42530. */
  42531. onControllerRemovedObservable: Observable<WebXRController>;
  42532. /**
  42533. * Initializes the WebXRInput
  42534. * @param baseExperience experience helper which the input should be created for
  42535. */
  42536. constructor(
  42537. /**
  42538. * Base experience the input listens to
  42539. */
  42540. baseExperience: WebXRExperienceHelper);
  42541. private _onInputSourcesChange;
  42542. private _addAndRemoveControllers;
  42543. /**
  42544. * Disposes of the object
  42545. */
  42546. dispose(): void;
  42547. }
  42548. }
  42549. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42551. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42552. /**
  42553. * Enables teleportation
  42554. */
  42555. export class WebXRControllerTeleportation {
  42556. private _teleportationFillColor;
  42557. private _teleportationBorderColor;
  42558. private _tmpRay;
  42559. private _tmpVector;
  42560. /**
  42561. * Creates a WebXRControllerTeleportation
  42562. * @param input input manager to add teleportation to
  42563. * @param floorMeshes floormeshes which can be teleported to
  42564. */
  42565. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42566. }
  42567. }
  42568. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42569. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42570. /**
  42571. * Handles pointer input automatically for the pointer of XR controllers
  42572. */
  42573. export class WebXRControllerPointerSelection {
  42574. private static _idCounter;
  42575. private _tmpRay;
  42576. /**
  42577. * Creates a WebXRControllerPointerSelection
  42578. * @param input input manager to setup pointer selection
  42579. */
  42580. constructor(input: WebXRInput);
  42581. private _convertNormalToDirectionOfRay;
  42582. private _updatePointerDistance;
  42583. }
  42584. }
  42585. declare module "babylonjs/Loading/sceneLoader" {
  42586. import { Observable } from "babylonjs/Misc/observable";
  42587. import { Nullable } from "babylonjs/types";
  42588. import { Scene } from "babylonjs/scene";
  42589. import { Engine } from "babylonjs/Engines/engine";
  42590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42591. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42592. import { AssetContainer } from "babylonjs/assetContainer";
  42593. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42594. import { Skeleton } from "babylonjs/Bones/skeleton";
  42595. /**
  42596. * Class used to represent data loading progression
  42597. */
  42598. export class SceneLoaderProgressEvent {
  42599. /** defines if data length to load can be evaluated */
  42600. readonly lengthComputable: boolean;
  42601. /** defines the loaded data length */
  42602. readonly loaded: number;
  42603. /** defines the data length to load */
  42604. readonly total: number;
  42605. /**
  42606. * Create a new progress event
  42607. * @param lengthComputable defines if data length to load can be evaluated
  42608. * @param loaded defines the loaded data length
  42609. * @param total defines the data length to load
  42610. */
  42611. constructor(
  42612. /** defines if data length to load can be evaluated */
  42613. lengthComputable: boolean,
  42614. /** defines the loaded data length */
  42615. loaded: number,
  42616. /** defines the data length to load */
  42617. total: number);
  42618. /**
  42619. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42620. * @param event defines the source event
  42621. * @returns a new SceneLoaderProgressEvent
  42622. */
  42623. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42624. }
  42625. /**
  42626. * Interface used by SceneLoader plugins to define supported file extensions
  42627. */
  42628. export interface ISceneLoaderPluginExtensions {
  42629. /**
  42630. * Defines the list of supported extensions
  42631. */
  42632. [extension: string]: {
  42633. isBinary: boolean;
  42634. };
  42635. }
  42636. /**
  42637. * Interface used by SceneLoader plugin factory
  42638. */
  42639. export interface ISceneLoaderPluginFactory {
  42640. /**
  42641. * Defines the name of the factory
  42642. */
  42643. name: string;
  42644. /**
  42645. * Function called to create a new plugin
  42646. * @return the new plugin
  42647. */
  42648. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42649. /**
  42650. * Boolean indicating if the plugin can direct load specific data
  42651. */
  42652. canDirectLoad?: (data: string) => boolean;
  42653. }
  42654. /**
  42655. * Interface used to define a SceneLoader plugin
  42656. */
  42657. export interface ISceneLoaderPlugin {
  42658. /**
  42659. * The friendly name of this plugin.
  42660. */
  42661. name: string;
  42662. /**
  42663. * The file extensions supported by this plugin.
  42664. */
  42665. extensions: string | ISceneLoaderPluginExtensions;
  42666. /**
  42667. * Import meshes into a scene.
  42668. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42669. * @param scene The scene to import into
  42670. * @param data The data to import
  42671. * @param rootUrl The root url for scene and resources
  42672. * @param meshes The meshes array to import into
  42673. * @param particleSystems The particle systems array to import into
  42674. * @param skeletons The skeletons array to import into
  42675. * @param onError The callback when import fails
  42676. * @returns True if successful or false otherwise
  42677. */
  42678. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42679. /**
  42680. * Load into a scene.
  42681. * @param scene The scene to load into
  42682. * @param data The data to import
  42683. * @param rootUrl The root url for scene and resources
  42684. * @param onError The callback when import fails
  42685. * @returns true if successful or false otherwise
  42686. */
  42687. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42688. /**
  42689. * The callback that returns true if the data can be directly loaded.
  42690. */
  42691. canDirectLoad?: (data: string) => boolean;
  42692. /**
  42693. * The callback that allows custom handling of the root url based on the response url.
  42694. */
  42695. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42696. /**
  42697. * Load into an asset container.
  42698. * @param scene The scene to load into
  42699. * @param data The data to import
  42700. * @param rootUrl The root url for scene and resources
  42701. * @param onError The callback when import fails
  42702. * @returns The loaded asset container
  42703. */
  42704. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42705. }
  42706. /**
  42707. * Interface used to define an async SceneLoader plugin
  42708. */
  42709. export interface ISceneLoaderPluginAsync {
  42710. /**
  42711. * The friendly name of this plugin.
  42712. */
  42713. name: string;
  42714. /**
  42715. * The file extensions supported by this plugin.
  42716. */
  42717. extensions: string | ISceneLoaderPluginExtensions;
  42718. /**
  42719. * Import meshes into a scene.
  42720. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42721. * @param scene The scene to import into
  42722. * @param data The data to import
  42723. * @param rootUrl The root url for scene and resources
  42724. * @param onProgress The callback when the load progresses
  42725. * @param fileName Defines the name of the file to load
  42726. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42727. */
  42728. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42729. meshes: AbstractMesh[];
  42730. particleSystems: IParticleSystem[];
  42731. skeletons: Skeleton[];
  42732. animationGroups: AnimationGroup[];
  42733. }>;
  42734. /**
  42735. * Load into a scene.
  42736. * @param scene The scene to load into
  42737. * @param data The data to import
  42738. * @param rootUrl The root url for scene and resources
  42739. * @param onProgress The callback when the load progresses
  42740. * @param fileName Defines the name of the file to load
  42741. * @returns Nothing
  42742. */
  42743. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42744. /**
  42745. * The callback that returns true if the data can be directly loaded.
  42746. */
  42747. canDirectLoad?: (data: string) => boolean;
  42748. /**
  42749. * The callback that allows custom handling of the root url based on the response url.
  42750. */
  42751. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42752. /**
  42753. * Load into an asset container.
  42754. * @param scene The scene to load into
  42755. * @param data The data to import
  42756. * @param rootUrl The root url for scene and resources
  42757. * @param onProgress The callback when the load progresses
  42758. * @param fileName Defines the name of the file to load
  42759. * @returns The loaded asset container
  42760. */
  42761. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42762. }
  42763. /**
  42764. * Class used to load scene from various file formats using registered plugins
  42765. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42766. */
  42767. export class SceneLoader {
  42768. /**
  42769. * No logging while loading
  42770. */
  42771. static readonly NO_LOGGING: number;
  42772. /**
  42773. * Minimal logging while loading
  42774. */
  42775. static readonly MINIMAL_LOGGING: number;
  42776. /**
  42777. * Summary logging while loading
  42778. */
  42779. static readonly SUMMARY_LOGGING: number;
  42780. /**
  42781. * Detailled logging while loading
  42782. */
  42783. static readonly DETAILED_LOGGING: number;
  42784. /**
  42785. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42786. */
  42787. static ForceFullSceneLoadingForIncremental: boolean;
  42788. /**
  42789. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42790. */
  42791. static ShowLoadingScreen: boolean;
  42792. /**
  42793. * Defines the current logging level (while loading the scene)
  42794. * @ignorenaming
  42795. */
  42796. static loggingLevel: number;
  42797. /**
  42798. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42799. */
  42800. static CleanBoneMatrixWeights: boolean;
  42801. /**
  42802. * Event raised when a plugin is used to load a scene
  42803. */
  42804. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42805. private static _registeredPlugins;
  42806. private static _getDefaultPlugin;
  42807. private static _getPluginForExtension;
  42808. private static _getPluginForDirectLoad;
  42809. private static _getPluginForFilename;
  42810. private static _getDirectLoad;
  42811. private static _loadData;
  42812. private static _getFileInfo;
  42813. /**
  42814. * Gets a plugin that can load the given extension
  42815. * @param extension defines the extension to load
  42816. * @returns a plugin or null if none works
  42817. */
  42818. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42819. /**
  42820. * Gets a boolean indicating that the given extension can be loaded
  42821. * @param extension defines the extension to load
  42822. * @returns true if the extension is supported
  42823. */
  42824. static IsPluginForExtensionAvailable(extension: string): boolean;
  42825. /**
  42826. * Adds a new plugin to the list of registered plugins
  42827. * @param plugin defines the plugin to add
  42828. */
  42829. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42830. /**
  42831. * Import meshes into a scene
  42832. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42833. * @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)
  42834. * @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)
  42835. * @param scene the instance of BABYLON.Scene to append to
  42836. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42837. * @param onProgress a callback with a progress event for each file being loaded
  42838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42839. * @param pluginExtension the extension used to determine the plugin
  42840. * @returns The loaded plugin
  42841. */
  42842. 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>;
  42843. /**
  42844. * Import meshes into a scene
  42845. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42846. * @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)
  42847. * @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)
  42848. * @param scene the instance of BABYLON.Scene to append to
  42849. * @param onProgress a callback with a progress event for each file being loaded
  42850. * @param pluginExtension the extension used to determine the plugin
  42851. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42852. */
  42853. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42854. meshes: AbstractMesh[];
  42855. particleSystems: IParticleSystem[];
  42856. skeletons: Skeleton[];
  42857. animationGroups: AnimationGroup[];
  42858. }>;
  42859. /**
  42860. * Load a scene
  42861. * @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)
  42862. * @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)
  42863. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42864. * @param onSuccess a callback with the scene when import succeeds
  42865. * @param onProgress a callback with a progress event for each file being loaded
  42866. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42867. * @param pluginExtension the extension used to determine the plugin
  42868. * @returns The loaded plugin
  42869. */
  42870. 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>;
  42871. /**
  42872. * Load a scene
  42873. * @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)
  42874. * @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)
  42875. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42876. * @param onProgress a callback with a progress event for each file being loaded
  42877. * @param pluginExtension the extension used to determine the plugin
  42878. * @returns The loaded scene
  42879. */
  42880. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42881. /**
  42882. * Append a scene
  42883. * @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)
  42884. * @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)
  42885. * @param scene is the instance of BABYLON.Scene to append to
  42886. * @param onSuccess a callback with the scene when import succeeds
  42887. * @param onProgress a callback with a progress event for each file being loaded
  42888. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42889. * @param pluginExtension the extension used to determine the plugin
  42890. * @returns The loaded plugin
  42891. */
  42892. 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>;
  42893. /**
  42894. * Append a scene
  42895. * @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)
  42896. * @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)
  42897. * @param scene is the instance of BABYLON.Scene to append to
  42898. * @param onProgress a callback with a progress event for each file being loaded
  42899. * @param pluginExtension the extension used to determine the plugin
  42900. * @returns The given scene
  42901. */
  42902. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42903. /**
  42904. * Load a scene into an asset container
  42905. * @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)
  42906. * @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)
  42907. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42908. * @param onSuccess a callback with the scene when import succeeds
  42909. * @param onProgress a callback with a progress event for each file being loaded
  42910. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42911. * @param pluginExtension the extension used to determine the plugin
  42912. * @returns The loaded plugin
  42913. */
  42914. 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>;
  42915. /**
  42916. * Load a scene into an asset container
  42917. * @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)
  42918. * @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)
  42919. * @param scene is the instance of Scene to append to
  42920. * @param onProgress a callback with a progress event for each file being loaded
  42921. * @param pluginExtension the extension used to determine the plugin
  42922. * @returns The loaded asset container
  42923. */
  42924. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42925. }
  42926. }
  42927. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42928. import { Scene } from "babylonjs/scene";
  42929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42930. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42931. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42932. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42933. /**
  42934. * Generic Controller
  42935. */
  42936. export class GenericController extends WebVRController {
  42937. /**
  42938. * Base Url for the controller model.
  42939. */
  42940. static readonly MODEL_BASE_URL: string;
  42941. /**
  42942. * File name for the controller model.
  42943. */
  42944. static readonly MODEL_FILENAME: string;
  42945. /**
  42946. * Creates a new GenericController from a gamepad
  42947. * @param vrGamepad the gamepad that the controller should be created from
  42948. */
  42949. constructor(vrGamepad: any);
  42950. /**
  42951. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42952. * @param scene scene in which to add meshes
  42953. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42954. */
  42955. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42956. /**
  42957. * Called once for each button that changed state since the last frame
  42958. * @param buttonIdx Which button index changed
  42959. * @param state New state of the button
  42960. * @param changes Which properties on the state changed since last frame
  42961. */
  42962. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42963. }
  42964. }
  42965. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42966. import { Observable } from "babylonjs/Misc/observable";
  42967. import { Scene } from "babylonjs/scene";
  42968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42969. import { Ray } from "babylonjs/Culling/ray";
  42970. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42971. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42972. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42973. /**
  42974. * Defines the WindowsMotionController object that the state of the windows motion controller
  42975. */
  42976. export class WindowsMotionController extends WebVRController {
  42977. /**
  42978. * The base url used to load the left and right controller models
  42979. */
  42980. static MODEL_BASE_URL: string;
  42981. /**
  42982. * The name of the left controller model file
  42983. */
  42984. static MODEL_LEFT_FILENAME: string;
  42985. /**
  42986. * The name of the right controller model file
  42987. */
  42988. static MODEL_RIGHT_FILENAME: string;
  42989. /**
  42990. * The controller name prefix for this controller type
  42991. */
  42992. static readonly GAMEPAD_ID_PREFIX: string;
  42993. /**
  42994. * The controller id pattern for this controller type
  42995. */
  42996. private static readonly GAMEPAD_ID_PATTERN;
  42997. private _loadedMeshInfo;
  42998. private readonly _mapping;
  42999. /**
  43000. * Fired when the trackpad on this controller is clicked
  43001. */
  43002. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43003. /**
  43004. * Fired when the trackpad on this controller is modified
  43005. */
  43006. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43007. /**
  43008. * The current x and y values of this controller's trackpad
  43009. */
  43010. trackpad: StickValues;
  43011. /**
  43012. * Creates a new WindowsMotionController from a gamepad
  43013. * @param vrGamepad the gamepad that the controller should be created from
  43014. */
  43015. constructor(vrGamepad: any);
  43016. /**
  43017. * Fired when the trigger on this controller is modified
  43018. */
  43019. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43020. /**
  43021. * Fired when the menu button on this controller is modified
  43022. */
  43023. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43024. /**
  43025. * Fired when the grip button on this controller is modified
  43026. */
  43027. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43028. /**
  43029. * Fired when the thumbstick button on this controller is modified
  43030. */
  43031. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43032. /**
  43033. * Fired when the touchpad button on this controller is modified
  43034. */
  43035. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43036. /**
  43037. * Fired when the touchpad values on this controller are modified
  43038. */
  43039. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43040. private _updateTrackpad;
  43041. /**
  43042. * Called once per frame by the engine.
  43043. */
  43044. update(): void;
  43045. /**
  43046. * Called once for each button that changed state since the last frame
  43047. * @param buttonIdx Which button index changed
  43048. * @param state New state of the button
  43049. * @param changes Which properties on the state changed since last frame
  43050. */
  43051. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43052. /**
  43053. * Moves the buttons on the controller mesh based on their current state
  43054. * @param buttonName the name of the button to move
  43055. * @param buttonValue the value of the button which determines the buttons new position
  43056. */
  43057. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43058. /**
  43059. * Moves the axis on the controller mesh based on its current state
  43060. * @param axis the index of the axis
  43061. * @param axisValue the value of the axis which determines the meshes new position
  43062. * @hidden
  43063. */
  43064. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43065. /**
  43066. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43067. * @param scene scene in which to add meshes
  43068. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43069. */
  43070. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43071. /**
  43072. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43073. * can be transformed by button presses and axes values, based on this._mapping.
  43074. *
  43075. * @param scene scene in which the meshes exist
  43076. * @param meshes list of meshes that make up the controller model to process
  43077. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43078. */
  43079. private processModel;
  43080. private createMeshInfo;
  43081. /**
  43082. * Gets the ray of the controller in the direction the controller is pointing
  43083. * @param length the length the resulting ray should be
  43084. * @returns a ray in the direction the controller is pointing
  43085. */
  43086. getForwardRay(length?: number): Ray;
  43087. /**
  43088. * Disposes of the controller
  43089. */
  43090. dispose(): void;
  43091. }
  43092. }
  43093. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43094. import { Observable } from "babylonjs/Misc/observable";
  43095. import { Scene } from "babylonjs/scene";
  43096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43097. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43098. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43099. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43100. /**
  43101. * Oculus Touch Controller
  43102. */
  43103. export class OculusTouchController extends WebVRController {
  43104. /**
  43105. * Base Url for the controller model.
  43106. */
  43107. static MODEL_BASE_URL: string;
  43108. /**
  43109. * File name for the left controller model.
  43110. */
  43111. static MODEL_LEFT_FILENAME: string;
  43112. /**
  43113. * File name for the right controller model.
  43114. */
  43115. static MODEL_RIGHT_FILENAME: string;
  43116. /**
  43117. * Base Url for the Quest controller model.
  43118. */
  43119. static QUEST_MODEL_BASE_URL: string;
  43120. /**
  43121. * @hidden
  43122. * If the controllers are running on a device that needs the updated Quest controller models
  43123. */
  43124. static _IsQuest: boolean;
  43125. /**
  43126. * Fired when the secondary trigger on this controller is modified
  43127. */
  43128. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43129. /**
  43130. * Fired when the thumb rest on this controller is modified
  43131. */
  43132. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43133. /**
  43134. * Creates a new OculusTouchController from a gamepad
  43135. * @param vrGamepad the gamepad that the controller should be created from
  43136. */
  43137. constructor(vrGamepad: any);
  43138. /**
  43139. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43140. * @param scene scene in which to add meshes
  43141. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43142. */
  43143. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43144. /**
  43145. * Fired when the A button on this controller is modified
  43146. */
  43147. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43148. /**
  43149. * Fired when the B button on this controller is modified
  43150. */
  43151. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43152. /**
  43153. * Fired when the X button on this controller is modified
  43154. */
  43155. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43156. /**
  43157. * Fired when the Y button on this controller is modified
  43158. */
  43159. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43160. /**
  43161. * Called once for each button that changed state since the last frame
  43162. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43163. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43164. * 2) secondary trigger (same)
  43165. * 3) A (right) X (left), touch, pressed = value
  43166. * 4) B / Y
  43167. * 5) thumb rest
  43168. * @param buttonIdx Which button index changed
  43169. * @param state New state of the button
  43170. * @param changes Which properties on the state changed since last frame
  43171. */
  43172. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43173. }
  43174. }
  43175. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43176. import { Scene } from "babylonjs/scene";
  43177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43178. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43179. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43180. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43181. import { Observable } from "babylonjs/Misc/observable";
  43182. /**
  43183. * Vive Controller
  43184. */
  43185. export class ViveController extends WebVRController {
  43186. /**
  43187. * Base Url for the controller model.
  43188. */
  43189. static MODEL_BASE_URL: string;
  43190. /**
  43191. * File name for the controller model.
  43192. */
  43193. static MODEL_FILENAME: string;
  43194. /**
  43195. * Creates a new ViveController from a gamepad
  43196. * @param vrGamepad the gamepad that the controller should be created from
  43197. */
  43198. constructor(vrGamepad: any);
  43199. /**
  43200. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43201. * @param scene scene in which to add meshes
  43202. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43203. */
  43204. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43205. /**
  43206. * Fired when the left button on this controller is modified
  43207. */
  43208. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43209. /**
  43210. * Fired when the right button on this controller is modified
  43211. */
  43212. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43213. /**
  43214. * Fired when the menu button on this controller is modified
  43215. */
  43216. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43217. /**
  43218. * Called once for each button that changed state since the last frame
  43219. * Vive mapping:
  43220. * 0: touchpad
  43221. * 1: trigger
  43222. * 2: left AND right buttons
  43223. * 3: menu button
  43224. * @param buttonIdx Which button index changed
  43225. * @param state New state of the button
  43226. * @param changes Which properties on the state changed since last frame
  43227. */
  43228. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43229. }
  43230. }
  43231. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43232. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43233. /**
  43234. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43235. */
  43236. export class WebXRControllerModelLoader {
  43237. /**
  43238. * Creates the WebXRControllerModelLoader
  43239. * @param input xr input that creates the controllers
  43240. */
  43241. constructor(input: WebXRInput);
  43242. }
  43243. }
  43244. declare module "babylonjs/Cameras/XR/index" {
  43245. export * from "babylonjs/Cameras/XR/webXRCamera";
  43246. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43247. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43248. export * from "babylonjs/Cameras/XR/webXRInput";
  43249. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43250. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43251. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43252. export * from "babylonjs/Cameras/XR/webXRController";
  43253. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43254. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43255. }
  43256. declare module "babylonjs/Cameras/RigModes/index" {
  43257. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43258. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43259. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43260. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43261. }
  43262. declare module "babylonjs/Cameras/index" {
  43263. export * from "babylonjs/Cameras/Inputs/index";
  43264. export * from "babylonjs/Cameras/cameraInputsManager";
  43265. export * from "babylonjs/Cameras/camera";
  43266. export * from "babylonjs/Cameras/targetCamera";
  43267. export * from "babylonjs/Cameras/freeCamera";
  43268. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43269. export * from "babylonjs/Cameras/touchCamera";
  43270. export * from "babylonjs/Cameras/arcRotateCamera";
  43271. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43272. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43273. export * from "babylonjs/Cameras/flyCamera";
  43274. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43275. export * from "babylonjs/Cameras/followCamera";
  43276. export * from "babylonjs/Cameras/gamepadCamera";
  43277. export * from "babylonjs/Cameras/Stereoscopic/index";
  43278. export * from "babylonjs/Cameras/universalCamera";
  43279. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43280. export * from "babylonjs/Cameras/VR/index";
  43281. export * from "babylonjs/Cameras/XR/index";
  43282. export * from "babylonjs/Cameras/RigModes/index";
  43283. }
  43284. declare module "babylonjs/Collisions/index" {
  43285. export * from "babylonjs/Collisions/collider";
  43286. export * from "babylonjs/Collisions/collisionCoordinator";
  43287. export * from "babylonjs/Collisions/pickingInfo";
  43288. export * from "babylonjs/Collisions/intersectionInfo";
  43289. export * from "babylonjs/Collisions/meshCollisionData";
  43290. }
  43291. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43292. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43293. import { Vector3 } from "babylonjs/Maths/math.vector";
  43294. import { Ray } from "babylonjs/Culling/ray";
  43295. import { Plane } from "babylonjs/Maths/math.plane";
  43296. /**
  43297. * Contains an array of blocks representing the octree
  43298. */
  43299. export interface IOctreeContainer<T> {
  43300. /**
  43301. * Blocks within the octree
  43302. */
  43303. blocks: Array<OctreeBlock<T>>;
  43304. }
  43305. /**
  43306. * Class used to store a cell in an octree
  43307. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43308. */
  43309. export class OctreeBlock<T> {
  43310. /**
  43311. * Gets the content of the current block
  43312. */
  43313. entries: T[];
  43314. /**
  43315. * Gets the list of block children
  43316. */
  43317. blocks: Array<OctreeBlock<T>>;
  43318. private _depth;
  43319. private _maxDepth;
  43320. private _capacity;
  43321. private _minPoint;
  43322. private _maxPoint;
  43323. private _boundingVectors;
  43324. private _creationFunc;
  43325. /**
  43326. * Creates a new block
  43327. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43328. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43329. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43330. * @param depth defines the current depth of this block in the octree
  43331. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43332. * @param creationFunc defines a callback to call when an element is added to the block
  43333. */
  43334. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43335. /**
  43336. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43337. */
  43338. readonly capacity: number;
  43339. /**
  43340. * Gets the minimum vector (in world space) of the block's bounding box
  43341. */
  43342. readonly minPoint: Vector3;
  43343. /**
  43344. * Gets the maximum vector (in world space) of the block's bounding box
  43345. */
  43346. readonly maxPoint: Vector3;
  43347. /**
  43348. * Add a new element to this block
  43349. * @param entry defines the element to add
  43350. */
  43351. addEntry(entry: T): void;
  43352. /**
  43353. * Remove an element from this block
  43354. * @param entry defines the element to remove
  43355. */
  43356. removeEntry(entry: T): void;
  43357. /**
  43358. * Add an array of elements to this block
  43359. * @param entries defines the array of elements to add
  43360. */
  43361. addEntries(entries: T[]): void;
  43362. /**
  43363. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43364. * @param frustumPlanes defines the frustum planes to test
  43365. * @param selection defines the array to store current content if selection is positive
  43366. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43367. */
  43368. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43369. /**
  43370. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43371. * @param sphereCenter defines the bounding sphere center
  43372. * @param sphereRadius defines the bounding sphere radius
  43373. * @param selection defines the array to store current content if selection is positive
  43374. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43375. */
  43376. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43377. /**
  43378. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43379. * @param ray defines the ray to test with
  43380. * @param selection defines the array to store current content if selection is positive
  43381. */
  43382. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43383. /**
  43384. * Subdivide the content into child blocks (this block will then be empty)
  43385. */
  43386. createInnerBlocks(): void;
  43387. /**
  43388. * @hidden
  43389. */
  43390. 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;
  43391. }
  43392. }
  43393. declare module "babylonjs/Culling/Octrees/octree" {
  43394. import { SmartArray } from "babylonjs/Misc/smartArray";
  43395. import { Vector3 } from "babylonjs/Maths/math.vector";
  43396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43398. import { Ray } from "babylonjs/Culling/ray";
  43399. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43400. import { Plane } from "babylonjs/Maths/math.plane";
  43401. /**
  43402. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43403. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43404. */
  43405. export class Octree<T> {
  43406. /** 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.) */
  43407. maxDepth: number;
  43408. /**
  43409. * Blocks within the octree containing objects
  43410. */
  43411. blocks: Array<OctreeBlock<T>>;
  43412. /**
  43413. * Content stored in the octree
  43414. */
  43415. dynamicContent: T[];
  43416. private _maxBlockCapacity;
  43417. private _selectionContent;
  43418. private _creationFunc;
  43419. /**
  43420. * Creates a octree
  43421. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43422. * @param creationFunc function to be used to instatiate the octree
  43423. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43424. * @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.)
  43425. */
  43426. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43427. /** 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.) */
  43428. maxDepth?: number);
  43429. /**
  43430. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43431. * @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);
  43432. * @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);
  43433. * @param entries meshes to be added to the octree blocks
  43434. */
  43435. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43436. /**
  43437. * Adds a mesh to the octree
  43438. * @param entry Mesh to add to the octree
  43439. */
  43440. addMesh(entry: T): void;
  43441. /**
  43442. * Remove an element from the octree
  43443. * @param entry defines the element to remove
  43444. */
  43445. removeMesh(entry: T): void;
  43446. /**
  43447. * Selects an array of meshes within the frustum
  43448. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43449. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43450. * @returns array of meshes within the frustum
  43451. */
  43452. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43453. /**
  43454. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43455. * @param sphereCenter defines the bounding sphere center
  43456. * @param sphereRadius defines the bounding sphere radius
  43457. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43458. * @returns an array of objects that intersect the sphere
  43459. */
  43460. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43461. /**
  43462. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43463. * @param ray defines the ray to test with
  43464. * @returns array of intersected objects
  43465. */
  43466. intersectsRay(ray: Ray): SmartArray<T>;
  43467. /**
  43468. * Adds a mesh into the octree block if it intersects the block
  43469. */
  43470. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43471. /**
  43472. * Adds a submesh into the octree block if it intersects the block
  43473. */
  43474. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43475. }
  43476. }
  43477. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43478. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43479. import { Scene } from "babylonjs/scene";
  43480. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43482. import { Ray } from "babylonjs/Culling/ray";
  43483. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43484. import { Collider } from "babylonjs/Collisions/collider";
  43485. module "babylonjs/scene" {
  43486. interface Scene {
  43487. /**
  43488. * @hidden
  43489. * Backing Filed
  43490. */
  43491. _selectionOctree: Octree<AbstractMesh>;
  43492. /**
  43493. * Gets the octree used to boost mesh selection (picking)
  43494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43495. */
  43496. selectionOctree: Octree<AbstractMesh>;
  43497. /**
  43498. * Creates or updates the octree used to boost selection (picking)
  43499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43500. * @param maxCapacity defines the maximum capacity per leaf
  43501. * @param maxDepth defines the maximum depth of the octree
  43502. * @returns an octree of AbstractMesh
  43503. */
  43504. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43505. }
  43506. }
  43507. module "babylonjs/Meshes/abstractMesh" {
  43508. interface AbstractMesh {
  43509. /**
  43510. * @hidden
  43511. * Backing Field
  43512. */
  43513. _submeshesOctree: Octree<SubMesh>;
  43514. /**
  43515. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43516. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43517. * @param maxCapacity defines the maximum size of each block (64 by default)
  43518. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43519. * @returns the new octree
  43520. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43522. */
  43523. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43524. }
  43525. }
  43526. /**
  43527. * Defines the octree scene component responsible to manage any octrees
  43528. * in a given scene.
  43529. */
  43530. export class OctreeSceneComponent {
  43531. /**
  43532. * The component name help to identify the component in the list of scene components.
  43533. */
  43534. readonly name: string;
  43535. /**
  43536. * The scene the component belongs to.
  43537. */
  43538. scene: Scene;
  43539. /**
  43540. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43541. */
  43542. readonly checksIsEnabled: boolean;
  43543. /**
  43544. * Creates a new instance of the component for the given scene
  43545. * @param scene Defines the scene to register the component in
  43546. */
  43547. constructor(scene: Scene);
  43548. /**
  43549. * Registers the component in a given scene
  43550. */
  43551. register(): void;
  43552. /**
  43553. * Return the list of active meshes
  43554. * @returns the list of active meshes
  43555. */
  43556. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43557. /**
  43558. * Return the list of active sub meshes
  43559. * @param mesh The mesh to get the candidates sub meshes from
  43560. * @returns the list of active sub meshes
  43561. */
  43562. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43563. private _tempRay;
  43564. /**
  43565. * Return the list of sub meshes intersecting with a given local ray
  43566. * @param mesh defines the mesh to find the submesh for
  43567. * @param localRay defines the ray in local space
  43568. * @returns the list of intersecting sub meshes
  43569. */
  43570. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43571. /**
  43572. * Return the list of sub meshes colliding with a collider
  43573. * @param mesh defines the mesh to find the submesh for
  43574. * @param collider defines the collider to evaluate the collision against
  43575. * @returns the list of colliding sub meshes
  43576. */
  43577. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43578. /**
  43579. * Rebuilds the elements related to this component in case of
  43580. * context lost for instance.
  43581. */
  43582. rebuild(): void;
  43583. /**
  43584. * Disposes the component and the associated ressources.
  43585. */
  43586. dispose(): void;
  43587. }
  43588. }
  43589. declare module "babylonjs/Culling/Octrees/index" {
  43590. export * from "babylonjs/Culling/Octrees/octree";
  43591. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43592. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43593. }
  43594. declare module "babylonjs/Culling/index" {
  43595. export * from "babylonjs/Culling/boundingBox";
  43596. export * from "babylonjs/Culling/boundingInfo";
  43597. export * from "babylonjs/Culling/boundingSphere";
  43598. export * from "babylonjs/Culling/Octrees/index";
  43599. export * from "babylonjs/Culling/ray";
  43600. }
  43601. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43602. import { IDisposable, Scene } from "babylonjs/scene";
  43603. import { Nullable } from "babylonjs/types";
  43604. import { Observable } from "babylonjs/Misc/observable";
  43605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43606. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43607. import { Camera } from "babylonjs/Cameras/camera";
  43608. /**
  43609. * Renders a layer on top of an existing scene
  43610. */
  43611. export class UtilityLayerRenderer implements IDisposable {
  43612. /** the original scene that will be rendered on top of */
  43613. originalScene: Scene;
  43614. private _pointerCaptures;
  43615. private _lastPointerEvents;
  43616. private static _DefaultUtilityLayer;
  43617. private static _DefaultKeepDepthUtilityLayer;
  43618. private _sharedGizmoLight;
  43619. private _renderCamera;
  43620. /**
  43621. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43622. * @returns the camera that is used when rendering the utility layer
  43623. */
  43624. getRenderCamera(): Nullable<Camera>;
  43625. /**
  43626. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43627. * @param cam the camera that should be used when rendering the utility layer
  43628. */
  43629. setRenderCamera(cam: Nullable<Camera>): void;
  43630. /**
  43631. * @hidden
  43632. * Light which used by gizmos to get light shading
  43633. */
  43634. _getSharedGizmoLight(): HemisphericLight;
  43635. /**
  43636. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43637. */
  43638. pickUtilitySceneFirst: boolean;
  43639. /**
  43640. * 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)
  43641. */
  43642. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43643. /**
  43644. * 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)
  43645. */
  43646. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43647. /**
  43648. * The scene that is rendered on top of the original scene
  43649. */
  43650. utilityLayerScene: Scene;
  43651. /**
  43652. * If the utility layer should automatically be rendered on top of existing scene
  43653. */
  43654. shouldRender: boolean;
  43655. /**
  43656. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43657. */
  43658. onlyCheckPointerDownEvents: boolean;
  43659. /**
  43660. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43661. */
  43662. processAllEvents: boolean;
  43663. /**
  43664. * Observable raised when the pointer move from the utility layer scene to the main scene
  43665. */
  43666. onPointerOutObservable: Observable<number>;
  43667. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43668. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43669. private _afterRenderObserver;
  43670. private _sceneDisposeObserver;
  43671. private _originalPointerObserver;
  43672. /**
  43673. * Instantiates a UtilityLayerRenderer
  43674. * @param originalScene the original scene that will be rendered on top of
  43675. * @param handleEvents boolean indicating if the utility layer should handle events
  43676. */
  43677. constructor(
  43678. /** the original scene that will be rendered on top of */
  43679. originalScene: Scene, handleEvents?: boolean);
  43680. private _notifyObservers;
  43681. /**
  43682. * Renders the utility layers scene on top of the original scene
  43683. */
  43684. render(): void;
  43685. /**
  43686. * Disposes of the renderer
  43687. */
  43688. dispose(): void;
  43689. private _updateCamera;
  43690. }
  43691. }
  43692. declare module "babylonjs/Gizmos/gizmo" {
  43693. import { Nullable } from "babylonjs/types";
  43694. import { IDisposable } from "babylonjs/scene";
  43695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43696. import { Mesh } from "babylonjs/Meshes/mesh";
  43697. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43698. /**
  43699. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43700. */
  43701. export class Gizmo implements IDisposable {
  43702. /** The utility layer the gizmo will be added to */
  43703. gizmoLayer: UtilityLayerRenderer;
  43704. /**
  43705. * The root mesh of the gizmo
  43706. */
  43707. _rootMesh: Mesh;
  43708. private _attachedMesh;
  43709. /**
  43710. * Ratio for the scale of the gizmo (Default: 1)
  43711. */
  43712. scaleRatio: number;
  43713. /**
  43714. * If a custom mesh has been set (Default: false)
  43715. */
  43716. protected _customMeshSet: boolean;
  43717. /**
  43718. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43719. * * When set, interactions will be enabled
  43720. */
  43721. attachedMesh: Nullable<AbstractMesh>;
  43722. /**
  43723. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43724. * @param mesh The mesh to replace the default mesh of the gizmo
  43725. */
  43726. setCustomMesh(mesh: Mesh): void;
  43727. /**
  43728. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43729. */
  43730. updateGizmoRotationToMatchAttachedMesh: boolean;
  43731. /**
  43732. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43733. */
  43734. updateGizmoPositionToMatchAttachedMesh: boolean;
  43735. /**
  43736. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43737. */
  43738. updateScale: boolean;
  43739. protected _interactionsEnabled: boolean;
  43740. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43741. private _beforeRenderObserver;
  43742. private _tempVector;
  43743. /**
  43744. * Creates a gizmo
  43745. * @param gizmoLayer The utility layer the gizmo will be added to
  43746. */
  43747. constructor(
  43748. /** The utility layer the gizmo will be added to */
  43749. gizmoLayer?: UtilityLayerRenderer);
  43750. /**
  43751. * Updates the gizmo to match the attached mesh's position/rotation
  43752. */
  43753. protected _update(): void;
  43754. /**
  43755. * Disposes of the gizmo
  43756. */
  43757. dispose(): void;
  43758. }
  43759. }
  43760. declare module "babylonjs/Gizmos/planeDragGizmo" {
  43761. import { Observable } from "babylonjs/Misc/observable";
  43762. import { Nullable } from "babylonjs/types";
  43763. import { Vector3 } from "babylonjs/Maths/math.vector";
  43764. import { Color3 } from "babylonjs/Maths/math.color";
  43765. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43767. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43768. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43769. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43770. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43771. import { Scene } from "babylonjs/scene";
  43772. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43773. /**
  43774. * Single plane drag gizmo
  43775. */
  43776. export class PlaneDragGizmo extends Gizmo {
  43777. /**
  43778. * Drag behavior responsible for the gizmos dragging interactions
  43779. */
  43780. dragBehavior: PointerDragBehavior;
  43781. private _pointerObserver;
  43782. /**
  43783. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43784. */
  43785. snapDistance: number;
  43786. /**
  43787. * Event that fires each time the gizmo snaps to a new location.
  43788. * * snapDistance is the the change in distance
  43789. */
  43790. onSnapObservable: Observable<{
  43791. snapDistance: number;
  43792. }>;
  43793. private _plane;
  43794. private _coloredMaterial;
  43795. private _hoverMaterial;
  43796. private _isEnabled;
  43797. private _parent;
  43798. /** @hidden */
  43799. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43800. /** @hidden */
  43801. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43802. /**
  43803. * Creates a PlaneDragGizmo
  43804. * @param gizmoLayer The utility layer the gizmo will be added to
  43805. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43806. * @param color The color of the gizmo
  43807. */
  43808. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43809. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43810. /**
  43811. * If the gizmo is enabled
  43812. */
  43813. isEnabled: boolean;
  43814. /**
  43815. * Disposes of the gizmo
  43816. */
  43817. dispose(): void;
  43818. }
  43819. }
  43820. declare module "babylonjs/Gizmos/positionGizmo" {
  43821. import { Observable } from "babylonjs/Misc/observable";
  43822. import { Nullable } from "babylonjs/types";
  43823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43824. import { Mesh } from "babylonjs/Meshes/mesh";
  43825. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43826. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43827. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  43828. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43829. /**
  43830. * Gizmo that enables dragging a mesh along 3 axis
  43831. */
  43832. export class PositionGizmo extends Gizmo {
  43833. /**
  43834. * Internal gizmo used for interactions on the x axis
  43835. */
  43836. xGizmo: AxisDragGizmo;
  43837. /**
  43838. * Internal gizmo used for interactions on the y axis
  43839. */
  43840. yGizmo: AxisDragGizmo;
  43841. /**
  43842. * Internal gizmo used for interactions on the z axis
  43843. */
  43844. zGizmo: AxisDragGizmo;
  43845. /**
  43846. * Internal gizmo used for interactions on the yz plane
  43847. */
  43848. xPlaneGizmo: PlaneDragGizmo;
  43849. /**
  43850. * Internal gizmo used for interactions on the xz plane
  43851. */
  43852. yPlaneGizmo: PlaneDragGizmo;
  43853. /**
  43854. * Internal gizmo used for interactions on the xy plane
  43855. */
  43856. zPlaneGizmo: PlaneDragGizmo;
  43857. /**
  43858. * private variables
  43859. */
  43860. private _meshAttached;
  43861. private _updateGizmoRotationToMatchAttachedMesh;
  43862. private _snapDistance;
  43863. private _scaleRatio;
  43864. /** Fires an event when any of it's sub gizmos are dragged */
  43865. onDragStartObservable: Observable<unknown>;
  43866. /** Fires an event when any of it's sub gizmos are released from dragging */
  43867. onDragEndObservable: Observable<unknown>;
  43868. /**
  43869. * If set to true, planar drag is enabled
  43870. */
  43871. private _planarGizmoEnabled;
  43872. attachedMesh: Nullable<AbstractMesh>;
  43873. /**
  43874. * Creates a PositionGizmo
  43875. * @param gizmoLayer The utility layer the gizmo will be added to
  43876. */
  43877. constructor(gizmoLayer?: UtilityLayerRenderer);
  43878. /**
  43879. * If the planar drag gizmo is enabled
  43880. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43881. */
  43882. planarGizmoEnabled: boolean;
  43883. updateGizmoRotationToMatchAttachedMesh: boolean;
  43884. /**
  43885. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43886. */
  43887. snapDistance: number;
  43888. /**
  43889. * Ratio for the scale of the gizmo (Default: 1)
  43890. */
  43891. scaleRatio: number;
  43892. /**
  43893. * Disposes of the gizmo
  43894. */
  43895. dispose(): void;
  43896. /**
  43897. * CustomMeshes are not supported by this gizmo
  43898. * @param mesh The mesh to replace the default mesh of the gizmo
  43899. */
  43900. setCustomMesh(mesh: Mesh): void;
  43901. }
  43902. }
  43903. declare module "babylonjs/Gizmos/axisDragGizmo" {
  43904. import { Observable } from "babylonjs/Misc/observable";
  43905. import { Nullable } from "babylonjs/types";
  43906. import { Vector3 } from "babylonjs/Maths/math.vector";
  43907. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43909. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43910. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43911. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43912. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43913. import { Scene } from "babylonjs/scene";
  43914. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43915. import { Color3 } from "babylonjs/Maths/math.color";
  43916. /**
  43917. * Single axis drag gizmo
  43918. */
  43919. export class AxisDragGizmo extends Gizmo {
  43920. /**
  43921. * Drag behavior responsible for the gizmos dragging interactions
  43922. */
  43923. dragBehavior: PointerDragBehavior;
  43924. private _pointerObserver;
  43925. /**
  43926. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43927. */
  43928. snapDistance: number;
  43929. /**
  43930. * Event that fires each time the gizmo snaps to a new location.
  43931. * * snapDistance is the the change in distance
  43932. */
  43933. onSnapObservable: Observable<{
  43934. snapDistance: number;
  43935. }>;
  43936. private _isEnabled;
  43937. private _parent;
  43938. private _arrow;
  43939. private _coloredMaterial;
  43940. private _hoverMaterial;
  43941. /** @hidden */
  43942. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43943. /** @hidden */
  43944. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43945. /**
  43946. * Creates an AxisDragGizmo
  43947. * @param gizmoLayer The utility layer the gizmo will be added to
  43948. * @param dragAxis The axis which the gizmo will be able to drag on
  43949. * @param color The color of the gizmo
  43950. */
  43951. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43952. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43953. /**
  43954. * If the gizmo is enabled
  43955. */
  43956. isEnabled: boolean;
  43957. /**
  43958. * Disposes of the gizmo
  43959. */
  43960. dispose(): void;
  43961. }
  43962. }
  43963. declare module "babylonjs/Debug/axesViewer" {
  43964. import { Vector3 } from "babylonjs/Maths/math.vector";
  43965. import { Nullable } from "babylonjs/types";
  43966. import { Scene } from "babylonjs/scene";
  43967. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43968. /**
  43969. * The Axes viewer will show 3 axes in a specific point in space
  43970. */
  43971. export class AxesViewer {
  43972. private _xAxis;
  43973. private _yAxis;
  43974. private _zAxis;
  43975. private _scaleLinesFactor;
  43976. private _instanced;
  43977. /**
  43978. * Gets the hosting scene
  43979. */
  43980. scene: Scene;
  43981. /**
  43982. * Gets or sets a number used to scale line length
  43983. */
  43984. scaleLines: number;
  43985. /** Gets the node hierarchy used to render x-axis */
  43986. readonly xAxis: TransformNode;
  43987. /** Gets the node hierarchy used to render y-axis */
  43988. readonly yAxis: TransformNode;
  43989. /** Gets the node hierarchy used to render z-axis */
  43990. readonly zAxis: TransformNode;
  43991. /**
  43992. * Creates a new AxesViewer
  43993. * @param scene defines the hosting scene
  43994. * @param scaleLines defines a number used to scale line length (1 by default)
  43995. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43996. * @param xAxis defines the node hierarchy used to render the x-axis
  43997. * @param yAxis defines the node hierarchy used to render the y-axis
  43998. * @param zAxis defines the node hierarchy used to render the z-axis
  43999. */
  44000. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44001. /**
  44002. * Force the viewer to update
  44003. * @param position defines the position of the viewer
  44004. * @param xaxis defines the x axis of the viewer
  44005. * @param yaxis defines the y axis of the viewer
  44006. * @param zaxis defines the z axis of the viewer
  44007. */
  44008. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44009. /**
  44010. * Creates an instance of this axes viewer.
  44011. * @returns a new axes viewer with instanced meshes
  44012. */
  44013. createInstance(): AxesViewer;
  44014. /** Releases resources */
  44015. dispose(): void;
  44016. private static _SetRenderingGroupId;
  44017. }
  44018. }
  44019. declare module "babylonjs/Debug/boneAxesViewer" {
  44020. import { Nullable } from "babylonjs/types";
  44021. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44022. import { Vector3 } from "babylonjs/Maths/math.vector";
  44023. import { Mesh } from "babylonjs/Meshes/mesh";
  44024. import { Bone } from "babylonjs/Bones/bone";
  44025. import { Scene } from "babylonjs/scene";
  44026. /**
  44027. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44028. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44029. */
  44030. export class BoneAxesViewer extends AxesViewer {
  44031. /**
  44032. * Gets or sets the target mesh where to display the axes viewer
  44033. */
  44034. mesh: Nullable<Mesh>;
  44035. /**
  44036. * Gets or sets the target bone where to display the axes viewer
  44037. */
  44038. bone: Nullable<Bone>;
  44039. /** Gets current position */
  44040. pos: Vector3;
  44041. /** Gets direction of X axis */
  44042. xaxis: Vector3;
  44043. /** Gets direction of Y axis */
  44044. yaxis: Vector3;
  44045. /** Gets direction of Z axis */
  44046. zaxis: Vector3;
  44047. /**
  44048. * Creates a new BoneAxesViewer
  44049. * @param scene defines the hosting scene
  44050. * @param bone defines the target bone
  44051. * @param mesh defines the target mesh
  44052. * @param scaleLines defines a scaling factor for line length (1 by default)
  44053. */
  44054. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44055. /**
  44056. * Force the viewer to update
  44057. */
  44058. update(): void;
  44059. /** Releases resources */
  44060. dispose(): void;
  44061. }
  44062. }
  44063. declare module "babylonjs/Debug/debugLayer" {
  44064. import { Scene } from "babylonjs/scene";
  44065. /**
  44066. * Interface used to define scene explorer extensibility option
  44067. */
  44068. export interface IExplorerExtensibilityOption {
  44069. /**
  44070. * Define the option label
  44071. */
  44072. label: string;
  44073. /**
  44074. * Defines the action to execute on click
  44075. */
  44076. action: (entity: any) => void;
  44077. }
  44078. /**
  44079. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44080. */
  44081. export interface IExplorerExtensibilityGroup {
  44082. /**
  44083. * Defines a predicate to test if a given type mut be extended
  44084. */
  44085. predicate: (entity: any) => boolean;
  44086. /**
  44087. * Gets the list of options added to a type
  44088. */
  44089. entries: IExplorerExtensibilityOption[];
  44090. }
  44091. /**
  44092. * Interface used to define the options to use to create the Inspector
  44093. */
  44094. export interface IInspectorOptions {
  44095. /**
  44096. * Display in overlay mode (default: false)
  44097. */
  44098. overlay?: boolean;
  44099. /**
  44100. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44101. */
  44102. globalRoot?: HTMLElement;
  44103. /**
  44104. * Display the Scene explorer
  44105. */
  44106. showExplorer?: boolean;
  44107. /**
  44108. * Display the property inspector
  44109. */
  44110. showInspector?: boolean;
  44111. /**
  44112. * Display in embed mode (both panes on the right)
  44113. */
  44114. embedMode?: boolean;
  44115. /**
  44116. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44117. */
  44118. handleResize?: boolean;
  44119. /**
  44120. * Allow the panes to popup (default: true)
  44121. */
  44122. enablePopup?: boolean;
  44123. /**
  44124. * Allow the panes to be closed by users (default: true)
  44125. */
  44126. enableClose?: boolean;
  44127. /**
  44128. * Optional list of extensibility entries
  44129. */
  44130. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44131. /**
  44132. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44133. */
  44134. inspectorURL?: string;
  44135. }
  44136. module "babylonjs/scene" {
  44137. interface Scene {
  44138. /**
  44139. * @hidden
  44140. * Backing field
  44141. */
  44142. _debugLayer: DebugLayer;
  44143. /**
  44144. * Gets the debug layer (aka Inspector) associated with the scene
  44145. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44146. */
  44147. debugLayer: DebugLayer;
  44148. }
  44149. }
  44150. /**
  44151. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44152. * what is happening in your scene
  44153. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44154. */
  44155. export class DebugLayer {
  44156. /**
  44157. * Define the url to get the inspector script from.
  44158. * By default it uses the babylonjs CDN.
  44159. * @ignoreNaming
  44160. */
  44161. static InspectorURL: string;
  44162. private _scene;
  44163. private BJSINSPECTOR;
  44164. private _onPropertyChangedObservable?;
  44165. /**
  44166. * Observable triggered when a property is changed through the inspector.
  44167. */
  44168. readonly onPropertyChangedObservable: any;
  44169. /**
  44170. * Instantiates a new debug layer.
  44171. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44172. * what is happening in your scene
  44173. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44174. * @param scene Defines the scene to inspect
  44175. */
  44176. constructor(scene: Scene);
  44177. /** Creates the inspector window. */
  44178. private _createInspector;
  44179. /**
  44180. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44181. * @param entity defines the entity to select
  44182. * @param lineContainerTitle defines the specific block to highlight
  44183. */
  44184. select(entity: any, lineContainerTitle?: string): void;
  44185. /** Get the inspector from bundle or global */
  44186. private _getGlobalInspector;
  44187. /**
  44188. * Get if the inspector is visible or not.
  44189. * @returns true if visible otherwise, false
  44190. */
  44191. isVisible(): boolean;
  44192. /**
  44193. * Hide the inspector and close its window.
  44194. */
  44195. hide(): void;
  44196. /**
  44197. * Launch the debugLayer.
  44198. * @param config Define the configuration of the inspector
  44199. * @return a promise fulfilled when the debug layer is visible
  44200. */
  44201. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44202. }
  44203. }
  44204. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44205. import { Nullable } from "babylonjs/types";
  44206. import { Scene } from "babylonjs/scene";
  44207. import { Vector4 } from "babylonjs/Maths/math.vector";
  44208. import { Color4 } from "babylonjs/Maths/math.color";
  44209. import { Mesh } from "babylonjs/Meshes/mesh";
  44210. /**
  44211. * Class containing static functions to help procedurally build meshes
  44212. */
  44213. export class BoxBuilder {
  44214. /**
  44215. * Creates a box mesh
  44216. * * The parameter `size` sets the size (float) of each box side (default 1)
  44217. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44218. * * 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)
  44219. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44223. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44224. * @param name defines the name of the mesh
  44225. * @param options defines the options used to create the mesh
  44226. * @param scene defines the hosting scene
  44227. * @returns the box mesh
  44228. */
  44229. static CreateBox(name: string, options: {
  44230. size?: number;
  44231. width?: number;
  44232. height?: number;
  44233. depth?: number;
  44234. faceUV?: Vector4[];
  44235. faceColors?: Color4[];
  44236. sideOrientation?: number;
  44237. frontUVs?: Vector4;
  44238. backUVs?: Vector4;
  44239. wrap?: boolean;
  44240. topBaseAt?: number;
  44241. bottomBaseAt?: number;
  44242. updatable?: boolean;
  44243. }, scene?: Nullable<Scene>): Mesh;
  44244. }
  44245. }
  44246. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44247. import { Vector4 } from "babylonjs/Maths/math.vector";
  44248. import { Mesh } from "babylonjs/Meshes/mesh";
  44249. /**
  44250. * Class containing static functions to help procedurally build meshes
  44251. */
  44252. export class SphereBuilder {
  44253. /**
  44254. * Creates a sphere mesh
  44255. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44256. * * 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`)
  44257. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44258. * * 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
  44259. * * 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)
  44260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44263. * @param name defines the name of the mesh
  44264. * @param options defines the options used to create the mesh
  44265. * @param scene defines the hosting scene
  44266. * @returns the sphere mesh
  44267. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44268. */
  44269. static CreateSphere(name: string, options: {
  44270. segments?: number;
  44271. diameter?: number;
  44272. diameterX?: number;
  44273. diameterY?: number;
  44274. diameterZ?: number;
  44275. arc?: number;
  44276. slice?: number;
  44277. sideOrientation?: number;
  44278. frontUVs?: Vector4;
  44279. backUVs?: Vector4;
  44280. updatable?: boolean;
  44281. }, scene: any): Mesh;
  44282. }
  44283. }
  44284. declare module "babylonjs/Debug/physicsViewer" {
  44285. import { Nullable } from "babylonjs/types";
  44286. import { Scene } from "babylonjs/scene";
  44287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44288. import { Mesh } from "babylonjs/Meshes/mesh";
  44289. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44290. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44291. /**
  44292. * Used to show the physics impostor around the specific mesh
  44293. */
  44294. export class PhysicsViewer {
  44295. /** @hidden */
  44296. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44297. /** @hidden */
  44298. protected _meshes: Array<Nullable<AbstractMesh>>;
  44299. /** @hidden */
  44300. protected _scene: Nullable<Scene>;
  44301. /** @hidden */
  44302. protected _numMeshes: number;
  44303. /** @hidden */
  44304. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44305. private _renderFunction;
  44306. private _utilityLayer;
  44307. private _debugBoxMesh;
  44308. private _debugSphereMesh;
  44309. private _debugCylinderMesh;
  44310. private _debugMaterial;
  44311. private _debugMeshMeshes;
  44312. /**
  44313. * Creates a new PhysicsViewer
  44314. * @param scene defines the hosting scene
  44315. */
  44316. constructor(scene: Scene);
  44317. /** @hidden */
  44318. protected _updateDebugMeshes(): void;
  44319. /**
  44320. * Renders a specified physic impostor
  44321. * @param impostor defines the impostor to render
  44322. * @param targetMesh defines the mesh represented by the impostor
  44323. * @returns the new debug mesh used to render the impostor
  44324. */
  44325. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44326. /**
  44327. * Hides a specified physic impostor
  44328. * @param impostor defines the impostor to hide
  44329. */
  44330. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44331. private _getDebugMaterial;
  44332. private _getDebugBoxMesh;
  44333. private _getDebugSphereMesh;
  44334. private _getDebugCylinderMesh;
  44335. private _getDebugMeshMesh;
  44336. private _getDebugMesh;
  44337. /** Releases all resources */
  44338. dispose(): void;
  44339. }
  44340. }
  44341. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44342. import { Vector3 } from "babylonjs/Maths/math.vector";
  44343. import { Color4 } from "babylonjs/Maths/math.color";
  44344. import { Nullable } from "babylonjs/types";
  44345. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44346. import { Scene } from "babylonjs/scene";
  44347. /**
  44348. * Class containing static functions to help procedurally build meshes
  44349. */
  44350. export class LinesBuilder {
  44351. /**
  44352. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44353. * * 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
  44354. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44355. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44356. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44357. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44358. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44359. * * 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
  44360. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44363. * @param name defines the name of the new line system
  44364. * @param options defines the options used to create the line system
  44365. * @param scene defines the hosting scene
  44366. * @returns a new line system mesh
  44367. */
  44368. static CreateLineSystem(name: string, options: {
  44369. lines: Vector3[][];
  44370. updatable?: boolean;
  44371. instance?: Nullable<LinesMesh>;
  44372. colors?: Nullable<Color4[][]>;
  44373. useVertexAlpha?: boolean;
  44374. }, scene: Nullable<Scene>): LinesMesh;
  44375. /**
  44376. * Creates a line mesh
  44377. * 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
  44378. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44379. * * The parameter `points` is an array successive Vector3
  44380. * * 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
  44381. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44382. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44383. * * When updating an instance, remember that only point positions can change, not the number of points
  44384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44386. * @param name defines the name of the new line system
  44387. * @param options defines the options used to create the line system
  44388. * @param scene defines the hosting scene
  44389. * @returns a new line mesh
  44390. */
  44391. static CreateLines(name: string, options: {
  44392. points: Vector3[];
  44393. updatable?: boolean;
  44394. instance?: Nullable<LinesMesh>;
  44395. colors?: Color4[];
  44396. useVertexAlpha?: boolean;
  44397. }, scene?: Nullable<Scene>): LinesMesh;
  44398. /**
  44399. * Creates a dashed line mesh
  44400. * * 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
  44401. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44402. * * The parameter `points` is an array successive Vector3
  44403. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44404. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44405. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44406. * * 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
  44407. * * When updating an instance, remember that only point positions can change, not the number of points
  44408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44409. * @param name defines the name of the mesh
  44410. * @param options defines the options used to create the mesh
  44411. * @param scene defines the hosting scene
  44412. * @returns the dashed line mesh
  44413. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44414. */
  44415. static CreateDashedLines(name: string, options: {
  44416. points: Vector3[];
  44417. dashSize?: number;
  44418. gapSize?: number;
  44419. dashNb?: number;
  44420. updatable?: boolean;
  44421. instance?: LinesMesh;
  44422. }, scene?: Nullable<Scene>): LinesMesh;
  44423. }
  44424. }
  44425. declare module "babylonjs/Debug/rayHelper" {
  44426. import { Nullable } from "babylonjs/types";
  44427. import { Ray } from "babylonjs/Culling/ray";
  44428. import { Vector3 } from "babylonjs/Maths/math.vector";
  44429. import { Color3 } from "babylonjs/Maths/math.color";
  44430. import { Scene } from "babylonjs/scene";
  44431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44432. import "babylonjs/Meshes/Builders/linesBuilder";
  44433. /**
  44434. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44435. * in order to better appreciate the issue one might have.
  44436. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44437. */
  44438. export class RayHelper {
  44439. /**
  44440. * Defines the ray we are currently tryin to visualize.
  44441. */
  44442. ray: Nullable<Ray>;
  44443. private _renderPoints;
  44444. private _renderLine;
  44445. private _renderFunction;
  44446. private _scene;
  44447. private _updateToMeshFunction;
  44448. private _attachedToMesh;
  44449. private _meshSpaceDirection;
  44450. private _meshSpaceOrigin;
  44451. /**
  44452. * Helper function to create a colored helper in a scene in one line.
  44453. * @param ray Defines the ray we are currently tryin to visualize
  44454. * @param scene Defines the scene the ray is used in
  44455. * @param color Defines the color we want to see the ray in
  44456. * @returns The newly created ray helper.
  44457. */
  44458. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44459. /**
  44460. * Instantiate a new ray helper.
  44461. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44462. * in order to better appreciate the issue one might have.
  44463. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44464. * @param ray Defines the ray we are currently tryin to visualize
  44465. */
  44466. constructor(ray: Ray);
  44467. /**
  44468. * Shows the ray we are willing to debug.
  44469. * @param scene Defines the scene the ray needs to be rendered in
  44470. * @param color Defines the color the ray needs to be rendered in
  44471. */
  44472. show(scene: Scene, color?: Color3): void;
  44473. /**
  44474. * Hides the ray we are debugging.
  44475. */
  44476. hide(): void;
  44477. private _render;
  44478. /**
  44479. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44480. * @param mesh Defines the mesh we want the helper attached to
  44481. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44482. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44483. * @param length Defines the length of the ray
  44484. */
  44485. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44486. /**
  44487. * Detach the ray helper from the mesh it has previously been attached to.
  44488. */
  44489. detachFromMesh(): void;
  44490. private _updateToMesh;
  44491. /**
  44492. * Dispose the helper and release its associated resources.
  44493. */
  44494. dispose(): void;
  44495. }
  44496. }
  44497. declare module "babylonjs/Debug/skeletonViewer" {
  44498. import { Color3 } from "babylonjs/Maths/math.color";
  44499. import { Scene } from "babylonjs/scene";
  44500. import { Nullable } from "babylonjs/types";
  44501. import { Skeleton } from "babylonjs/Bones/skeleton";
  44502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44503. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44504. /**
  44505. * Class used to render a debug view of a given skeleton
  44506. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44507. */
  44508. export class SkeletonViewer {
  44509. /** defines the skeleton to render */
  44510. skeleton: Skeleton;
  44511. /** defines the mesh attached to the skeleton */
  44512. mesh: AbstractMesh;
  44513. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44514. autoUpdateBonesMatrices: boolean;
  44515. /** defines the rendering group id to use with the viewer */
  44516. renderingGroupId: number;
  44517. /** Gets or sets the color used to render the skeleton */
  44518. color: Color3;
  44519. private _scene;
  44520. private _debugLines;
  44521. private _debugMesh;
  44522. private _isEnabled;
  44523. private _renderFunction;
  44524. private _utilityLayer;
  44525. /**
  44526. * Returns the mesh used to render the bones
  44527. */
  44528. readonly debugMesh: Nullable<LinesMesh>;
  44529. /**
  44530. * Creates a new SkeletonViewer
  44531. * @param skeleton defines the skeleton to render
  44532. * @param mesh defines the mesh attached to the skeleton
  44533. * @param scene defines the hosting scene
  44534. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44535. * @param renderingGroupId defines the rendering group id to use with the viewer
  44536. */
  44537. constructor(
  44538. /** defines the skeleton to render */
  44539. skeleton: Skeleton,
  44540. /** defines the mesh attached to the skeleton */
  44541. mesh: AbstractMesh, scene: Scene,
  44542. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44543. autoUpdateBonesMatrices?: boolean,
  44544. /** defines the rendering group id to use with the viewer */
  44545. renderingGroupId?: number);
  44546. /** Gets or sets a boolean indicating if the viewer is enabled */
  44547. isEnabled: boolean;
  44548. private _getBonePosition;
  44549. private _getLinesForBonesWithLength;
  44550. private _getLinesForBonesNoLength;
  44551. /** Update the viewer to sync with current skeleton state */
  44552. update(): void;
  44553. /** Release associated resources */
  44554. dispose(): void;
  44555. }
  44556. }
  44557. declare module "babylonjs/Debug/index" {
  44558. export * from "babylonjs/Debug/axesViewer";
  44559. export * from "babylonjs/Debug/boneAxesViewer";
  44560. export * from "babylonjs/Debug/debugLayer";
  44561. export * from "babylonjs/Debug/physicsViewer";
  44562. export * from "babylonjs/Debug/rayHelper";
  44563. export * from "babylonjs/Debug/skeletonViewer";
  44564. }
  44565. declare module "babylonjs/Engines/nullEngine" {
  44566. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44567. import { Scene } from "babylonjs/scene";
  44568. import { Engine } from "babylonjs/Engines/engine";
  44569. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44570. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44571. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44572. import { Effect } from "babylonjs/Materials/effect";
  44573. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44574. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44575. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44576. /**
  44577. * Options to create the null engine
  44578. */
  44579. export class NullEngineOptions {
  44580. /**
  44581. * Render width (Default: 512)
  44582. */
  44583. renderWidth: number;
  44584. /**
  44585. * Render height (Default: 256)
  44586. */
  44587. renderHeight: number;
  44588. /**
  44589. * Texture size (Default: 512)
  44590. */
  44591. textureSize: number;
  44592. /**
  44593. * If delta time between frames should be constant
  44594. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44595. */
  44596. deterministicLockstep: boolean;
  44597. /**
  44598. * Maximum about of steps between frames (Default: 4)
  44599. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44600. */
  44601. lockstepMaxSteps: number;
  44602. }
  44603. /**
  44604. * The null engine class provides support for headless version of babylon.js.
  44605. * This can be used in server side scenario or for testing purposes
  44606. */
  44607. export class NullEngine extends Engine {
  44608. private _options;
  44609. /**
  44610. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44611. */
  44612. isDeterministicLockStep(): boolean;
  44613. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44614. getLockstepMaxSteps(): number;
  44615. /**
  44616. * Sets hardware scaling, used to save performance if needed
  44617. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44618. */
  44619. getHardwareScalingLevel(): number;
  44620. constructor(options?: NullEngineOptions);
  44621. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44622. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44623. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44624. getRenderWidth(useScreen?: boolean): number;
  44625. getRenderHeight(useScreen?: boolean): number;
  44626. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44627. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44628. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44629. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44630. bindSamplers(effect: Effect): void;
  44631. enableEffect(effect: Effect): void;
  44632. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44633. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44634. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44635. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44636. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44637. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44638. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44639. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44640. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44641. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44642. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44643. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44644. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44645. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44646. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44647. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44648. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44649. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44650. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44651. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44652. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44653. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44654. bindBuffers(vertexBuffers: {
  44655. [key: string]: VertexBuffer;
  44656. }, indexBuffer: DataBuffer, effect: Effect): void;
  44657. wipeCaches(bruteForce?: boolean): void;
  44658. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44659. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44660. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44661. /** @hidden */
  44662. _createTexture(): WebGLTexture;
  44663. /** @hidden */
  44664. _releaseTexture(texture: InternalTexture): void;
  44665. 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;
  44666. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44667. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44668. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44669. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44670. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44671. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44672. areAllEffectsReady(): boolean;
  44673. /**
  44674. * @hidden
  44675. * Get the current error code of the webGL context
  44676. * @returns the error code
  44677. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44678. */
  44679. getError(): number;
  44680. /** @hidden */
  44681. _getUnpackAlignement(): number;
  44682. /** @hidden */
  44683. _unpackFlipY(value: boolean): void;
  44684. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44685. /**
  44686. * Updates a dynamic vertex buffer.
  44687. * @param vertexBuffer the vertex buffer to update
  44688. * @param data the data used to update the vertex buffer
  44689. * @param byteOffset the byte offset of the data (optional)
  44690. * @param byteLength the byte length of the data (optional)
  44691. */
  44692. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44693. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44694. /** @hidden */
  44695. _bindTexture(channel: number, texture: InternalTexture): void;
  44696. /** @hidden */
  44697. _releaseBuffer(buffer: DataBuffer): boolean;
  44698. releaseEffects(): void;
  44699. displayLoadingUI(): void;
  44700. hideLoadingUI(): void;
  44701. /** @hidden */
  44702. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44703. /** @hidden */
  44704. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44705. /** @hidden */
  44706. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44707. /** @hidden */
  44708. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44709. }
  44710. }
  44711. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  44712. import { Nullable, int } from "babylonjs/types";
  44713. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  44714. /** @hidden */
  44715. export class _OcclusionDataStorage {
  44716. /** @hidden */
  44717. occlusionInternalRetryCounter: number;
  44718. /** @hidden */
  44719. isOcclusionQueryInProgress: boolean;
  44720. /** @hidden */
  44721. isOccluded: boolean;
  44722. /** @hidden */
  44723. occlusionRetryCount: number;
  44724. /** @hidden */
  44725. occlusionType: number;
  44726. /** @hidden */
  44727. occlusionQueryAlgorithmType: number;
  44728. }
  44729. module "babylonjs/Engines/engine" {
  44730. interface Engine {
  44731. /**
  44732. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44733. * @return the new query
  44734. */
  44735. createQuery(): WebGLQuery;
  44736. /**
  44737. * Delete and release a webGL query
  44738. * @param query defines the query to delete
  44739. * @return the current engine
  44740. */
  44741. deleteQuery(query: WebGLQuery): Engine;
  44742. /**
  44743. * Check if a given query has resolved and got its value
  44744. * @param query defines the query to check
  44745. * @returns true if the query got its value
  44746. */
  44747. isQueryResultAvailable(query: WebGLQuery): boolean;
  44748. /**
  44749. * Gets the value of a given query
  44750. * @param query defines the query to check
  44751. * @returns the value of the query
  44752. */
  44753. getQueryResult(query: WebGLQuery): number;
  44754. /**
  44755. * Initiates an occlusion query
  44756. * @param algorithmType defines the algorithm to use
  44757. * @param query defines the query to use
  44758. * @returns the current engine
  44759. * @see http://doc.babylonjs.com/features/occlusionquery
  44760. */
  44761. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44762. /**
  44763. * Ends an occlusion query
  44764. * @see http://doc.babylonjs.com/features/occlusionquery
  44765. * @param algorithmType defines the algorithm to use
  44766. * @returns the current engine
  44767. */
  44768. endOcclusionQuery(algorithmType: number): Engine;
  44769. /**
  44770. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44771. * Please note that only one query can be issued at a time
  44772. * @returns a time token used to track the time span
  44773. */
  44774. startTimeQuery(): Nullable<_TimeToken>;
  44775. /**
  44776. * Ends a time query
  44777. * @param token defines the token used to measure the time span
  44778. * @returns the time spent (in ns)
  44779. */
  44780. endTimeQuery(token: _TimeToken): int;
  44781. /** @hidden */
  44782. _currentNonTimestampToken: Nullable<_TimeToken>;
  44783. /** @hidden */
  44784. _createTimeQuery(): WebGLQuery;
  44785. /** @hidden */
  44786. _deleteTimeQuery(query: WebGLQuery): void;
  44787. /** @hidden */
  44788. _getGlAlgorithmType(algorithmType: number): number;
  44789. /** @hidden */
  44790. _getTimeQueryResult(query: WebGLQuery): any;
  44791. /** @hidden */
  44792. _getTimeQueryAvailability(query: WebGLQuery): any;
  44793. }
  44794. }
  44795. module "babylonjs/Meshes/abstractMesh" {
  44796. interface AbstractMesh {
  44797. /**
  44798. * Backing filed
  44799. * @hidden
  44800. */
  44801. __occlusionDataStorage: _OcclusionDataStorage;
  44802. /**
  44803. * Access property
  44804. * @hidden
  44805. */
  44806. _occlusionDataStorage: _OcclusionDataStorage;
  44807. /**
  44808. * 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.
  44809. * The default value is -1 which means don't break the query and wait till the result
  44810. * @see http://doc.babylonjs.com/features/occlusionquery
  44811. */
  44812. occlusionRetryCount: number;
  44813. /**
  44814. * 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:
  44815. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44816. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44817. * * 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.
  44818. * @see http://doc.babylonjs.com/features/occlusionquery
  44819. */
  44820. occlusionType: number;
  44821. /**
  44822. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44823. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44824. * * 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.
  44825. * @see http://doc.babylonjs.com/features/occlusionquery
  44826. */
  44827. occlusionQueryAlgorithmType: number;
  44828. /**
  44829. * 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
  44830. * @see http://doc.babylonjs.com/features/occlusionquery
  44831. */
  44832. isOccluded: boolean;
  44833. /**
  44834. * Flag to check the progress status of the query
  44835. * @see http://doc.babylonjs.com/features/occlusionquery
  44836. */
  44837. isOcclusionQueryInProgress: boolean;
  44838. }
  44839. }
  44840. }
  44841. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  44842. import { Nullable } from "babylonjs/types";
  44843. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44844. /** @hidden */
  44845. export var _forceTransformFeedbackToBundle: boolean;
  44846. module "babylonjs/Engines/engine" {
  44847. interface Engine {
  44848. /**
  44849. * Creates a webGL transform feedback object
  44850. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44851. * @returns the webGL transform feedback object
  44852. */
  44853. createTransformFeedback(): WebGLTransformFeedback;
  44854. /**
  44855. * Delete a webGL transform feedback object
  44856. * @param value defines the webGL transform feedback object to delete
  44857. */
  44858. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44859. /**
  44860. * Bind a webGL transform feedback object to the webgl context
  44861. * @param value defines the webGL transform feedback object to bind
  44862. */
  44863. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44864. /**
  44865. * Begins a transform feedback operation
  44866. * @param usePoints defines if points or triangles must be used
  44867. */
  44868. beginTransformFeedback(usePoints: boolean): void;
  44869. /**
  44870. * Ends a transform feedback operation
  44871. */
  44872. endTransformFeedback(): void;
  44873. /**
  44874. * Specify the varyings to use with transform feedback
  44875. * @param program defines the associated webGL program
  44876. * @param value defines the list of strings representing the varying names
  44877. */
  44878. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44879. /**
  44880. * Bind a webGL buffer for a transform feedback operation
  44881. * @param value defines the webGL buffer to bind
  44882. */
  44883. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44884. }
  44885. }
  44886. }
  44887. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  44888. import { Scene } from "babylonjs/scene";
  44889. import { Engine } from "babylonjs/Engines/engine";
  44890. import { Texture } from "babylonjs/Materials/Textures/texture";
  44891. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44892. import "babylonjs/Engines/Extensions/engine.multiRender";
  44893. /**
  44894. * Creation options of the multi render target texture.
  44895. */
  44896. export interface IMultiRenderTargetOptions {
  44897. /**
  44898. * Define if the texture needs to create mip maps after render.
  44899. */
  44900. generateMipMaps?: boolean;
  44901. /**
  44902. * Define the types of all the draw buffers we want to create
  44903. */
  44904. types?: number[];
  44905. /**
  44906. * Define the sampling modes of all the draw buffers we want to create
  44907. */
  44908. samplingModes?: number[];
  44909. /**
  44910. * Define if a depth buffer is required
  44911. */
  44912. generateDepthBuffer?: boolean;
  44913. /**
  44914. * Define if a stencil buffer is required
  44915. */
  44916. generateStencilBuffer?: boolean;
  44917. /**
  44918. * Define if a depth texture is required instead of a depth buffer
  44919. */
  44920. generateDepthTexture?: boolean;
  44921. /**
  44922. * Define the number of desired draw buffers
  44923. */
  44924. textureCount?: number;
  44925. /**
  44926. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44927. */
  44928. doNotChangeAspectRatio?: boolean;
  44929. /**
  44930. * Define the default type of the buffers we are creating
  44931. */
  44932. defaultType?: number;
  44933. }
  44934. /**
  44935. * A multi render target, like a render target provides the ability to render to a texture.
  44936. * Unlike the render target, it can render to several draw buffers in one draw.
  44937. * This is specially interesting in deferred rendering or for any effects requiring more than
  44938. * just one color from a single pass.
  44939. */
  44940. export class MultiRenderTarget extends RenderTargetTexture {
  44941. private _internalTextures;
  44942. private _textures;
  44943. private _multiRenderTargetOptions;
  44944. /**
  44945. * Get if draw buffers are currently supported by the used hardware and browser.
  44946. */
  44947. readonly isSupported: boolean;
  44948. /**
  44949. * Get the list of textures generated by the multi render target.
  44950. */
  44951. readonly textures: Texture[];
  44952. /**
  44953. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44954. */
  44955. readonly depthTexture: Texture;
  44956. /**
  44957. * Set the wrapping mode on U of all the textures we are rendering to.
  44958. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44959. */
  44960. wrapU: number;
  44961. /**
  44962. * Set the wrapping mode on V of all the textures we are rendering to.
  44963. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44964. */
  44965. wrapV: number;
  44966. /**
  44967. * Instantiate a new multi render target texture.
  44968. * A multi render target, like a render target provides the ability to render to a texture.
  44969. * Unlike the render target, it can render to several draw buffers in one draw.
  44970. * This is specially interesting in deferred rendering or for any effects requiring more than
  44971. * just one color from a single pass.
  44972. * @param name Define the name of the texture
  44973. * @param size Define the size of the buffers to render to
  44974. * @param count Define the number of target we are rendering into
  44975. * @param scene Define the scene the texture belongs to
  44976. * @param options Define the options used to create the multi render target
  44977. */
  44978. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44979. /** @hidden */
  44980. _rebuild(): void;
  44981. private _createInternalTextures;
  44982. private _createTextures;
  44983. /**
  44984. * Define the number of samples used if MSAA is enabled.
  44985. */
  44986. samples: number;
  44987. /**
  44988. * Resize all the textures in the multi render target.
  44989. * Be carrefull as it will recreate all the data in the new texture.
  44990. * @param size Define the new size
  44991. */
  44992. resize(size: any): void;
  44993. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44994. /**
  44995. * Dispose the render targets and their associated resources
  44996. */
  44997. dispose(): void;
  44998. /**
  44999. * Release all the underlying texture used as draw buffers.
  45000. */
  45001. releaseInternalTextures(): void;
  45002. }
  45003. }
  45004. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45006. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45007. import { Nullable } from "babylonjs/types";
  45008. module "babylonjs/Engines/engine" {
  45009. interface Engine {
  45010. /**
  45011. * Unbind a list of render target textures from the webGL context
  45012. * This is used only when drawBuffer extension or webGL2 are active
  45013. * @param textures defines the render target textures to unbind
  45014. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45015. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45016. */
  45017. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45018. /**
  45019. * Create a multi render target texture
  45020. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45021. * @param size defines the size of the texture
  45022. * @param options defines the creation options
  45023. * @returns the cube texture as an InternalTexture
  45024. */
  45025. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45026. /**
  45027. * Update the sample count for a given multiple render target texture
  45028. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45029. * @param textures defines the textures to update
  45030. * @param samples defines the sample count to set
  45031. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45032. */
  45033. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45034. }
  45035. }
  45036. }
  45037. declare module "babylonjs/Engines/Extensions/index" {
  45038. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45039. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45040. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45041. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45042. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45043. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45044. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45045. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45046. }
  45047. declare module "babylonjs/Engines/index" {
  45048. export * from "babylonjs/Engines/constants";
  45049. export * from "babylonjs/Engines/engine";
  45050. export * from "babylonjs/Engines/engineStore";
  45051. export * from "babylonjs/Engines/nullEngine";
  45052. export * from "babylonjs/Engines/Extensions/index";
  45053. export * from "babylonjs/Engines/IPipelineContext";
  45054. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45055. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45056. }
  45057. declare module "babylonjs/Events/clipboardEvents" {
  45058. /**
  45059. * Gather the list of clipboard event types as constants.
  45060. */
  45061. export class ClipboardEventTypes {
  45062. /**
  45063. * The clipboard event is fired when a copy command is active (pressed).
  45064. */
  45065. static readonly COPY: number;
  45066. /**
  45067. * The clipboard event is fired when a cut command is active (pressed).
  45068. */
  45069. static readonly CUT: number;
  45070. /**
  45071. * The clipboard event is fired when a paste command is active (pressed).
  45072. */
  45073. static readonly PASTE: number;
  45074. }
  45075. /**
  45076. * This class is used to store clipboard related info for the onClipboardObservable event.
  45077. */
  45078. export class ClipboardInfo {
  45079. /**
  45080. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45081. */
  45082. type: number;
  45083. /**
  45084. * Defines the related dom event
  45085. */
  45086. event: ClipboardEvent;
  45087. /**
  45088. *Creates an instance of ClipboardInfo.
  45089. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45090. * @param event Defines the related dom event
  45091. */
  45092. constructor(
  45093. /**
  45094. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45095. */
  45096. type: number,
  45097. /**
  45098. * Defines the related dom event
  45099. */
  45100. event: ClipboardEvent);
  45101. /**
  45102. * Get the clipboard event's type from the keycode.
  45103. * @param keyCode Defines the keyCode for the current keyboard event.
  45104. * @return {number}
  45105. */
  45106. static GetTypeFromCharacter(keyCode: number): number;
  45107. }
  45108. }
  45109. declare module "babylonjs/Events/index" {
  45110. export * from "babylonjs/Events/keyboardEvents";
  45111. export * from "babylonjs/Events/pointerEvents";
  45112. export * from "babylonjs/Events/clipboardEvents";
  45113. }
  45114. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45115. import { Scene } from "babylonjs/scene";
  45116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45117. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45118. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45119. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45120. /**
  45121. * Google Daydream controller
  45122. */
  45123. export class DaydreamController extends WebVRController {
  45124. /**
  45125. * Base Url for the controller model.
  45126. */
  45127. static MODEL_BASE_URL: string;
  45128. /**
  45129. * File name for the controller model.
  45130. */
  45131. static MODEL_FILENAME: string;
  45132. /**
  45133. * Gamepad Id prefix used to identify Daydream Controller.
  45134. */
  45135. static readonly GAMEPAD_ID_PREFIX: string;
  45136. /**
  45137. * Creates a new DaydreamController from a gamepad
  45138. * @param vrGamepad the gamepad that the controller should be created from
  45139. */
  45140. constructor(vrGamepad: any);
  45141. /**
  45142. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45143. * @param scene scene in which to add meshes
  45144. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45145. */
  45146. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45147. /**
  45148. * Called once for each button that changed state since the last frame
  45149. * @param buttonIdx Which button index changed
  45150. * @param state New state of the button
  45151. * @param changes Which properties on the state changed since last frame
  45152. */
  45153. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45154. }
  45155. }
  45156. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45157. import { Scene } from "babylonjs/scene";
  45158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45159. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45160. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45161. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45162. /**
  45163. * Gear VR Controller
  45164. */
  45165. export class GearVRController extends WebVRController {
  45166. /**
  45167. * Base Url for the controller model.
  45168. */
  45169. static MODEL_BASE_URL: string;
  45170. /**
  45171. * File name for the controller model.
  45172. */
  45173. static MODEL_FILENAME: string;
  45174. /**
  45175. * Gamepad Id prefix used to identify this controller.
  45176. */
  45177. static readonly GAMEPAD_ID_PREFIX: string;
  45178. private readonly _buttonIndexToObservableNameMap;
  45179. /**
  45180. * Creates a new GearVRController from a gamepad
  45181. * @param vrGamepad the gamepad that the controller should be created from
  45182. */
  45183. constructor(vrGamepad: any);
  45184. /**
  45185. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45186. * @param scene scene in which to add meshes
  45187. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45188. */
  45189. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45190. /**
  45191. * Called once for each button that changed state since the last frame
  45192. * @param buttonIdx Which button index changed
  45193. * @param state New state of the button
  45194. * @param changes Which properties on the state changed since last frame
  45195. */
  45196. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45197. }
  45198. }
  45199. declare module "babylonjs/Gamepads/Controllers/index" {
  45200. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45201. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45202. export * from "babylonjs/Gamepads/Controllers/genericController";
  45203. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45204. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45205. export * from "babylonjs/Gamepads/Controllers/viveController";
  45206. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45207. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45208. }
  45209. declare module "babylonjs/Gamepads/index" {
  45210. export * from "babylonjs/Gamepads/Controllers/index";
  45211. export * from "babylonjs/Gamepads/gamepad";
  45212. export * from "babylonjs/Gamepads/gamepadManager";
  45213. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45214. export * from "babylonjs/Gamepads/xboxGamepad";
  45215. }
  45216. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45217. import { Scene } from "babylonjs/scene";
  45218. import { Vector4 } from "babylonjs/Maths/math.vector";
  45219. import { Color4 } from "babylonjs/Maths/math.color";
  45220. import { Mesh } from "babylonjs/Meshes/mesh";
  45221. import { Nullable } from "babylonjs/types";
  45222. /**
  45223. * Class containing static functions to help procedurally build meshes
  45224. */
  45225. export class PolyhedronBuilder {
  45226. /**
  45227. * Creates a polyhedron mesh
  45228. * * 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
  45229. * * The parameter `size` (positive float, default 1) sets the polygon size
  45230. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45231. * * 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`
  45232. * * 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
  45233. * * 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)`)
  45234. * * 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
  45235. * * 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
  45236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45239. * @param name defines the name of the mesh
  45240. * @param options defines the options used to create the mesh
  45241. * @param scene defines the hosting scene
  45242. * @returns the polyhedron mesh
  45243. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45244. */
  45245. static CreatePolyhedron(name: string, options: {
  45246. type?: number;
  45247. size?: number;
  45248. sizeX?: number;
  45249. sizeY?: number;
  45250. sizeZ?: number;
  45251. custom?: any;
  45252. faceUV?: Vector4[];
  45253. faceColors?: Color4[];
  45254. flat?: boolean;
  45255. updatable?: boolean;
  45256. sideOrientation?: number;
  45257. frontUVs?: Vector4;
  45258. backUVs?: Vector4;
  45259. }, scene?: Nullable<Scene>): Mesh;
  45260. }
  45261. }
  45262. declare module "babylonjs/Gizmos/scaleGizmo" {
  45263. import { Observable } from "babylonjs/Misc/observable";
  45264. import { Nullable } from "babylonjs/types";
  45265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45266. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45267. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45268. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45269. /**
  45270. * Gizmo that enables scaling a mesh along 3 axis
  45271. */
  45272. export class ScaleGizmo extends Gizmo {
  45273. /**
  45274. * Internal gizmo used for interactions on the x axis
  45275. */
  45276. xGizmo: AxisScaleGizmo;
  45277. /**
  45278. * Internal gizmo used for interactions on the y axis
  45279. */
  45280. yGizmo: AxisScaleGizmo;
  45281. /**
  45282. * Internal gizmo used for interactions on the z axis
  45283. */
  45284. zGizmo: AxisScaleGizmo;
  45285. /**
  45286. * Internal gizmo used to scale all axis equally
  45287. */
  45288. uniformScaleGizmo: AxisScaleGizmo;
  45289. private _meshAttached;
  45290. private _updateGizmoRotationToMatchAttachedMesh;
  45291. private _snapDistance;
  45292. private _scaleRatio;
  45293. private _uniformScalingMesh;
  45294. private _octahedron;
  45295. /** Fires an event when any of it's sub gizmos are dragged */
  45296. onDragStartObservable: Observable<unknown>;
  45297. /** Fires an event when any of it's sub gizmos are released from dragging */
  45298. onDragEndObservable: Observable<unknown>;
  45299. attachedMesh: Nullable<AbstractMesh>;
  45300. /**
  45301. * Creates a ScaleGizmo
  45302. * @param gizmoLayer The utility layer the gizmo will be added to
  45303. */
  45304. constructor(gizmoLayer?: UtilityLayerRenderer);
  45305. updateGizmoRotationToMatchAttachedMesh: boolean;
  45306. /**
  45307. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45308. */
  45309. snapDistance: number;
  45310. /**
  45311. * Ratio for the scale of the gizmo (Default: 1)
  45312. */
  45313. scaleRatio: number;
  45314. /**
  45315. * Disposes of the gizmo
  45316. */
  45317. dispose(): void;
  45318. }
  45319. }
  45320. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45321. import { Observable } from "babylonjs/Misc/observable";
  45322. import { Nullable } from "babylonjs/types";
  45323. import { Vector3 } from "babylonjs/Maths/math.vector";
  45324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45325. import { Mesh } from "babylonjs/Meshes/mesh";
  45326. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45327. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45328. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45329. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45330. import { Color3 } from "babylonjs/Maths/math.color";
  45331. /**
  45332. * Single axis scale gizmo
  45333. */
  45334. export class AxisScaleGizmo extends Gizmo {
  45335. /**
  45336. * Drag behavior responsible for the gizmos dragging interactions
  45337. */
  45338. dragBehavior: PointerDragBehavior;
  45339. private _pointerObserver;
  45340. /**
  45341. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45342. */
  45343. snapDistance: number;
  45344. /**
  45345. * Event that fires each time the gizmo snaps to a new location.
  45346. * * snapDistance is the the change in distance
  45347. */
  45348. onSnapObservable: Observable<{
  45349. snapDistance: number;
  45350. }>;
  45351. /**
  45352. * If the scaling operation should be done on all axis (default: false)
  45353. */
  45354. uniformScaling: boolean;
  45355. private _isEnabled;
  45356. private _parent;
  45357. private _arrow;
  45358. private _coloredMaterial;
  45359. private _hoverMaterial;
  45360. /**
  45361. * Creates an AxisScaleGizmo
  45362. * @param gizmoLayer The utility layer the gizmo will be added to
  45363. * @param dragAxis The axis which the gizmo will be able to scale on
  45364. * @param color The color of the gizmo
  45365. */
  45366. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45367. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45368. /**
  45369. * If the gizmo is enabled
  45370. */
  45371. isEnabled: boolean;
  45372. /**
  45373. * Disposes of the gizmo
  45374. */
  45375. dispose(): void;
  45376. /**
  45377. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45378. * @param mesh The mesh to replace the default mesh of the gizmo
  45379. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45380. */
  45381. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45382. }
  45383. }
  45384. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45385. import { Observable } from "babylonjs/Misc/observable";
  45386. import { Nullable } from "babylonjs/types";
  45387. import { Vector3 } from "babylonjs/Maths/math.vector";
  45388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45389. import { Mesh } from "babylonjs/Meshes/mesh";
  45390. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45391. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45392. import { Color3 } from "babylonjs/Maths/math.color";
  45393. import "babylonjs/Meshes/Builders/boxBuilder";
  45394. /**
  45395. * Bounding box gizmo
  45396. */
  45397. export class BoundingBoxGizmo extends Gizmo {
  45398. private _lineBoundingBox;
  45399. private _rotateSpheresParent;
  45400. private _scaleBoxesParent;
  45401. private _boundingDimensions;
  45402. private _renderObserver;
  45403. private _pointerObserver;
  45404. private _scaleDragSpeed;
  45405. private _tmpQuaternion;
  45406. private _tmpVector;
  45407. private _tmpRotationMatrix;
  45408. /**
  45409. * 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)
  45410. */
  45411. ignoreChildren: boolean;
  45412. /**
  45413. * 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)
  45414. */
  45415. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45416. /**
  45417. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45418. */
  45419. rotationSphereSize: number;
  45420. /**
  45421. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45422. */
  45423. scaleBoxSize: number;
  45424. /**
  45425. * 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)
  45426. */
  45427. fixedDragMeshScreenSize: boolean;
  45428. /**
  45429. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45430. */
  45431. fixedDragMeshScreenSizeDistanceFactor: number;
  45432. /**
  45433. * Fired when a rotation sphere or scale box is dragged
  45434. */
  45435. onDragStartObservable: Observable<{}>;
  45436. /**
  45437. * Fired when a scale box is dragged
  45438. */
  45439. onScaleBoxDragObservable: Observable<{}>;
  45440. /**
  45441. * Fired when a scale box drag is ended
  45442. */
  45443. onScaleBoxDragEndObservable: Observable<{}>;
  45444. /**
  45445. * Fired when a rotation sphere is dragged
  45446. */
  45447. onRotationSphereDragObservable: Observable<{}>;
  45448. /**
  45449. * Fired when a rotation sphere drag is ended
  45450. */
  45451. onRotationSphereDragEndObservable: Observable<{}>;
  45452. /**
  45453. * 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)
  45454. */
  45455. scalePivot: Nullable<Vector3>;
  45456. /**
  45457. * Mesh used as a pivot to rotate the attached mesh
  45458. */
  45459. private _anchorMesh;
  45460. private _existingMeshScale;
  45461. private _dragMesh;
  45462. private pointerDragBehavior;
  45463. private coloredMaterial;
  45464. private hoverColoredMaterial;
  45465. /**
  45466. * Sets the color of the bounding box gizmo
  45467. * @param color the color to set
  45468. */
  45469. setColor(color: Color3): void;
  45470. /**
  45471. * Creates an BoundingBoxGizmo
  45472. * @param gizmoLayer The utility layer the gizmo will be added to
  45473. * @param color The color of the gizmo
  45474. */
  45475. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45476. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45477. private _selectNode;
  45478. /**
  45479. * Updates the bounding box information for the Gizmo
  45480. */
  45481. updateBoundingBox(): void;
  45482. private _updateRotationSpheres;
  45483. private _updateScaleBoxes;
  45484. /**
  45485. * Enables rotation on the specified axis and disables rotation on the others
  45486. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45487. */
  45488. setEnabledRotationAxis(axis: string): void;
  45489. /**
  45490. * Enables/disables scaling
  45491. * @param enable if scaling should be enabled
  45492. */
  45493. setEnabledScaling(enable: boolean): void;
  45494. private _updateDummy;
  45495. /**
  45496. * Enables a pointer drag behavior on the bounding box of the gizmo
  45497. */
  45498. enableDragBehavior(): void;
  45499. /**
  45500. * Disposes of the gizmo
  45501. */
  45502. dispose(): void;
  45503. /**
  45504. * 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)
  45505. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45506. * @returns the bounding box mesh with the passed in mesh as a child
  45507. */
  45508. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45509. /**
  45510. * CustomMeshes are not supported by this gizmo
  45511. * @param mesh The mesh to replace the default mesh of the gizmo
  45512. */
  45513. setCustomMesh(mesh: Mesh): void;
  45514. }
  45515. }
  45516. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45517. import { Observable } from "babylonjs/Misc/observable";
  45518. import { Nullable } from "babylonjs/types";
  45519. import { Vector3 } from "babylonjs/Maths/math.vector";
  45520. import { Color3 } from "babylonjs/Maths/math.color";
  45521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45522. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45523. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45524. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45525. import "babylonjs/Meshes/Builders/linesBuilder";
  45526. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45527. /**
  45528. * Single plane rotation gizmo
  45529. */
  45530. export class PlaneRotationGizmo extends Gizmo {
  45531. /**
  45532. * Drag behavior responsible for the gizmos dragging interactions
  45533. */
  45534. dragBehavior: PointerDragBehavior;
  45535. private _pointerObserver;
  45536. /**
  45537. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45538. */
  45539. snapDistance: number;
  45540. /**
  45541. * Event that fires each time the gizmo snaps to a new location.
  45542. * * snapDistance is the the change in distance
  45543. */
  45544. onSnapObservable: Observable<{
  45545. snapDistance: number;
  45546. }>;
  45547. private _isEnabled;
  45548. private _parent;
  45549. /**
  45550. * Creates a PlaneRotationGizmo
  45551. * @param gizmoLayer The utility layer the gizmo will be added to
  45552. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45553. * @param color The color of the gizmo
  45554. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45555. */
  45556. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45557. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45558. /**
  45559. * If the gizmo is enabled
  45560. */
  45561. isEnabled: boolean;
  45562. /**
  45563. * Disposes of the gizmo
  45564. */
  45565. dispose(): void;
  45566. }
  45567. }
  45568. declare module "babylonjs/Gizmos/rotationGizmo" {
  45569. import { Observable } from "babylonjs/Misc/observable";
  45570. import { Nullable } from "babylonjs/types";
  45571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45572. import { Mesh } from "babylonjs/Meshes/mesh";
  45573. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45574. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45575. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45576. /**
  45577. * Gizmo that enables rotating a mesh along 3 axis
  45578. */
  45579. export class RotationGizmo extends Gizmo {
  45580. /**
  45581. * Internal gizmo used for interactions on the x axis
  45582. */
  45583. xGizmo: PlaneRotationGizmo;
  45584. /**
  45585. * Internal gizmo used for interactions on the y axis
  45586. */
  45587. yGizmo: PlaneRotationGizmo;
  45588. /**
  45589. * Internal gizmo used for interactions on the z axis
  45590. */
  45591. zGizmo: PlaneRotationGizmo;
  45592. /** Fires an event when any of it's sub gizmos are dragged */
  45593. onDragStartObservable: Observable<unknown>;
  45594. /** Fires an event when any of it's sub gizmos are released from dragging */
  45595. onDragEndObservable: Observable<unknown>;
  45596. private _meshAttached;
  45597. attachedMesh: Nullable<AbstractMesh>;
  45598. /**
  45599. * Creates a RotationGizmo
  45600. * @param gizmoLayer The utility layer the gizmo will be added to
  45601. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45602. */
  45603. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45604. updateGizmoRotationToMatchAttachedMesh: boolean;
  45605. /**
  45606. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45607. */
  45608. snapDistance: number;
  45609. /**
  45610. * Ratio for the scale of the gizmo (Default: 1)
  45611. */
  45612. scaleRatio: number;
  45613. /**
  45614. * Disposes of the gizmo
  45615. */
  45616. dispose(): void;
  45617. /**
  45618. * CustomMeshes are not supported by this gizmo
  45619. * @param mesh The mesh to replace the default mesh of the gizmo
  45620. */
  45621. setCustomMesh(mesh: Mesh): void;
  45622. }
  45623. }
  45624. declare module "babylonjs/Gizmos/gizmoManager" {
  45625. import { Observable } from "babylonjs/Misc/observable";
  45626. import { Nullable } from "babylonjs/types";
  45627. import { Scene, IDisposable } from "babylonjs/scene";
  45628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45629. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45630. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45631. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45632. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45633. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45634. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45635. /**
  45636. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45637. */
  45638. export class GizmoManager implements IDisposable {
  45639. private scene;
  45640. /**
  45641. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45642. */
  45643. gizmos: {
  45644. positionGizmo: Nullable<PositionGizmo>;
  45645. rotationGizmo: Nullable<RotationGizmo>;
  45646. scaleGizmo: Nullable<ScaleGizmo>;
  45647. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45648. };
  45649. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45650. clearGizmoOnEmptyPointerEvent: boolean;
  45651. /** Fires an event when the manager is attached to a mesh */
  45652. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45653. private _gizmosEnabled;
  45654. private _pointerObserver;
  45655. private _attachedMesh;
  45656. private _boundingBoxColor;
  45657. private _defaultUtilityLayer;
  45658. private _defaultKeepDepthUtilityLayer;
  45659. /**
  45660. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45661. */
  45662. boundingBoxDragBehavior: SixDofDragBehavior;
  45663. /**
  45664. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45665. */
  45666. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45667. /**
  45668. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45669. */
  45670. usePointerToAttachGizmos: boolean;
  45671. /**
  45672. * Utility layer that the bounding box gizmo belongs to
  45673. */
  45674. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45675. /**
  45676. * Utility layer that all gizmos besides bounding box belong to
  45677. */
  45678. readonly utilityLayer: UtilityLayerRenderer;
  45679. /**
  45680. * Instatiates a gizmo manager
  45681. * @param scene the scene to overlay the gizmos on top of
  45682. */
  45683. constructor(scene: Scene);
  45684. /**
  45685. * Attaches a set of gizmos to the specified mesh
  45686. * @param mesh The mesh the gizmo's should be attached to
  45687. */
  45688. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45689. /**
  45690. * If the position gizmo is enabled
  45691. */
  45692. positionGizmoEnabled: boolean;
  45693. /**
  45694. * If the rotation gizmo is enabled
  45695. */
  45696. rotationGizmoEnabled: boolean;
  45697. /**
  45698. * If the scale gizmo is enabled
  45699. */
  45700. scaleGizmoEnabled: boolean;
  45701. /**
  45702. * If the boundingBox gizmo is enabled
  45703. */
  45704. boundingBoxGizmoEnabled: boolean;
  45705. /**
  45706. * Disposes of the gizmo manager
  45707. */
  45708. dispose(): void;
  45709. }
  45710. }
  45711. declare module "babylonjs/Lights/directionalLight" {
  45712. import { Camera } from "babylonjs/Cameras/camera";
  45713. import { Scene } from "babylonjs/scene";
  45714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45716. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45717. import { Effect } from "babylonjs/Materials/effect";
  45718. /**
  45719. * A directional light is defined by a direction (what a surprise!).
  45720. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45721. * 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.
  45722. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45723. */
  45724. export class DirectionalLight extends ShadowLight {
  45725. private _shadowFrustumSize;
  45726. /**
  45727. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45728. */
  45729. /**
  45730. * Specifies a fix frustum size for the shadow generation.
  45731. */
  45732. shadowFrustumSize: number;
  45733. private _shadowOrthoScale;
  45734. /**
  45735. * Gets the shadow projection scale against the optimal computed one.
  45736. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45737. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45738. */
  45739. /**
  45740. * Sets the shadow projection scale against the optimal computed one.
  45741. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45742. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45743. */
  45744. shadowOrthoScale: number;
  45745. /**
  45746. * Automatically compute the projection matrix to best fit (including all the casters)
  45747. * on each frame.
  45748. */
  45749. autoUpdateExtends: boolean;
  45750. private _orthoLeft;
  45751. private _orthoRight;
  45752. private _orthoTop;
  45753. private _orthoBottom;
  45754. /**
  45755. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45756. * The directional light is emitted from everywhere in the given direction.
  45757. * It can cast shadows.
  45758. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45759. * @param name The friendly name of the light
  45760. * @param direction The direction of the light
  45761. * @param scene The scene the light belongs to
  45762. */
  45763. constructor(name: string, direction: Vector3, scene: Scene);
  45764. /**
  45765. * Returns the string "DirectionalLight".
  45766. * @return The class name
  45767. */
  45768. getClassName(): string;
  45769. /**
  45770. * Returns the integer 1.
  45771. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45772. */
  45773. getTypeID(): number;
  45774. /**
  45775. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45776. * Returns the DirectionalLight Shadow projection matrix.
  45777. */
  45778. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45779. /**
  45780. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45781. * Returns the DirectionalLight Shadow projection matrix.
  45782. */
  45783. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45784. /**
  45785. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45786. * Returns the DirectionalLight Shadow projection matrix.
  45787. */
  45788. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45789. protected _buildUniformLayout(): void;
  45790. /**
  45791. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45792. * @param effect The effect to update
  45793. * @param lightIndex The index of the light in the effect to update
  45794. * @returns The directional light
  45795. */
  45796. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45797. /**
  45798. * Gets the minZ used for shadow according to both the scene and the light.
  45799. *
  45800. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45801. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45802. * @param activeCamera The camera we are returning the min for
  45803. * @returns the depth min z
  45804. */
  45805. getDepthMinZ(activeCamera: Camera): number;
  45806. /**
  45807. * Gets the maxZ used for shadow according to both the scene and the light.
  45808. *
  45809. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45810. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45811. * @param activeCamera The camera we are returning the max for
  45812. * @returns the depth max z
  45813. */
  45814. getDepthMaxZ(activeCamera: Camera): number;
  45815. /**
  45816. * Prepares the list of defines specific to the light type.
  45817. * @param defines the list of defines
  45818. * @param lightIndex defines the index of the light for the effect
  45819. */
  45820. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45821. }
  45822. }
  45823. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45824. import { Mesh } from "babylonjs/Meshes/mesh";
  45825. /**
  45826. * Class containing static functions to help procedurally build meshes
  45827. */
  45828. export class HemisphereBuilder {
  45829. /**
  45830. * Creates a hemisphere mesh
  45831. * @param name defines the name of the mesh
  45832. * @param options defines the options used to create the mesh
  45833. * @param scene defines the hosting scene
  45834. * @returns the hemisphere mesh
  45835. */
  45836. static CreateHemisphere(name: string, options: {
  45837. segments?: number;
  45838. diameter?: number;
  45839. sideOrientation?: number;
  45840. }, scene: any): Mesh;
  45841. }
  45842. }
  45843. declare module "babylonjs/Lights/spotLight" {
  45844. import { Nullable } from "babylonjs/types";
  45845. import { Scene } from "babylonjs/scene";
  45846. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45848. import { Effect } from "babylonjs/Materials/effect";
  45849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45850. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45851. /**
  45852. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45853. * These values define a cone of light starting from the position, emitting toward the direction.
  45854. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45855. * and the exponent defines the speed of the decay of the light with distance (reach).
  45856. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45857. */
  45858. export class SpotLight extends ShadowLight {
  45859. private _angle;
  45860. private _innerAngle;
  45861. private _cosHalfAngle;
  45862. private _lightAngleScale;
  45863. private _lightAngleOffset;
  45864. /**
  45865. * Gets the cone angle of the spot light in Radians.
  45866. */
  45867. /**
  45868. * Sets the cone angle of the spot light in Radians.
  45869. */
  45870. angle: number;
  45871. /**
  45872. * Only used in gltf falloff mode, this defines the angle where
  45873. * the directional falloff will start before cutting at angle which could be seen
  45874. * as outer angle.
  45875. */
  45876. /**
  45877. * Only used in gltf falloff mode, this defines the angle where
  45878. * the directional falloff will start before cutting at angle which could be seen
  45879. * as outer angle.
  45880. */
  45881. innerAngle: number;
  45882. private _shadowAngleScale;
  45883. /**
  45884. * Allows scaling the angle of the light for shadow generation only.
  45885. */
  45886. /**
  45887. * Allows scaling the angle of the light for shadow generation only.
  45888. */
  45889. shadowAngleScale: number;
  45890. /**
  45891. * The light decay speed with the distance from the emission spot.
  45892. */
  45893. exponent: number;
  45894. private _projectionTextureMatrix;
  45895. /**
  45896. * Allows reading the projecton texture
  45897. */
  45898. readonly projectionTextureMatrix: Matrix;
  45899. protected _projectionTextureLightNear: number;
  45900. /**
  45901. * Gets the near clip of the Spotlight for texture projection.
  45902. */
  45903. /**
  45904. * Sets the near clip of the Spotlight for texture projection.
  45905. */
  45906. projectionTextureLightNear: number;
  45907. protected _projectionTextureLightFar: number;
  45908. /**
  45909. * Gets the far clip of the Spotlight for texture projection.
  45910. */
  45911. /**
  45912. * Sets the far clip of the Spotlight for texture projection.
  45913. */
  45914. projectionTextureLightFar: number;
  45915. protected _projectionTextureUpDirection: Vector3;
  45916. /**
  45917. * Gets the Up vector of the Spotlight for texture projection.
  45918. */
  45919. /**
  45920. * Sets the Up vector of the Spotlight for texture projection.
  45921. */
  45922. projectionTextureUpDirection: Vector3;
  45923. private _projectionTexture;
  45924. /**
  45925. * Gets the projection texture of the light.
  45926. */
  45927. /**
  45928. * Sets the projection texture of the light.
  45929. */
  45930. projectionTexture: Nullable<BaseTexture>;
  45931. private _projectionTextureViewLightDirty;
  45932. private _projectionTextureProjectionLightDirty;
  45933. private _projectionTextureDirty;
  45934. private _projectionTextureViewTargetVector;
  45935. private _projectionTextureViewLightMatrix;
  45936. private _projectionTextureProjectionLightMatrix;
  45937. private _projectionTextureScalingMatrix;
  45938. /**
  45939. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45940. * It can cast shadows.
  45941. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45942. * @param name The light friendly name
  45943. * @param position The position of the spot light in the scene
  45944. * @param direction The direction of the light in the scene
  45945. * @param angle The cone angle of the light in Radians
  45946. * @param exponent The light decay speed with the distance from the emission spot
  45947. * @param scene The scene the lights belongs to
  45948. */
  45949. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45950. /**
  45951. * Returns the string "SpotLight".
  45952. * @returns the class name
  45953. */
  45954. getClassName(): string;
  45955. /**
  45956. * Returns the integer 2.
  45957. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45958. */
  45959. getTypeID(): number;
  45960. /**
  45961. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45962. */
  45963. protected _setDirection(value: Vector3): void;
  45964. /**
  45965. * Overrides the position setter to recompute the projection texture view light Matrix.
  45966. */
  45967. protected _setPosition(value: Vector3): void;
  45968. /**
  45969. * 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.
  45970. * Returns the SpotLight.
  45971. */
  45972. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45973. protected _computeProjectionTextureViewLightMatrix(): void;
  45974. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45975. /**
  45976. * Main function for light texture projection matrix computing.
  45977. */
  45978. protected _computeProjectionTextureMatrix(): void;
  45979. protected _buildUniformLayout(): void;
  45980. private _computeAngleValues;
  45981. /**
  45982. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45983. * @param effect The effect to update
  45984. * @param lightIndex The index of the light in the effect to update
  45985. * @returns The spot light
  45986. */
  45987. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45988. /**
  45989. * Disposes the light and the associated resources.
  45990. */
  45991. dispose(): void;
  45992. /**
  45993. * Prepares the list of defines specific to the light type.
  45994. * @param defines the list of defines
  45995. * @param lightIndex defines the index of the light for the effect
  45996. */
  45997. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45998. }
  45999. }
  46000. declare module "babylonjs/Gizmos/lightGizmo" {
  46001. import { Nullable } from "babylonjs/types";
  46002. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46003. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46004. import { Light } from "babylonjs/Lights/light";
  46005. /**
  46006. * Gizmo that enables viewing a light
  46007. */
  46008. export class LightGizmo extends Gizmo {
  46009. private _lightMesh;
  46010. private _material;
  46011. private cachedPosition;
  46012. private cachedForward;
  46013. /**
  46014. * Creates a LightGizmo
  46015. * @param gizmoLayer The utility layer the gizmo will be added to
  46016. */
  46017. constructor(gizmoLayer?: UtilityLayerRenderer);
  46018. private _light;
  46019. /**
  46020. * The light that the gizmo is attached to
  46021. */
  46022. light: Nullable<Light>;
  46023. /**
  46024. * @hidden
  46025. * Updates the gizmo to match the attached mesh's position/rotation
  46026. */
  46027. protected _update(): void;
  46028. private static _Scale;
  46029. /**
  46030. * Creates the lines for a light mesh
  46031. */
  46032. private static _createLightLines;
  46033. /**
  46034. * Disposes of the light gizmo
  46035. */
  46036. dispose(): void;
  46037. private static _CreateHemisphericLightMesh;
  46038. private static _CreatePointLightMesh;
  46039. private static _CreateSpotLightMesh;
  46040. private static _CreateDirectionalLightMesh;
  46041. }
  46042. }
  46043. declare module "babylonjs/Gizmos/index" {
  46044. export * from "babylonjs/Gizmos/axisDragGizmo";
  46045. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46046. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46047. export * from "babylonjs/Gizmos/gizmo";
  46048. export * from "babylonjs/Gizmos/gizmoManager";
  46049. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46050. export * from "babylonjs/Gizmos/positionGizmo";
  46051. export * from "babylonjs/Gizmos/rotationGizmo";
  46052. export * from "babylonjs/Gizmos/scaleGizmo";
  46053. export * from "babylonjs/Gizmos/lightGizmo";
  46054. export * from "babylonjs/Gizmos/planeDragGizmo";
  46055. }
  46056. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46057. /** @hidden */
  46058. export var backgroundFragmentDeclaration: {
  46059. name: string;
  46060. shader: string;
  46061. };
  46062. }
  46063. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46064. /** @hidden */
  46065. export var backgroundUboDeclaration: {
  46066. name: string;
  46067. shader: string;
  46068. };
  46069. }
  46070. declare module "babylonjs/Shaders/background.fragment" {
  46071. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46072. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46073. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46074. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46075. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46076. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46077. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46078. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46079. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46080. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46081. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46082. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46083. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46084. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46085. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46086. /** @hidden */
  46087. export var backgroundPixelShader: {
  46088. name: string;
  46089. shader: string;
  46090. };
  46091. }
  46092. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46093. /** @hidden */
  46094. export var backgroundVertexDeclaration: {
  46095. name: string;
  46096. shader: string;
  46097. };
  46098. }
  46099. declare module "babylonjs/Shaders/background.vertex" {
  46100. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46101. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46102. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46103. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46104. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46105. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46106. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46107. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46108. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46109. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46110. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46111. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46112. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46113. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46114. /** @hidden */
  46115. export var backgroundVertexShader: {
  46116. name: string;
  46117. shader: string;
  46118. };
  46119. }
  46120. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46121. import { Nullable, int, float } from "babylonjs/types";
  46122. import { Scene } from "babylonjs/scene";
  46123. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46124. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46126. import { Mesh } from "babylonjs/Meshes/mesh";
  46127. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46128. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46129. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46131. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46132. import { Color3 } from "babylonjs/Maths/math.color";
  46133. import "babylonjs/Shaders/background.fragment";
  46134. import "babylonjs/Shaders/background.vertex";
  46135. /**
  46136. * Background material used to create an efficient environement around your scene.
  46137. */
  46138. export class BackgroundMaterial extends PushMaterial {
  46139. /**
  46140. * Standard reflectance value at parallel view angle.
  46141. */
  46142. static StandardReflectance0: number;
  46143. /**
  46144. * Standard reflectance value at grazing angle.
  46145. */
  46146. static StandardReflectance90: number;
  46147. protected _primaryColor: Color3;
  46148. /**
  46149. * Key light Color (multiply against the environement texture)
  46150. */
  46151. primaryColor: Color3;
  46152. protected __perceptualColor: Nullable<Color3>;
  46153. /**
  46154. * Experimental Internal Use Only.
  46155. *
  46156. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46157. * This acts as a helper to set the primary color to a more "human friendly" value.
  46158. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46159. * output color as close as possible from the chosen value.
  46160. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46161. * part of lighting setup.)
  46162. */
  46163. _perceptualColor: Nullable<Color3>;
  46164. protected _primaryColorShadowLevel: float;
  46165. /**
  46166. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46167. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46168. */
  46169. primaryColorShadowLevel: float;
  46170. protected _primaryColorHighlightLevel: float;
  46171. /**
  46172. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46173. * The primary color is used at the level chosen to define what the white area would look.
  46174. */
  46175. primaryColorHighlightLevel: float;
  46176. protected _reflectionTexture: Nullable<BaseTexture>;
  46177. /**
  46178. * Reflection Texture used in the material.
  46179. * Should be author in a specific way for the best result (refer to the documentation).
  46180. */
  46181. reflectionTexture: Nullable<BaseTexture>;
  46182. protected _reflectionBlur: float;
  46183. /**
  46184. * Reflection Texture level of blur.
  46185. *
  46186. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46187. * texture twice.
  46188. */
  46189. reflectionBlur: float;
  46190. protected _diffuseTexture: Nullable<BaseTexture>;
  46191. /**
  46192. * Diffuse Texture used in the material.
  46193. * Should be author in a specific way for the best result (refer to the documentation).
  46194. */
  46195. diffuseTexture: Nullable<BaseTexture>;
  46196. protected _shadowLights: Nullable<IShadowLight[]>;
  46197. /**
  46198. * Specify the list of lights casting shadow on the material.
  46199. * All scene shadow lights will be included if null.
  46200. */
  46201. shadowLights: Nullable<IShadowLight[]>;
  46202. protected _shadowLevel: float;
  46203. /**
  46204. * Helps adjusting the shadow to a softer level if required.
  46205. * 0 means black shadows and 1 means no shadows.
  46206. */
  46207. shadowLevel: float;
  46208. protected _sceneCenter: Vector3;
  46209. /**
  46210. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46211. * It is usually zero but might be interesting to modify according to your setup.
  46212. */
  46213. sceneCenter: Vector3;
  46214. protected _opacityFresnel: boolean;
  46215. /**
  46216. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46217. * This helps ensuring a nice transition when the camera goes under the ground.
  46218. */
  46219. opacityFresnel: boolean;
  46220. protected _reflectionFresnel: boolean;
  46221. /**
  46222. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46223. * This helps adding a mirror texture on the ground.
  46224. */
  46225. reflectionFresnel: boolean;
  46226. protected _reflectionFalloffDistance: number;
  46227. /**
  46228. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46229. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46230. */
  46231. reflectionFalloffDistance: number;
  46232. protected _reflectionAmount: number;
  46233. /**
  46234. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46235. */
  46236. reflectionAmount: number;
  46237. protected _reflectionReflectance0: number;
  46238. /**
  46239. * This specifies the weight of the reflection at grazing angle.
  46240. */
  46241. reflectionReflectance0: number;
  46242. protected _reflectionReflectance90: number;
  46243. /**
  46244. * This specifies the weight of the reflection at a perpendicular point of view.
  46245. */
  46246. reflectionReflectance90: number;
  46247. /**
  46248. * Sets the reflection reflectance fresnel values according to the default standard
  46249. * empirically know to work well :-)
  46250. */
  46251. reflectionStandardFresnelWeight: number;
  46252. protected _useRGBColor: boolean;
  46253. /**
  46254. * Helps to directly use the maps channels instead of their level.
  46255. */
  46256. useRGBColor: boolean;
  46257. protected _enableNoise: boolean;
  46258. /**
  46259. * This helps reducing the banding effect that could occur on the background.
  46260. */
  46261. enableNoise: boolean;
  46262. /**
  46263. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46264. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46265. * Recommended to be keep at 1.0 except for special cases.
  46266. */
  46267. fovMultiplier: number;
  46268. private _fovMultiplier;
  46269. /**
  46270. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46271. */
  46272. useEquirectangularFOV: boolean;
  46273. private _maxSimultaneousLights;
  46274. /**
  46275. * Number of Simultaneous lights allowed on the material.
  46276. */
  46277. maxSimultaneousLights: int;
  46278. /**
  46279. * Default configuration related to image processing available in the Background Material.
  46280. */
  46281. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46282. /**
  46283. * Keep track of the image processing observer to allow dispose and replace.
  46284. */
  46285. private _imageProcessingObserver;
  46286. /**
  46287. * Attaches a new image processing configuration to the PBR Material.
  46288. * @param configuration (if null the scene configuration will be use)
  46289. */
  46290. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46291. /**
  46292. * Gets the image processing configuration used either in this material.
  46293. */
  46294. /**
  46295. * Sets the Default image processing configuration used either in the this material.
  46296. *
  46297. * If sets to null, the scene one is in use.
  46298. */
  46299. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46300. /**
  46301. * Gets wether the color curves effect is enabled.
  46302. */
  46303. /**
  46304. * Sets wether the color curves effect is enabled.
  46305. */
  46306. cameraColorCurvesEnabled: boolean;
  46307. /**
  46308. * Gets wether the color grading effect is enabled.
  46309. */
  46310. /**
  46311. * Gets wether the color grading effect is enabled.
  46312. */
  46313. cameraColorGradingEnabled: boolean;
  46314. /**
  46315. * Gets wether tonemapping is enabled or not.
  46316. */
  46317. /**
  46318. * Sets wether tonemapping is enabled or not
  46319. */
  46320. cameraToneMappingEnabled: boolean;
  46321. /**
  46322. * The camera exposure used on this material.
  46323. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46324. * This corresponds to a photographic exposure.
  46325. */
  46326. /**
  46327. * The camera exposure used on this material.
  46328. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46329. * This corresponds to a photographic exposure.
  46330. */
  46331. cameraExposure: float;
  46332. /**
  46333. * Gets The camera contrast used on this material.
  46334. */
  46335. /**
  46336. * Sets The camera contrast used on this material.
  46337. */
  46338. cameraContrast: float;
  46339. /**
  46340. * Gets the Color Grading 2D Lookup Texture.
  46341. */
  46342. /**
  46343. * Sets the Color Grading 2D Lookup Texture.
  46344. */
  46345. cameraColorGradingTexture: Nullable<BaseTexture>;
  46346. /**
  46347. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46348. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46349. * 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;
  46350. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46351. */
  46352. /**
  46353. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46354. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46355. * 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;
  46356. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46357. */
  46358. cameraColorCurves: Nullable<ColorCurves>;
  46359. /**
  46360. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46361. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46362. */
  46363. switchToBGR: boolean;
  46364. private _renderTargets;
  46365. private _reflectionControls;
  46366. private _white;
  46367. private _primaryShadowColor;
  46368. private _primaryHighlightColor;
  46369. /**
  46370. * Instantiates a Background Material in the given scene
  46371. * @param name The friendly name of the material
  46372. * @param scene The scene to add the material to
  46373. */
  46374. constructor(name: string, scene: Scene);
  46375. /**
  46376. * Gets a boolean indicating that current material needs to register RTT
  46377. */
  46378. readonly hasRenderTargetTextures: boolean;
  46379. /**
  46380. * The entire material has been created in order to prevent overdraw.
  46381. * @returns false
  46382. */
  46383. needAlphaTesting(): boolean;
  46384. /**
  46385. * The entire material has been created in order to prevent overdraw.
  46386. * @returns true if blending is enable
  46387. */
  46388. needAlphaBlending(): boolean;
  46389. /**
  46390. * Checks wether the material is ready to be rendered for a given mesh.
  46391. * @param mesh The mesh to render
  46392. * @param subMesh The submesh to check against
  46393. * @param useInstances Specify wether or not the material is used with instances
  46394. * @returns true if all the dependencies are ready (Textures, Effects...)
  46395. */
  46396. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46397. /**
  46398. * Compute the primary color according to the chosen perceptual color.
  46399. */
  46400. private _computePrimaryColorFromPerceptualColor;
  46401. /**
  46402. * Compute the highlights and shadow colors according to their chosen levels.
  46403. */
  46404. private _computePrimaryColors;
  46405. /**
  46406. * Build the uniform buffer used in the material.
  46407. */
  46408. buildUniformLayout(): void;
  46409. /**
  46410. * Unbind the material.
  46411. */
  46412. unbind(): void;
  46413. /**
  46414. * Bind only the world matrix to the material.
  46415. * @param world The world matrix to bind.
  46416. */
  46417. bindOnlyWorldMatrix(world: Matrix): void;
  46418. /**
  46419. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46420. * @param world The world matrix to bind.
  46421. * @param subMesh The submesh to bind for.
  46422. */
  46423. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46424. /**
  46425. * Dispose the material.
  46426. * @param forceDisposeEffect Force disposal of the associated effect.
  46427. * @param forceDisposeTextures Force disposal of the associated textures.
  46428. */
  46429. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46430. /**
  46431. * Clones the material.
  46432. * @param name The cloned name.
  46433. * @returns The cloned material.
  46434. */
  46435. clone(name: string): BackgroundMaterial;
  46436. /**
  46437. * Serializes the current material to its JSON representation.
  46438. * @returns The JSON representation.
  46439. */
  46440. serialize(): any;
  46441. /**
  46442. * Gets the class name of the material
  46443. * @returns "BackgroundMaterial"
  46444. */
  46445. getClassName(): string;
  46446. /**
  46447. * Parse a JSON input to create back a background material.
  46448. * @param source The JSON data to parse
  46449. * @param scene The scene to create the parsed material in
  46450. * @param rootUrl The root url of the assets the material depends upon
  46451. * @returns the instantiated BackgroundMaterial.
  46452. */
  46453. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46454. }
  46455. }
  46456. declare module "babylonjs/Helpers/environmentHelper" {
  46457. import { Observable } from "babylonjs/Misc/observable";
  46458. import { Nullable } from "babylonjs/types";
  46459. import { Scene } from "babylonjs/scene";
  46460. import { Vector3 } from "babylonjs/Maths/math.vector";
  46461. import { Color3 } from "babylonjs/Maths/math.color";
  46462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46463. import { Mesh } from "babylonjs/Meshes/mesh";
  46464. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46465. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46466. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46467. import "babylonjs/Meshes/Builders/planeBuilder";
  46468. import "babylonjs/Meshes/Builders/boxBuilder";
  46469. /**
  46470. * Represents the different options available during the creation of
  46471. * a Environment helper.
  46472. *
  46473. * This can control the default ground, skybox and image processing setup of your scene.
  46474. */
  46475. export interface IEnvironmentHelperOptions {
  46476. /**
  46477. * Specifies wether or not to create a ground.
  46478. * True by default.
  46479. */
  46480. createGround: boolean;
  46481. /**
  46482. * Specifies the ground size.
  46483. * 15 by default.
  46484. */
  46485. groundSize: number;
  46486. /**
  46487. * The texture used on the ground for the main color.
  46488. * Comes from the BabylonJS CDN by default.
  46489. *
  46490. * Remarks: Can be either a texture or a url.
  46491. */
  46492. groundTexture: string | BaseTexture;
  46493. /**
  46494. * The color mixed in the ground texture by default.
  46495. * BabylonJS clearColor by default.
  46496. */
  46497. groundColor: Color3;
  46498. /**
  46499. * Specifies the ground opacity.
  46500. * 1 by default.
  46501. */
  46502. groundOpacity: number;
  46503. /**
  46504. * Enables the ground to receive shadows.
  46505. * True by default.
  46506. */
  46507. enableGroundShadow: boolean;
  46508. /**
  46509. * Helps preventing the shadow to be fully black on the ground.
  46510. * 0.5 by default.
  46511. */
  46512. groundShadowLevel: number;
  46513. /**
  46514. * Creates a mirror texture attach to the ground.
  46515. * false by default.
  46516. */
  46517. enableGroundMirror: boolean;
  46518. /**
  46519. * Specifies the ground mirror size ratio.
  46520. * 0.3 by default as the default kernel is 64.
  46521. */
  46522. groundMirrorSizeRatio: number;
  46523. /**
  46524. * Specifies the ground mirror blur kernel size.
  46525. * 64 by default.
  46526. */
  46527. groundMirrorBlurKernel: number;
  46528. /**
  46529. * Specifies the ground mirror visibility amount.
  46530. * 1 by default
  46531. */
  46532. groundMirrorAmount: number;
  46533. /**
  46534. * Specifies the ground mirror reflectance weight.
  46535. * This uses the standard weight of the background material to setup the fresnel effect
  46536. * of the mirror.
  46537. * 1 by default.
  46538. */
  46539. groundMirrorFresnelWeight: number;
  46540. /**
  46541. * Specifies the ground mirror Falloff distance.
  46542. * This can helps reducing the size of the reflection.
  46543. * 0 by Default.
  46544. */
  46545. groundMirrorFallOffDistance: number;
  46546. /**
  46547. * Specifies the ground mirror texture type.
  46548. * Unsigned Int by Default.
  46549. */
  46550. groundMirrorTextureType: number;
  46551. /**
  46552. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46553. * the shown objects.
  46554. */
  46555. groundYBias: number;
  46556. /**
  46557. * Specifies wether or not to create a skybox.
  46558. * True by default.
  46559. */
  46560. createSkybox: boolean;
  46561. /**
  46562. * Specifies the skybox size.
  46563. * 20 by default.
  46564. */
  46565. skyboxSize: number;
  46566. /**
  46567. * The texture used on the skybox for the main color.
  46568. * Comes from the BabylonJS CDN by default.
  46569. *
  46570. * Remarks: Can be either a texture or a url.
  46571. */
  46572. skyboxTexture: string | BaseTexture;
  46573. /**
  46574. * The color mixed in the skybox texture by default.
  46575. * BabylonJS clearColor by default.
  46576. */
  46577. skyboxColor: Color3;
  46578. /**
  46579. * The background rotation around the Y axis of the scene.
  46580. * This helps aligning the key lights of your scene with the background.
  46581. * 0 by default.
  46582. */
  46583. backgroundYRotation: number;
  46584. /**
  46585. * Compute automatically the size of the elements to best fit with the scene.
  46586. */
  46587. sizeAuto: boolean;
  46588. /**
  46589. * Default position of the rootMesh if autoSize is not true.
  46590. */
  46591. rootPosition: Vector3;
  46592. /**
  46593. * Sets up the image processing in the scene.
  46594. * true by default.
  46595. */
  46596. setupImageProcessing: boolean;
  46597. /**
  46598. * The texture used as your environment texture in the scene.
  46599. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46600. *
  46601. * Remarks: Can be either a texture or a url.
  46602. */
  46603. environmentTexture: string | BaseTexture;
  46604. /**
  46605. * The value of the exposure to apply to the scene.
  46606. * 0.6 by default if setupImageProcessing is true.
  46607. */
  46608. cameraExposure: number;
  46609. /**
  46610. * The value of the contrast to apply to the scene.
  46611. * 1.6 by default if setupImageProcessing is true.
  46612. */
  46613. cameraContrast: number;
  46614. /**
  46615. * Specifies wether or not tonemapping should be enabled in the scene.
  46616. * true by default if setupImageProcessing is true.
  46617. */
  46618. toneMappingEnabled: boolean;
  46619. }
  46620. /**
  46621. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46622. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46623. * It also helps with the default setup of your imageProcessing configuration.
  46624. */
  46625. export class EnvironmentHelper {
  46626. /**
  46627. * Default ground texture URL.
  46628. */
  46629. private static _groundTextureCDNUrl;
  46630. /**
  46631. * Default skybox texture URL.
  46632. */
  46633. private static _skyboxTextureCDNUrl;
  46634. /**
  46635. * Default environment texture URL.
  46636. */
  46637. private static _environmentTextureCDNUrl;
  46638. /**
  46639. * Creates the default options for the helper.
  46640. */
  46641. private static _getDefaultOptions;
  46642. private _rootMesh;
  46643. /**
  46644. * Gets the root mesh created by the helper.
  46645. */
  46646. readonly rootMesh: Mesh;
  46647. private _skybox;
  46648. /**
  46649. * Gets the skybox created by the helper.
  46650. */
  46651. readonly skybox: Nullable<Mesh>;
  46652. private _skyboxTexture;
  46653. /**
  46654. * Gets the skybox texture created by the helper.
  46655. */
  46656. readonly skyboxTexture: Nullable<BaseTexture>;
  46657. private _skyboxMaterial;
  46658. /**
  46659. * Gets the skybox material created by the helper.
  46660. */
  46661. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46662. private _ground;
  46663. /**
  46664. * Gets the ground mesh created by the helper.
  46665. */
  46666. readonly ground: Nullable<Mesh>;
  46667. private _groundTexture;
  46668. /**
  46669. * Gets the ground texture created by the helper.
  46670. */
  46671. readonly groundTexture: Nullable<BaseTexture>;
  46672. private _groundMirror;
  46673. /**
  46674. * Gets the ground mirror created by the helper.
  46675. */
  46676. readonly groundMirror: Nullable<MirrorTexture>;
  46677. /**
  46678. * Gets the ground mirror render list to helps pushing the meshes
  46679. * you wish in the ground reflection.
  46680. */
  46681. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46682. private _groundMaterial;
  46683. /**
  46684. * Gets the ground material created by the helper.
  46685. */
  46686. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46687. /**
  46688. * Stores the creation options.
  46689. */
  46690. private readonly _scene;
  46691. private _options;
  46692. /**
  46693. * This observable will be notified with any error during the creation of the environment,
  46694. * mainly texture creation errors.
  46695. */
  46696. onErrorObservable: Observable<{
  46697. message?: string;
  46698. exception?: any;
  46699. }>;
  46700. /**
  46701. * constructor
  46702. * @param options Defines the options we want to customize the helper
  46703. * @param scene The scene to add the material to
  46704. */
  46705. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46706. /**
  46707. * Updates the background according to the new options
  46708. * @param options
  46709. */
  46710. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46711. /**
  46712. * Sets the primary color of all the available elements.
  46713. * @param color the main color to affect to the ground and the background
  46714. */
  46715. setMainColor(color: Color3): void;
  46716. /**
  46717. * Setup the image processing according to the specified options.
  46718. */
  46719. private _setupImageProcessing;
  46720. /**
  46721. * Setup the environment texture according to the specified options.
  46722. */
  46723. private _setupEnvironmentTexture;
  46724. /**
  46725. * Setup the background according to the specified options.
  46726. */
  46727. private _setupBackground;
  46728. /**
  46729. * Get the scene sizes according to the setup.
  46730. */
  46731. private _getSceneSize;
  46732. /**
  46733. * Setup the ground according to the specified options.
  46734. */
  46735. private _setupGround;
  46736. /**
  46737. * Setup the ground material according to the specified options.
  46738. */
  46739. private _setupGroundMaterial;
  46740. /**
  46741. * Setup the ground diffuse texture according to the specified options.
  46742. */
  46743. private _setupGroundDiffuseTexture;
  46744. /**
  46745. * Setup the ground mirror texture according to the specified options.
  46746. */
  46747. private _setupGroundMirrorTexture;
  46748. /**
  46749. * Setup the ground to receive the mirror texture.
  46750. */
  46751. private _setupMirrorInGroundMaterial;
  46752. /**
  46753. * Setup the skybox according to the specified options.
  46754. */
  46755. private _setupSkybox;
  46756. /**
  46757. * Setup the skybox material according to the specified options.
  46758. */
  46759. private _setupSkyboxMaterial;
  46760. /**
  46761. * Setup the skybox reflection texture according to the specified options.
  46762. */
  46763. private _setupSkyboxReflectionTexture;
  46764. private _errorHandler;
  46765. /**
  46766. * Dispose all the elements created by the Helper.
  46767. */
  46768. dispose(): void;
  46769. }
  46770. }
  46771. declare module "babylonjs/Helpers/photoDome" {
  46772. import { Observable } from "babylonjs/Misc/observable";
  46773. import { Nullable } from "babylonjs/types";
  46774. import { Scene } from "babylonjs/scene";
  46775. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46776. import { Mesh } from "babylonjs/Meshes/mesh";
  46777. import { Texture } from "babylonjs/Materials/Textures/texture";
  46778. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46779. import "babylonjs/Meshes/Builders/sphereBuilder";
  46780. /**
  46781. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46782. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46783. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46784. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46785. */
  46786. export class PhotoDome extends TransformNode {
  46787. /**
  46788. * Define the image as a Monoscopic panoramic 360 image.
  46789. */
  46790. static readonly MODE_MONOSCOPIC: number;
  46791. /**
  46792. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46793. */
  46794. static readonly MODE_TOPBOTTOM: number;
  46795. /**
  46796. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46797. */
  46798. static readonly MODE_SIDEBYSIDE: number;
  46799. private _useDirectMapping;
  46800. /**
  46801. * The texture being displayed on the sphere
  46802. */
  46803. protected _photoTexture: Texture;
  46804. /**
  46805. * Gets or sets the texture being displayed on the sphere
  46806. */
  46807. photoTexture: Texture;
  46808. /**
  46809. * Observable raised when an error occured while loading the 360 image
  46810. */
  46811. onLoadErrorObservable: Observable<string>;
  46812. /**
  46813. * The skybox material
  46814. */
  46815. protected _material: BackgroundMaterial;
  46816. /**
  46817. * The surface used for the skybox
  46818. */
  46819. protected _mesh: Mesh;
  46820. /**
  46821. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46822. * Also see the options.resolution property.
  46823. */
  46824. fovMultiplier: number;
  46825. private _imageMode;
  46826. /**
  46827. * Gets or set the current video mode for the video. It can be:
  46828. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46829. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46830. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46831. */
  46832. imageMode: number;
  46833. /**
  46834. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46835. * @param name Element's name, child elements will append suffixes for their own names.
  46836. * @param urlsOfPhoto defines the url of the photo to display
  46837. * @param options defines an object containing optional or exposed sub element properties
  46838. * @param onError defines a callback called when an error occured while loading the texture
  46839. */
  46840. constructor(name: string, urlOfPhoto: string, options: {
  46841. resolution?: number;
  46842. size?: number;
  46843. useDirectMapping?: boolean;
  46844. faceForward?: boolean;
  46845. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46846. private _onBeforeCameraRenderObserver;
  46847. private _changeImageMode;
  46848. /**
  46849. * Releases resources associated with this node.
  46850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46852. */
  46853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46854. }
  46855. }
  46856. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46857. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46858. /** @hidden */
  46859. export var rgbdDecodePixelShader: {
  46860. name: string;
  46861. shader: string;
  46862. };
  46863. }
  46864. declare module "babylonjs/Misc/brdfTextureTools" {
  46865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46866. import { Scene } from "babylonjs/scene";
  46867. import "babylonjs/Shaders/rgbdDecode.fragment";
  46868. /**
  46869. * Class used to host texture specific utilities
  46870. */
  46871. export class BRDFTextureTools {
  46872. /**
  46873. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46874. * @param texture the texture to expand.
  46875. */
  46876. private static _ExpandDefaultBRDFTexture;
  46877. /**
  46878. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46879. * @param scene defines the hosting scene
  46880. * @returns the environment BRDF texture
  46881. */
  46882. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46883. private static _environmentBRDFBase64Texture;
  46884. }
  46885. }
  46886. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46887. import { Nullable } from "babylonjs/types";
  46888. import { Color3 } from "babylonjs/Maths/math.color";
  46889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46890. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46891. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46892. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  46893. import { Engine } from "babylonjs/Engines/engine";
  46894. import { Scene } from "babylonjs/scene";
  46895. /**
  46896. * @hidden
  46897. */
  46898. export interface IMaterialClearCoatDefines {
  46899. CLEARCOAT: boolean;
  46900. CLEARCOAT_DEFAULTIOR: boolean;
  46901. CLEARCOAT_TEXTURE: boolean;
  46902. CLEARCOAT_TEXTUREDIRECTUV: number;
  46903. CLEARCOAT_BUMP: boolean;
  46904. CLEARCOAT_BUMPDIRECTUV: number;
  46905. CLEARCOAT_TINT: boolean;
  46906. CLEARCOAT_TINT_TEXTURE: boolean;
  46907. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46908. /** @hidden */
  46909. _areTexturesDirty: boolean;
  46910. }
  46911. /**
  46912. * Define the code related to the clear coat parameters of the pbr material.
  46913. */
  46914. export class PBRClearCoatConfiguration {
  46915. /**
  46916. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46917. * The default fits with a polyurethane material.
  46918. */
  46919. private static readonly _DefaultIndexOfRefraction;
  46920. private _isEnabled;
  46921. /**
  46922. * Defines if the clear coat is enabled in the material.
  46923. */
  46924. isEnabled: boolean;
  46925. /**
  46926. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46927. */
  46928. intensity: number;
  46929. /**
  46930. * Defines the clear coat layer roughness.
  46931. */
  46932. roughness: number;
  46933. private _indexOfRefraction;
  46934. /**
  46935. * Defines the index of refraction of the clear coat.
  46936. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46937. * The default fits with a polyurethane material.
  46938. * Changing the default value is more performance intensive.
  46939. */
  46940. indexOfRefraction: number;
  46941. private _texture;
  46942. /**
  46943. * Stores the clear coat values in a texture.
  46944. */
  46945. texture: Nullable<BaseTexture>;
  46946. private _bumpTexture;
  46947. /**
  46948. * Define the clear coat specific bump texture.
  46949. */
  46950. bumpTexture: Nullable<BaseTexture>;
  46951. private _isTintEnabled;
  46952. /**
  46953. * Defines if the clear coat tint is enabled in the material.
  46954. */
  46955. isTintEnabled: boolean;
  46956. /**
  46957. * Defines the clear coat tint of the material.
  46958. * This is only use if tint is enabled
  46959. */
  46960. tintColor: Color3;
  46961. /**
  46962. * Defines the distance at which the tint color should be found in the
  46963. * clear coat media.
  46964. * This is only use if tint is enabled
  46965. */
  46966. tintColorAtDistance: number;
  46967. /**
  46968. * Defines the clear coat layer thickness.
  46969. * This is only use if tint is enabled
  46970. */
  46971. tintThickness: number;
  46972. private _tintTexture;
  46973. /**
  46974. * Stores the clear tint values in a texture.
  46975. * rgb is tint
  46976. * a is a thickness factor
  46977. */
  46978. tintTexture: Nullable<BaseTexture>;
  46979. /** @hidden */
  46980. private _internalMarkAllSubMeshesAsTexturesDirty;
  46981. /** @hidden */
  46982. _markAllSubMeshesAsTexturesDirty(): void;
  46983. /**
  46984. * Instantiate a new istance of clear coat configuration.
  46985. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46986. */
  46987. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46988. /**
  46989. * Gets wehter the submesh is ready to be used or not.
  46990. * @param defines the list of "defines" to update.
  46991. * @param scene defines the scene the material belongs to.
  46992. * @param engine defines the engine the material belongs to.
  46993. * @param disableBumpMap defines wether the material disables bump or not.
  46994. * @returns - boolean indicating that the submesh is ready or not.
  46995. */
  46996. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46997. /**
  46998. * Checks to see if a texture is used in the material.
  46999. * @param defines the list of "defines" to update.
  47000. * @param scene defines the scene to the material belongs to.
  47001. */
  47002. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47003. /**
  47004. * Binds the material data.
  47005. * @param uniformBuffer defines the Uniform buffer to fill in.
  47006. * @param scene defines the scene the material belongs to.
  47007. * @param engine defines the engine the material belongs to.
  47008. * @param disableBumpMap defines wether the material disables bump or not.
  47009. * @param isFrozen defines wether the material is frozen or not.
  47010. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47011. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47012. */
  47013. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47014. /**
  47015. * Checks to see if a texture is used in the material.
  47016. * @param texture - Base texture to use.
  47017. * @returns - Boolean specifying if a texture is used in the material.
  47018. */
  47019. hasTexture(texture: BaseTexture): boolean;
  47020. /**
  47021. * Returns an array of the actively used textures.
  47022. * @param activeTextures Array of BaseTextures
  47023. */
  47024. getActiveTextures(activeTextures: BaseTexture[]): void;
  47025. /**
  47026. * Returns the animatable textures.
  47027. * @param animatables Array of animatable textures.
  47028. */
  47029. getAnimatables(animatables: IAnimatable[]): void;
  47030. /**
  47031. * Disposes the resources of the material.
  47032. * @param forceDisposeTextures - Forces the disposal of all textures.
  47033. */
  47034. dispose(forceDisposeTextures?: boolean): void;
  47035. /**
  47036. * Get the current class name of the texture useful for serialization or dynamic coding.
  47037. * @returns "PBRClearCoatConfiguration"
  47038. */
  47039. getClassName(): string;
  47040. /**
  47041. * Add fallbacks to the effect fallbacks list.
  47042. * @param defines defines the Base texture to use.
  47043. * @param fallbacks defines the current fallback list.
  47044. * @param currentRank defines the current fallback rank.
  47045. * @returns the new fallback rank.
  47046. */
  47047. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47048. /**
  47049. * Add the required uniforms to the current list.
  47050. * @param uniforms defines the current uniform list.
  47051. */
  47052. static AddUniforms(uniforms: string[]): void;
  47053. /**
  47054. * Add the required samplers to the current list.
  47055. * @param samplers defines the current sampler list.
  47056. */
  47057. static AddSamplers(samplers: string[]): void;
  47058. /**
  47059. * Add the required uniforms to the current buffer.
  47060. * @param uniformBuffer defines the current uniform buffer.
  47061. */
  47062. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47063. /**
  47064. * Makes a duplicate of the current configuration into another one.
  47065. * @param clearCoatConfiguration define the config where to copy the info
  47066. */
  47067. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47068. /**
  47069. * Serializes this clear coat configuration.
  47070. * @returns - An object with the serialized config.
  47071. */
  47072. serialize(): any;
  47073. /**
  47074. * Parses a anisotropy Configuration from a serialized object.
  47075. * @param source - Serialized object.
  47076. * @param scene Defines the scene we are parsing for
  47077. * @param rootUrl Defines the rootUrl to load from
  47078. */
  47079. parse(source: any, scene: Scene, rootUrl: string): void;
  47080. }
  47081. }
  47082. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47083. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47084. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47086. import { Vector2 } from "babylonjs/Maths/math.vector";
  47087. import { Scene } from "babylonjs/scene";
  47088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47089. import { Nullable } from "babylonjs/types";
  47090. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47091. /**
  47092. * @hidden
  47093. */
  47094. export interface IMaterialAnisotropicDefines {
  47095. ANISOTROPIC: boolean;
  47096. ANISOTROPIC_TEXTURE: boolean;
  47097. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47098. MAINUV1: boolean;
  47099. _areTexturesDirty: boolean;
  47100. _needUVs: boolean;
  47101. }
  47102. /**
  47103. * Define the code related to the anisotropic parameters of the pbr material.
  47104. */
  47105. export class PBRAnisotropicConfiguration {
  47106. private _isEnabled;
  47107. /**
  47108. * Defines if the anisotropy is enabled in the material.
  47109. */
  47110. isEnabled: boolean;
  47111. /**
  47112. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47113. */
  47114. intensity: number;
  47115. /**
  47116. * Defines if the effect is along the tangents, bitangents or in between.
  47117. * By default, the effect is "strectching" the highlights along the tangents.
  47118. */
  47119. direction: Vector2;
  47120. private _texture;
  47121. /**
  47122. * Stores the anisotropy values in a texture.
  47123. * rg is direction (like normal from -1 to 1)
  47124. * b is a intensity
  47125. */
  47126. texture: Nullable<BaseTexture>;
  47127. /** @hidden */
  47128. private _internalMarkAllSubMeshesAsTexturesDirty;
  47129. /** @hidden */
  47130. _markAllSubMeshesAsTexturesDirty(): void;
  47131. /**
  47132. * Instantiate a new istance of anisotropy configuration.
  47133. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47134. */
  47135. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47136. /**
  47137. * Specifies that the submesh is ready to be used.
  47138. * @param defines the list of "defines" to update.
  47139. * @param scene defines the scene the material belongs to.
  47140. * @returns - boolean indicating that the submesh is ready or not.
  47141. */
  47142. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47143. /**
  47144. * Checks to see if a texture is used in the material.
  47145. * @param defines the list of "defines" to update.
  47146. * @param mesh the mesh we are preparing the defines for.
  47147. * @param scene defines the scene the material belongs to.
  47148. */
  47149. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47150. /**
  47151. * Binds the material data.
  47152. * @param uniformBuffer defines the Uniform buffer to fill in.
  47153. * @param scene defines the scene the material belongs to.
  47154. * @param isFrozen defines wether the material is frozen or not.
  47155. */
  47156. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47157. /**
  47158. * Checks to see if a texture is used in the material.
  47159. * @param texture - Base texture to use.
  47160. * @returns - Boolean specifying if a texture is used in the material.
  47161. */
  47162. hasTexture(texture: BaseTexture): boolean;
  47163. /**
  47164. * Returns an array of the actively used textures.
  47165. * @param activeTextures Array of BaseTextures
  47166. */
  47167. getActiveTextures(activeTextures: BaseTexture[]): void;
  47168. /**
  47169. * Returns the animatable textures.
  47170. * @param animatables Array of animatable textures.
  47171. */
  47172. getAnimatables(animatables: IAnimatable[]): void;
  47173. /**
  47174. * Disposes the resources of the material.
  47175. * @param forceDisposeTextures - Forces the disposal of all textures.
  47176. */
  47177. dispose(forceDisposeTextures?: boolean): void;
  47178. /**
  47179. * Get the current class name of the texture useful for serialization or dynamic coding.
  47180. * @returns "PBRAnisotropicConfiguration"
  47181. */
  47182. getClassName(): string;
  47183. /**
  47184. * Add fallbacks to the effect fallbacks list.
  47185. * @param defines defines the Base texture to use.
  47186. * @param fallbacks defines the current fallback list.
  47187. * @param currentRank defines the current fallback rank.
  47188. * @returns the new fallback rank.
  47189. */
  47190. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47191. /**
  47192. * Add the required uniforms to the current list.
  47193. * @param uniforms defines the current uniform list.
  47194. */
  47195. static AddUniforms(uniforms: string[]): void;
  47196. /**
  47197. * Add the required uniforms to the current buffer.
  47198. * @param uniformBuffer defines the current uniform buffer.
  47199. */
  47200. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47201. /**
  47202. * Add the required samplers to the current list.
  47203. * @param samplers defines the current sampler list.
  47204. */
  47205. static AddSamplers(samplers: string[]): void;
  47206. /**
  47207. * Makes a duplicate of the current configuration into another one.
  47208. * @param anisotropicConfiguration define the config where to copy the info
  47209. */
  47210. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47211. /**
  47212. * Serializes this anisotropy configuration.
  47213. * @returns - An object with the serialized config.
  47214. */
  47215. serialize(): any;
  47216. /**
  47217. * Parses a anisotropy Configuration from a serialized object.
  47218. * @param source - Serialized object.
  47219. * @param scene Defines the scene we are parsing for
  47220. * @param rootUrl Defines the rootUrl to load from
  47221. */
  47222. parse(source: any, scene: Scene, rootUrl: string): void;
  47223. }
  47224. }
  47225. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47226. import { Scene } from "babylonjs/scene";
  47227. /**
  47228. * @hidden
  47229. */
  47230. export interface IMaterialBRDFDefines {
  47231. BRDF_V_HEIGHT_CORRELATED: boolean;
  47232. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47233. SPHERICAL_HARMONICS: boolean;
  47234. /** @hidden */
  47235. _areMiscDirty: boolean;
  47236. }
  47237. /**
  47238. * Define the code related to the BRDF parameters of the pbr material.
  47239. */
  47240. export class PBRBRDFConfiguration {
  47241. /**
  47242. * Default value used for the energy conservation.
  47243. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47244. */
  47245. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47246. /**
  47247. * Default value used for the Smith Visibility Height Correlated mode.
  47248. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47249. */
  47250. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47251. /**
  47252. * Default value used for the IBL diffuse part.
  47253. * This can help switching back to the polynomials mode globally which is a tiny bit
  47254. * less GPU intensive at the drawback of a lower quality.
  47255. */
  47256. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47257. private _useEnergyConservation;
  47258. /**
  47259. * Defines if the material uses energy conservation.
  47260. */
  47261. useEnergyConservation: boolean;
  47262. private _useSmithVisibilityHeightCorrelated;
  47263. /**
  47264. * LEGACY Mode set to false
  47265. * Defines if the material uses height smith correlated visibility term.
  47266. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47267. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47268. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47269. * Not relying on height correlated will also disable energy conservation.
  47270. */
  47271. useSmithVisibilityHeightCorrelated: boolean;
  47272. private _useSphericalHarmonics;
  47273. /**
  47274. * LEGACY Mode set to false
  47275. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47276. * diffuse part of the IBL.
  47277. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47278. * to the ground truth.
  47279. */
  47280. useSphericalHarmonics: boolean;
  47281. /** @hidden */
  47282. private _internalMarkAllSubMeshesAsMiscDirty;
  47283. /** @hidden */
  47284. _markAllSubMeshesAsMiscDirty(): void;
  47285. /**
  47286. * Instantiate a new istance of clear coat configuration.
  47287. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47288. */
  47289. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47290. /**
  47291. * Checks to see if a texture is used in the material.
  47292. * @param defines the list of "defines" to update.
  47293. */
  47294. prepareDefines(defines: IMaterialBRDFDefines): void;
  47295. /**
  47296. * Get the current class name of the texture useful for serialization or dynamic coding.
  47297. * @returns "PBRClearCoatConfiguration"
  47298. */
  47299. getClassName(): string;
  47300. /**
  47301. * Makes a duplicate of the current configuration into another one.
  47302. * @param brdfConfiguration define the config where to copy the info
  47303. */
  47304. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47305. /**
  47306. * Serializes this BRDF configuration.
  47307. * @returns - An object with the serialized config.
  47308. */
  47309. serialize(): any;
  47310. /**
  47311. * Parses a anisotropy Configuration from a serialized object.
  47312. * @param source - Serialized object.
  47313. * @param scene Defines the scene we are parsing for
  47314. * @param rootUrl Defines the rootUrl to load from
  47315. */
  47316. parse(source: any, scene: Scene, rootUrl: string): void;
  47317. }
  47318. }
  47319. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47320. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47321. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47322. import { Color3 } from "babylonjs/Maths/math.color";
  47323. import { Scene } from "babylonjs/scene";
  47324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47325. import { Nullable } from "babylonjs/types";
  47326. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47327. /**
  47328. * @hidden
  47329. */
  47330. export interface IMaterialSheenDefines {
  47331. SHEEN: boolean;
  47332. SHEEN_TEXTURE: boolean;
  47333. SHEEN_TEXTUREDIRECTUV: number;
  47334. SHEEN_LINKWITHALBEDO: boolean;
  47335. /** @hidden */
  47336. _areTexturesDirty: boolean;
  47337. }
  47338. /**
  47339. * Define the code related to the Sheen parameters of the pbr material.
  47340. */
  47341. export class PBRSheenConfiguration {
  47342. private _isEnabled;
  47343. /**
  47344. * Defines if the material uses sheen.
  47345. */
  47346. isEnabled: boolean;
  47347. private _linkSheenWithAlbedo;
  47348. /**
  47349. * Defines if the sheen is linked to the sheen color.
  47350. */
  47351. linkSheenWithAlbedo: boolean;
  47352. /**
  47353. * Defines the sheen intensity.
  47354. */
  47355. intensity: number;
  47356. /**
  47357. * Defines the sheen color.
  47358. */
  47359. color: Color3;
  47360. private _texture;
  47361. /**
  47362. * Stores the sheen tint values in a texture.
  47363. * rgb is tint
  47364. * a is a intensity
  47365. */
  47366. texture: Nullable<BaseTexture>;
  47367. /** @hidden */
  47368. private _internalMarkAllSubMeshesAsTexturesDirty;
  47369. /** @hidden */
  47370. _markAllSubMeshesAsTexturesDirty(): void;
  47371. /**
  47372. * Instantiate a new istance of clear coat configuration.
  47373. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47374. */
  47375. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47376. /**
  47377. * Specifies that the submesh is ready to be used.
  47378. * @param defines the list of "defines" to update.
  47379. * @param scene defines the scene the material belongs to.
  47380. * @returns - boolean indicating that the submesh is ready or not.
  47381. */
  47382. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47383. /**
  47384. * Checks to see if a texture is used in the material.
  47385. * @param defines the list of "defines" to update.
  47386. * @param scene defines the scene the material belongs to.
  47387. */
  47388. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47389. /**
  47390. * Binds the material data.
  47391. * @param uniformBuffer defines the Uniform buffer to fill in.
  47392. * @param scene defines the scene the material belongs to.
  47393. * @param isFrozen defines wether the material is frozen or not.
  47394. */
  47395. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47396. /**
  47397. * Checks to see if a texture is used in the material.
  47398. * @param texture - Base texture to use.
  47399. * @returns - Boolean specifying if a texture is used in the material.
  47400. */
  47401. hasTexture(texture: BaseTexture): boolean;
  47402. /**
  47403. * Returns an array of the actively used textures.
  47404. * @param activeTextures Array of BaseTextures
  47405. */
  47406. getActiveTextures(activeTextures: BaseTexture[]): void;
  47407. /**
  47408. * Returns the animatable textures.
  47409. * @param animatables Array of animatable textures.
  47410. */
  47411. getAnimatables(animatables: IAnimatable[]): void;
  47412. /**
  47413. * Disposes the resources of the material.
  47414. * @param forceDisposeTextures - Forces the disposal of all textures.
  47415. */
  47416. dispose(forceDisposeTextures?: boolean): void;
  47417. /**
  47418. * Get the current class name of the texture useful for serialization or dynamic coding.
  47419. * @returns "PBRSheenConfiguration"
  47420. */
  47421. getClassName(): string;
  47422. /**
  47423. * Add fallbacks to the effect fallbacks list.
  47424. * @param defines defines the Base texture to use.
  47425. * @param fallbacks defines the current fallback list.
  47426. * @param currentRank defines the current fallback rank.
  47427. * @returns the new fallback rank.
  47428. */
  47429. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47430. /**
  47431. * Add the required uniforms to the current list.
  47432. * @param uniforms defines the current uniform list.
  47433. */
  47434. static AddUniforms(uniforms: string[]): void;
  47435. /**
  47436. * Add the required uniforms to the current buffer.
  47437. * @param uniformBuffer defines the current uniform buffer.
  47438. */
  47439. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47440. /**
  47441. * Add the required samplers to the current list.
  47442. * @param samplers defines the current sampler list.
  47443. */
  47444. static AddSamplers(samplers: string[]): void;
  47445. /**
  47446. * Makes a duplicate of the current configuration into another one.
  47447. * @param sheenConfiguration define the config where to copy the info
  47448. */
  47449. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47450. /**
  47451. * Serializes this BRDF configuration.
  47452. * @returns - An object with the serialized config.
  47453. */
  47454. serialize(): any;
  47455. /**
  47456. * Parses a anisotropy Configuration from a serialized object.
  47457. * @param source - Serialized object.
  47458. * @param scene Defines the scene we are parsing for
  47459. * @param rootUrl Defines the rootUrl to load from
  47460. */
  47461. parse(source: any, scene: Scene, rootUrl: string): void;
  47462. }
  47463. }
  47464. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47465. import { Nullable } from "babylonjs/types";
  47466. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47467. import { Color3 } from "babylonjs/Maths/math.color";
  47468. import { SmartArray } from "babylonjs/Misc/smartArray";
  47469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47471. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47472. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47473. import { Engine } from "babylonjs/Engines/engine";
  47474. import { Scene } from "babylonjs/scene";
  47475. /**
  47476. * @hidden
  47477. */
  47478. export interface IMaterialSubSurfaceDefines {
  47479. SUBSURFACE: boolean;
  47480. SS_REFRACTION: boolean;
  47481. SS_TRANSLUCENCY: boolean;
  47482. SS_SCATERRING: boolean;
  47483. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47484. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47485. SS_REFRACTIONMAP_3D: boolean;
  47486. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47487. SS_LODINREFRACTIONALPHA: boolean;
  47488. SS_GAMMAREFRACTION: boolean;
  47489. SS_RGBDREFRACTION: boolean;
  47490. SS_LINEARSPECULARREFRACTION: boolean;
  47491. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47492. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47493. /** @hidden */
  47494. _areTexturesDirty: boolean;
  47495. }
  47496. /**
  47497. * Define the code related to the sub surface parameters of the pbr material.
  47498. */
  47499. export class PBRSubSurfaceConfiguration {
  47500. private _isRefractionEnabled;
  47501. /**
  47502. * Defines if the refraction is enabled in the material.
  47503. */
  47504. isRefractionEnabled: boolean;
  47505. private _isTranslucencyEnabled;
  47506. /**
  47507. * Defines if the translucency is enabled in the material.
  47508. */
  47509. isTranslucencyEnabled: boolean;
  47510. private _isScatteringEnabled;
  47511. /**
  47512. * Defines the refraction intensity of the material.
  47513. * The refraction when enabled replaces the Diffuse part of the material.
  47514. * The intensity helps transitionning between diffuse and refraction.
  47515. */
  47516. refractionIntensity: number;
  47517. /**
  47518. * Defines the translucency intensity of the material.
  47519. * When translucency has been enabled, this defines how much of the "translucency"
  47520. * is addded to the diffuse part of the material.
  47521. */
  47522. translucencyIntensity: number;
  47523. /**
  47524. * Defines the scattering intensity of the material.
  47525. * When scattering has been enabled, this defines how much of the "scattered light"
  47526. * is addded to the diffuse part of the material.
  47527. */
  47528. scatteringIntensity: number;
  47529. private _thicknessTexture;
  47530. /**
  47531. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47532. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47533. * 0 would mean minimumThickness
  47534. * 1 would mean maximumThickness
  47535. * The other channels might be use as a mask to vary the different effects intensity.
  47536. */
  47537. thicknessTexture: Nullable<BaseTexture>;
  47538. private _refractionTexture;
  47539. /**
  47540. * Defines the texture to use for refraction.
  47541. */
  47542. refractionTexture: Nullable<BaseTexture>;
  47543. private _indexOfRefraction;
  47544. /**
  47545. * Defines the index of refraction used in the material.
  47546. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47547. */
  47548. indexOfRefraction: number;
  47549. private _invertRefractionY;
  47550. /**
  47551. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47552. */
  47553. invertRefractionY: boolean;
  47554. private _linkRefractionWithTransparency;
  47555. /**
  47556. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47557. * Materials half opaque for instance using refraction could benefit from this control.
  47558. */
  47559. linkRefractionWithTransparency: boolean;
  47560. /**
  47561. * Defines the minimum thickness stored in the thickness map.
  47562. * If no thickness map is defined, this value will be used to simulate thickness.
  47563. */
  47564. minimumThickness: number;
  47565. /**
  47566. * Defines the maximum thickness stored in the thickness map.
  47567. */
  47568. maximumThickness: number;
  47569. /**
  47570. * Defines the volume tint of the material.
  47571. * This is used for both translucency and scattering.
  47572. */
  47573. tintColor: Color3;
  47574. /**
  47575. * Defines the distance at which the tint color should be found in the media.
  47576. * This is used for refraction only.
  47577. */
  47578. tintColorAtDistance: number;
  47579. /**
  47580. * Defines how far each channel transmit through the media.
  47581. * It is defined as a color to simplify it selection.
  47582. */
  47583. diffusionDistance: Color3;
  47584. private _useMaskFromThicknessTexture;
  47585. /**
  47586. * Stores the intensity of the different subsurface effects in the thickness texture.
  47587. * * the green channel is the translucency intensity.
  47588. * * the blue channel is the scattering intensity.
  47589. * * the alpha channel is the refraction intensity.
  47590. */
  47591. useMaskFromThicknessTexture: boolean;
  47592. /** @hidden */
  47593. private _internalMarkAllSubMeshesAsTexturesDirty;
  47594. /** @hidden */
  47595. _markAllSubMeshesAsTexturesDirty(): void;
  47596. /**
  47597. * Instantiate a new istance of sub surface configuration.
  47598. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47599. */
  47600. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47601. /**
  47602. * Gets wehter the submesh is ready to be used or not.
  47603. * @param defines the list of "defines" to update.
  47604. * @param scene defines the scene the material belongs to.
  47605. * @returns - boolean indicating that the submesh is ready or not.
  47606. */
  47607. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47608. /**
  47609. * Checks to see if a texture is used in the material.
  47610. * @param defines the list of "defines" to update.
  47611. * @param scene defines the scene to the material belongs to.
  47612. */
  47613. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47614. /**
  47615. * Binds the material data.
  47616. * @param uniformBuffer defines the Uniform buffer to fill in.
  47617. * @param scene defines the scene the material belongs to.
  47618. * @param engine defines the engine the material belongs to.
  47619. * @param isFrozen defines wether the material is frozen or not.
  47620. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47621. */
  47622. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47623. /**
  47624. * Unbinds the material from the mesh.
  47625. * @param activeEffect defines the effect that should be unbound from.
  47626. * @returns true if unbound, otherwise false
  47627. */
  47628. unbind(activeEffect: Effect): boolean;
  47629. /**
  47630. * Returns the texture used for refraction or null if none is used.
  47631. * @param scene defines the scene the material belongs to.
  47632. * @returns - Refraction texture if present. If no refraction texture and refraction
  47633. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47634. */
  47635. private _getRefractionTexture;
  47636. /**
  47637. * Returns true if alpha blending should be disabled.
  47638. */
  47639. readonly disableAlphaBlending: boolean;
  47640. /**
  47641. * Fills the list of render target textures.
  47642. * @param renderTargets the list of render targets to update
  47643. */
  47644. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47645. /**
  47646. * Checks to see if a texture is used in the material.
  47647. * @param texture - Base texture to use.
  47648. * @returns - Boolean specifying if a texture is used in the material.
  47649. */
  47650. hasTexture(texture: BaseTexture): boolean;
  47651. /**
  47652. * Gets a boolean indicating that current material needs to register RTT
  47653. * @returns true if this uses a render target otherwise false.
  47654. */
  47655. hasRenderTargetTextures(): boolean;
  47656. /**
  47657. * Returns an array of the actively used textures.
  47658. * @param activeTextures Array of BaseTextures
  47659. */
  47660. getActiveTextures(activeTextures: BaseTexture[]): void;
  47661. /**
  47662. * Returns the animatable textures.
  47663. * @param animatables Array of animatable textures.
  47664. */
  47665. getAnimatables(animatables: IAnimatable[]): void;
  47666. /**
  47667. * Disposes the resources of the material.
  47668. * @param forceDisposeTextures - Forces the disposal of all textures.
  47669. */
  47670. dispose(forceDisposeTextures?: boolean): void;
  47671. /**
  47672. * Get the current class name of the texture useful for serialization or dynamic coding.
  47673. * @returns "PBRSubSurfaceConfiguration"
  47674. */
  47675. getClassName(): string;
  47676. /**
  47677. * Add fallbacks to the effect fallbacks list.
  47678. * @param defines defines the Base texture to use.
  47679. * @param fallbacks defines the current fallback list.
  47680. * @param currentRank defines the current fallback rank.
  47681. * @returns the new fallback rank.
  47682. */
  47683. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47684. /**
  47685. * Add the required uniforms to the current list.
  47686. * @param uniforms defines the current uniform list.
  47687. */
  47688. static AddUniforms(uniforms: string[]): void;
  47689. /**
  47690. * Add the required samplers to the current list.
  47691. * @param samplers defines the current sampler list.
  47692. */
  47693. static AddSamplers(samplers: string[]): void;
  47694. /**
  47695. * Add the required uniforms to the current buffer.
  47696. * @param uniformBuffer defines the current uniform buffer.
  47697. */
  47698. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47699. /**
  47700. * Makes a duplicate of the current configuration into another one.
  47701. * @param configuration define the config where to copy the info
  47702. */
  47703. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47704. /**
  47705. * Serializes this Sub Surface configuration.
  47706. * @returns - An object with the serialized config.
  47707. */
  47708. serialize(): any;
  47709. /**
  47710. * Parses a anisotropy Configuration from a serialized object.
  47711. * @param source - Serialized object.
  47712. * @param scene Defines the scene we are parsing for
  47713. * @param rootUrl Defines the rootUrl to load from
  47714. */
  47715. parse(source: any, scene: Scene, rootUrl: string): void;
  47716. }
  47717. }
  47718. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47719. /** @hidden */
  47720. export var pbrFragmentDeclaration: {
  47721. name: string;
  47722. shader: string;
  47723. };
  47724. }
  47725. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47726. /** @hidden */
  47727. export var pbrUboDeclaration: {
  47728. name: string;
  47729. shader: string;
  47730. };
  47731. }
  47732. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47733. /** @hidden */
  47734. export var pbrFragmentExtraDeclaration: {
  47735. name: string;
  47736. shader: string;
  47737. };
  47738. }
  47739. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47740. /** @hidden */
  47741. export var pbrFragmentSamplersDeclaration: {
  47742. name: string;
  47743. shader: string;
  47744. };
  47745. }
  47746. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47747. /** @hidden */
  47748. export var pbrHelperFunctions: {
  47749. name: string;
  47750. shader: string;
  47751. };
  47752. }
  47753. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47754. /** @hidden */
  47755. export var harmonicsFunctions: {
  47756. name: string;
  47757. shader: string;
  47758. };
  47759. }
  47760. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47761. /** @hidden */
  47762. export var pbrDirectLightingSetupFunctions: {
  47763. name: string;
  47764. shader: string;
  47765. };
  47766. }
  47767. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47768. /** @hidden */
  47769. export var pbrDirectLightingFalloffFunctions: {
  47770. name: string;
  47771. shader: string;
  47772. };
  47773. }
  47774. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47775. /** @hidden */
  47776. export var pbrBRDFFunctions: {
  47777. name: string;
  47778. shader: string;
  47779. };
  47780. }
  47781. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47782. /** @hidden */
  47783. export var pbrDirectLightingFunctions: {
  47784. name: string;
  47785. shader: string;
  47786. };
  47787. }
  47788. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47789. /** @hidden */
  47790. export var pbrIBLFunctions: {
  47791. name: string;
  47792. shader: string;
  47793. };
  47794. }
  47795. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47796. /** @hidden */
  47797. export var pbrDebug: {
  47798. name: string;
  47799. shader: string;
  47800. };
  47801. }
  47802. declare module "babylonjs/Shaders/pbr.fragment" {
  47803. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47804. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47805. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47806. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47807. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47808. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47809. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47810. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47811. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47812. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47813. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47814. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47815. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47816. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47817. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47818. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47819. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47820. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47821. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47822. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47823. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47824. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47825. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47826. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47827. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47828. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47829. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47830. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47831. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47832. /** @hidden */
  47833. export var pbrPixelShader: {
  47834. name: string;
  47835. shader: string;
  47836. };
  47837. }
  47838. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47839. /** @hidden */
  47840. export var pbrVertexDeclaration: {
  47841. name: string;
  47842. shader: string;
  47843. };
  47844. }
  47845. declare module "babylonjs/Shaders/pbr.vertex" {
  47846. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47847. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47848. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47849. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47850. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47851. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47852. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47853. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47854. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47855. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47856. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47858. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47859. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47860. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47861. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47862. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47863. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47864. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47865. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47866. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47867. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47868. /** @hidden */
  47869. export var pbrVertexShader: {
  47870. name: string;
  47871. shader: string;
  47872. };
  47873. }
  47874. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47875. import { Nullable } from "babylonjs/types";
  47876. import { Scene } from "babylonjs/scene";
  47877. import { Matrix } from "babylonjs/Maths/math.vector";
  47878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47880. import { Mesh } from "babylonjs/Meshes/mesh";
  47881. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47882. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47883. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47884. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47885. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47886. import { Color3 } from "babylonjs/Maths/math.color";
  47887. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47888. import { Material } from "babylonjs/Materials/material";
  47889. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47890. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47892. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47893. import "babylonjs/Shaders/pbr.fragment";
  47894. import "babylonjs/Shaders/pbr.vertex";
  47895. /**
  47896. * Manages the defines for the PBR Material.
  47897. * @hidden
  47898. */
  47899. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47900. PBR: boolean;
  47901. MAINUV1: boolean;
  47902. MAINUV2: boolean;
  47903. UV1: boolean;
  47904. UV2: boolean;
  47905. ALBEDO: boolean;
  47906. ALBEDODIRECTUV: number;
  47907. VERTEXCOLOR: boolean;
  47908. AMBIENT: boolean;
  47909. AMBIENTDIRECTUV: number;
  47910. AMBIENTINGRAYSCALE: boolean;
  47911. OPACITY: boolean;
  47912. VERTEXALPHA: boolean;
  47913. OPACITYDIRECTUV: number;
  47914. OPACITYRGB: boolean;
  47915. ALPHATEST: boolean;
  47916. DEPTHPREPASS: boolean;
  47917. ALPHABLEND: boolean;
  47918. ALPHAFROMALBEDO: boolean;
  47919. ALPHATESTVALUE: string;
  47920. SPECULAROVERALPHA: boolean;
  47921. RADIANCEOVERALPHA: boolean;
  47922. ALPHAFRESNEL: boolean;
  47923. LINEARALPHAFRESNEL: boolean;
  47924. PREMULTIPLYALPHA: boolean;
  47925. EMISSIVE: boolean;
  47926. EMISSIVEDIRECTUV: number;
  47927. REFLECTIVITY: boolean;
  47928. REFLECTIVITYDIRECTUV: number;
  47929. SPECULARTERM: boolean;
  47930. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47931. MICROSURFACEAUTOMATIC: boolean;
  47932. LODBASEDMICROSFURACE: boolean;
  47933. MICROSURFACEMAP: boolean;
  47934. MICROSURFACEMAPDIRECTUV: number;
  47935. METALLICWORKFLOW: boolean;
  47936. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47937. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47938. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47939. AOSTOREINMETALMAPRED: boolean;
  47940. ENVIRONMENTBRDF: boolean;
  47941. ENVIRONMENTBRDF_RGBD: boolean;
  47942. NORMAL: boolean;
  47943. TANGENT: boolean;
  47944. BUMP: boolean;
  47945. BUMPDIRECTUV: number;
  47946. OBJECTSPACE_NORMALMAP: boolean;
  47947. PARALLAX: boolean;
  47948. PARALLAXOCCLUSION: boolean;
  47949. NORMALXYSCALE: boolean;
  47950. LIGHTMAP: boolean;
  47951. LIGHTMAPDIRECTUV: number;
  47952. USELIGHTMAPASSHADOWMAP: boolean;
  47953. GAMMALIGHTMAP: boolean;
  47954. REFLECTION: boolean;
  47955. REFLECTIONMAP_3D: boolean;
  47956. REFLECTIONMAP_SPHERICAL: boolean;
  47957. REFLECTIONMAP_PLANAR: boolean;
  47958. REFLECTIONMAP_CUBIC: boolean;
  47959. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47960. REFLECTIONMAP_PROJECTION: boolean;
  47961. REFLECTIONMAP_SKYBOX: boolean;
  47962. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47963. REFLECTIONMAP_EXPLICIT: boolean;
  47964. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47965. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47966. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47967. INVERTCUBICMAP: boolean;
  47968. USESPHERICALFROMREFLECTIONMAP: boolean;
  47969. USEIRRADIANCEMAP: boolean;
  47970. SPHERICAL_HARMONICS: boolean;
  47971. USESPHERICALINVERTEX: boolean;
  47972. REFLECTIONMAP_OPPOSITEZ: boolean;
  47973. LODINREFLECTIONALPHA: boolean;
  47974. GAMMAREFLECTION: boolean;
  47975. RGBDREFLECTION: boolean;
  47976. LINEARSPECULARREFLECTION: boolean;
  47977. RADIANCEOCCLUSION: boolean;
  47978. HORIZONOCCLUSION: boolean;
  47979. INSTANCES: boolean;
  47980. NUM_BONE_INFLUENCERS: number;
  47981. BonesPerMesh: number;
  47982. BONETEXTURE: boolean;
  47983. NONUNIFORMSCALING: boolean;
  47984. MORPHTARGETS: boolean;
  47985. MORPHTARGETS_NORMAL: boolean;
  47986. MORPHTARGETS_TANGENT: boolean;
  47987. MORPHTARGETS_UV: boolean;
  47988. NUM_MORPH_INFLUENCERS: number;
  47989. IMAGEPROCESSING: boolean;
  47990. VIGNETTE: boolean;
  47991. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47992. VIGNETTEBLENDMODEOPAQUE: boolean;
  47993. TONEMAPPING: boolean;
  47994. TONEMAPPING_ACES: boolean;
  47995. CONTRAST: boolean;
  47996. COLORCURVES: boolean;
  47997. COLORGRADING: boolean;
  47998. COLORGRADING3D: boolean;
  47999. SAMPLER3DGREENDEPTH: boolean;
  48000. SAMPLER3DBGRMAP: boolean;
  48001. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48002. EXPOSURE: boolean;
  48003. MULTIVIEW: boolean;
  48004. USEPHYSICALLIGHTFALLOFF: boolean;
  48005. USEGLTFLIGHTFALLOFF: boolean;
  48006. TWOSIDEDLIGHTING: boolean;
  48007. SHADOWFLOAT: boolean;
  48008. CLIPPLANE: boolean;
  48009. CLIPPLANE2: boolean;
  48010. CLIPPLANE3: boolean;
  48011. CLIPPLANE4: boolean;
  48012. POINTSIZE: boolean;
  48013. FOG: boolean;
  48014. LOGARITHMICDEPTH: boolean;
  48015. FORCENORMALFORWARD: boolean;
  48016. SPECULARAA: boolean;
  48017. CLEARCOAT: boolean;
  48018. CLEARCOAT_DEFAULTIOR: boolean;
  48019. CLEARCOAT_TEXTURE: boolean;
  48020. CLEARCOAT_TEXTUREDIRECTUV: number;
  48021. CLEARCOAT_BUMP: boolean;
  48022. CLEARCOAT_BUMPDIRECTUV: number;
  48023. CLEARCOAT_TINT: boolean;
  48024. CLEARCOAT_TINT_TEXTURE: boolean;
  48025. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48026. ANISOTROPIC: boolean;
  48027. ANISOTROPIC_TEXTURE: boolean;
  48028. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48029. BRDF_V_HEIGHT_CORRELATED: boolean;
  48030. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48031. SHEEN: boolean;
  48032. SHEEN_TEXTURE: boolean;
  48033. SHEEN_TEXTUREDIRECTUV: number;
  48034. SHEEN_LINKWITHALBEDO: boolean;
  48035. SUBSURFACE: boolean;
  48036. SS_REFRACTION: boolean;
  48037. SS_TRANSLUCENCY: boolean;
  48038. SS_SCATERRING: boolean;
  48039. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48040. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48041. SS_REFRACTIONMAP_3D: boolean;
  48042. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48043. SS_LODINREFRACTIONALPHA: boolean;
  48044. SS_GAMMAREFRACTION: boolean;
  48045. SS_RGBDREFRACTION: boolean;
  48046. SS_LINEARSPECULARREFRACTION: boolean;
  48047. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48048. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48049. UNLIT: boolean;
  48050. DEBUGMODE: number;
  48051. /**
  48052. * Initializes the PBR Material defines.
  48053. */
  48054. constructor();
  48055. /**
  48056. * Resets the PBR Material defines.
  48057. */
  48058. reset(): void;
  48059. }
  48060. /**
  48061. * The Physically based material base class of BJS.
  48062. *
  48063. * This offers the main features of a standard PBR material.
  48064. * For more information, please refer to the documentation :
  48065. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48066. */
  48067. export abstract class PBRBaseMaterial extends PushMaterial {
  48068. /**
  48069. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48070. */
  48071. static readonly PBRMATERIAL_OPAQUE: number;
  48072. /**
  48073. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48074. */
  48075. static readonly PBRMATERIAL_ALPHATEST: number;
  48076. /**
  48077. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48078. */
  48079. static readonly PBRMATERIAL_ALPHABLEND: number;
  48080. /**
  48081. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48082. * They are also discarded below the alpha cutoff threshold to improve performances.
  48083. */
  48084. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48085. /**
  48086. * Defines the default value of how much AO map is occluding the analytical lights
  48087. * (point spot...).
  48088. */
  48089. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48090. /**
  48091. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48092. */
  48093. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48094. /**
  48095. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48096. * to enhance interoperability with other engines.
  48097. */
  48098. static readonly LIGHTFALLOFF_GLTF: number;
  48099. /**
  48100. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48101. * to enhance interoperability with other materials.
  48102. */
  48103. static readonly LIGHTFALLOFF_STANDARD: number;
  48104. /**
  48105. * Intensity of the direct lights e.g. the four lights available in your scene.
  48106. * This impacts both the direct diffuse and specular highlights.
  48107. */
  48108. protected _directIntensity: number;
  48109. /**
  48110. * Intensity of the emissive part of the material.
  48111. * This helps controlling the emissive effect without modifying the emissive color.
  48112. */
  48113. protected _emissiveIntensity: number;
  48114. /**
  48115. * Intensity of the environment e.g. how much the environment will light the object
  48116. * either through harmonics for rough material or through the refelction for shiny ones.
  48117. */
  48118. protected _environmentIntensity: number;
  48119. /**
  48120. * This is a special control allowing the reduction of the specular highlights coming from the
  48121. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48122. */
  48123. protected _specularIntensity: number;
  48124. /**
  48125. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48126. */
  48127. private _lightingInfos;
  48128. /**
  48129. * Debug Control allowing disabling the bump map on this material.
  48130. */
  48131. protected _disableBumpMap: boolean;
  48132. /**
  48133. * AKA Diffuse Texture in standard nomenclature.
  48134. */
  48135. protected _albedoTexture: Nullable<BaseTexture>;
  48136. /**
  48137. * AKA Occlusion Texture in other nomenclature.
  48138. */
  48139. protected _ambientTexture: Nullable<BaseTexture>;
  48140. /**
  48141. * AKA Occlusion Texture Intensity in other nomenclature.
  48142. */
  48143. protected _ambientTextureStrength: number;
  48144. /**
  48145. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48146. * 1 means it completely occludes it
  48147. * 0 mean it has no impact
  48148. */
  48149. protected _ambientTextureImpactOnAnalyticalLights: number;
  48150. /**
  48151. * Stores the alpha values in a texture.
  48152. */
  48153. protected _opacityTexture: Nullable<BaseTexture>;
  48154. /**
  48155. * Stores the reflection values in a texture.
  48156. */
  48157. protected _reflectionTexture: Nullable<BaseTexture>;
  48158. /**
  48159. * Stores the emissive values in a texture.
  48160. */
  48161. protected _emissiveTexture: Nullable<BaseTexture>;
  48162. /**
  48163. * AKA Specular texture in other nomenclature.
  48164. */
  48165. protected _reflectivityTexture: Nullable<BaseTexture>;
  48166. /**
  48167. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48168. */
  48169. protected _metallicTexture: Nullable<BaseTexture>;
  48170. /**
  48171. * Specifies the metallic scalar of the metallic/roughness workflow.
  48172. * Can also be used to scale the metalness values of the metallic texture.
  48173. */
  48174. protected _metallic: Nullable<number>;
  48175. /**
  48176. * Specifies the roughness scalar of the metallic/roughness workflow.
  48177. * Can also be used to scale the roughness values of the metallic texture.
  48178. */
  48179. protected _roughness: Nullable<number>;
  48180. /**
  48181. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48182. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48183. */
  48184. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48185. /**
  48186. * Stores surface normal data used to displace a mesh in a texture.
  48187. */
  48188. protected _bumpTexture: Nullable<BaseTexture>;
  48189. /**
  48190. * Stores the pre-calculated light information of a mesh in a texture.
  48191. */
  48192. protected _lightmapTexture: Nullable<BaseTexture>;
  48193. /**
  48194. * The color of a material in ambient lighting.
  48195. */
  48196. protected _ambientColor: Color3;
  48197. /**
  48198. * AKA Diffuse Color in other nomenclature.
  48199. */
  48200. protected _albedoColor: Color3;
  48201. /**
  48202. * AKA Specular Color in other nomenclature.
  48203. */
  48204. protected _reflectivityColor: Color3;
  48205. /**
  48206. * The color applied when light is reflected from a material.
  48207. */
  48208. protected _reflectionColor: Color3;
  48209. /**
  48210. * The color applied when light is emitted from a material.
  48211. */
  48212. protected _emissiveColor: Color3;
  48213. /**
  48214. * AKA Glossiness in other nomenclature.
  48215. */
  48216. protected _microSurface: number;
  48217. /**
  48218. * Specifies that the material will use the light map as a show map.
  48219. */
  48220. protected _useLightmapAsShadowmap: boolean;
  48221. /**
  48222. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48223. * makes the reflect vector face the model (under horizon).
  48224. */
  48225. protected _useHorizonOcclusion: boolean;
  48226. /**
  48227. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48228. * too much the area relying on ambient texture to define their ambient occlusion.
  48229. */
  48230. protected _useRadianceOcclusion: boolean;
  48231. /**
  48232. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48233. */
  48234. protected _useAlphaFromAlbedoTexture: boolean;
  48235. /**
  48236. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48237. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48238. */
  48239. protected _useSpecularOverAlpha: boolean;
  48240. /**
  48241. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48242. */
  48243. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48244. /**
  48245. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48246. */
  48247. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48248. /**
  48249. * Specifies if the metallic texture contains the roughness information in its green channel.
  48250. */
  48251. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48252. /**
  48253. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48254. */
  48255. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48256. /**
  48257. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48258. */
  48259. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48260. /**
  48261. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48262. */
  48263. protected _useAmbientInGrayScale: boolean;
  48264. /**
  48265. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48266. * The material will try to infer what glossiness each pixel should be.
  48267. */
  48268. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48269. /**
  48270. * Defines the falloff type used in this material.
  48271. * It by default is Physical.
  48272. */
  48273. protected _lightFalloff: number;
  48274. /**
  48275. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48276. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48277. */
  48278. protected _useRadianceOverAlpha: boolean;
  48279. /**
  48280. * Allows using an object space normal map (instead of tangent space).
  48281. */
  48282. protected _useObjectSpaceNormalMap: boolean;
  48283. /**
  48284. * Allows using the bump map in parallax mode.
  48285. */
  48286. protected _useParallax: boolean;
  48287. /**
  48288. * Allows using the bump map in parallax occlusion mode.
  48289. */
  48290. protected _useParallaxOcclusion: boolean;
  48291. /**
  48292. * Controls the scale bias of the parallax mode.
  48293. */
  48294. protected _parallaxScaleBias: number;
  48295. /**
  48296. * If sets to true, disables all the lights affecting the material.
  48297. */
  48298. protected _disableLighting: boolean;
  48299. /**
  48300. * Number of Simultaneous lights allowed on the material.
  48301. */
  48302. protected _maxSimultaneousLights: number;
  48303. /**
  48304. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48305. */
  48306. protected _invertNormalMapX: boolean;
  48307. /**
  48308. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48309. */
  48310. protected _invertNormalMapY: boolean;
  48311. /**
  48312. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48313. */
  48314. protected _twoSidedLighting: boolean;
  48315. /**
  48316. * Defines the alpha limits in alpha test mode.
  48317. */
  48318. protected _alphaCutOff: number;
  48319. /**
  48320. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48321. */
  48322. protected _forceAlphaTest: boolean;
  48323. /**
  48324. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48325. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48326. */
  48327. protected _useAlphaFresnel: boolean;
  48328. /**
  48329. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48330. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48331. */
  48332. protected _useLinearAlphaFresnel: boolean;
  48333. /**
  48334. * The transparency mode of the material.
  48335. */
  48336. protected _transparencyMode: Nullable<number>;
  48337. /**
  48338. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48339. * from cos thetav and roughness:
  48340. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48341. */
  48342. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48343. /**
  48344. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48345. */
  48346. protected _forceIrradianceInFragment: boolean;
  48347. /**
  48348. * Force normal to face away from face.
  48349. */
  48350. protected _forceNormalForward: boolean;
  48351. /**
  48352. * Enables specular anti aliasing in the PBR shader.
  48353. * It will both interacts on the Geometry for analytical and IBL lighting.
  48354. * It also prefilter the roughness map based on the bump values.
  48355. */
  48356. protected _enableSpecularAntiAliasing: boolean;
  48357. /**
  48358. * Default configuration related to image processing available in the PBR Material.
  48359. */
  48360. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48361. /**
  48362. * Keep track of the image processing observer to allow dispose and replace.
  48363. */
  48364. private _imageProcessingObserver;
  48365. /**
  48366. * Attaches a new image processing configuration to the PBR Material.
  48367. * @param configuration
  48368. */
  48369. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48370. /**
  48371. * Stores the available render targets.
  48372. */
  48373. private _renderTargets;
  48374. /**
  48375. * Sets the global ambient color for the material used in lighting calculations.
  48376. */
  48377. private _globalAmbientColor;
  48378. /**
  48379. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48380. */
  48381. private _useLogarithmicDepth;
  48382. /**
  48383. * If set to true, no lighting calculations will be applied.
  48384. */
  48385. private _unlit;
  48386. private _debugMode;
  48387. /**
  48388. * @hidden
  48389. * This is reserved for the inspector.
  48390. * Defines the material debug mode.
  48391. * It helps seeing only some components of the material while troubleshooting.
  48392. */
  48393. debugMode: number;
  48394. /**
  48395. * @hidden
  48396. * This is reserved for the inspector.
  48397. * Specify from where on screen the debug mode should start.
  48398. * The value goes from -1 (full screen) to 1 (not visible)
  48399. * It helps with side by side comparison against the final render
  48400. * This defaults to -1
  48401. */
  48402. private debugLimit;
  48403. /**
  48404. * @hidden
  48405. * This is reserved for the inspector.
  48406. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48407. * You can use the factor to better multiply the final value.
  48408. */
  48409. private debugFactor;
  48410. /**
  48411. * Defines the clear coat layer parameters for the material.
  48412. */
  48413. readonly clearCoat: PBRClearCoatConfiguration;
  48414. /**
  48415. * Defines the anisotropic parameters for the material.
  48416. */
  48417. readonly anisotropy: PBRAnisotropicConfiguration;
  48418. /**
  48419. * Defines the BRDF parameters for the material.
  48420. */
  48421. readonly brdf: PBRBRDFConfiguration;
  48422. /**
  48423. * Defines the Sheen parameters for the material.
  48424. */
  48425. readonly sheen: PBRSheenConfiguration;
  48426. /**
  48427. * Defines the SubSurface parameters for the material.
  48428. */
  48429. readonly subSurface: PBRSubSurfaceConfiguration;
  48430. /**
  48431. * Custom callback helping to override the default shader used in the material.
  48432. */
  48433. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48434. /**
  48435. * Instantiates a new PBRMaterial instance.
  48436. *
  48437. * @param name The material name
  48438. * @param scene The scene the material will be use in.
  48439. */
  48440. constructor(name: string, scene: Scene);
  48441. /**
  48442. * Gets a boolean indicating that current material needs to register RTT
  48443. */
  48444. readonly hasRenderTargetTextures: boolean;
  48445. /**
  48446. * Gets the name of the material class.
  48447. */
  48448. getClassName(): string;
  48449. /**
  48450. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48451. */
  48452. /**
  48453. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48454. */
  48455. useLogarithmicDepth: boolean;
  48456. /**
  48457. * Gets the current transparency mode.
  48458. */
  48459. /**
  48460. * Sets the transparency mode of the material.
  48461. *
  48462. * | Value | Type | Description |
  48463. * | ----- | ----------------------------------- | ----------- |
  48464. * | 0 | OPAQUE | |
  48465. * | 1 | ALPHATEST | |
  48466. * | 2 | ALPHABLEND | |
  48467. * | 3 | ALPHATESTANDBLEND | |
  48468. *
  48469. */
  48470. transparencyMode: Nullable<number>;
  48471. /**
  48472. * Returns true if alpha blending should be disabled.
  48473. */
  48474. private readonly _disableAlphaBlending;
  48475. /**
  48476. * Specifies whether or not this material should be rendered in alpha blend mode.
  48477. */
  48478. needAlphaBlending(): boolean;
  48479. /**
  48480. * Specifies if the mesh will require alpha blending.
  48481. * @param mesh - BJS mesh.
  48482. */
  48483. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48484. /**
  48485. * Specifies whether or not this material should be rendered in alpha test mode.
  48486. */
  48487. needAlphaTesting(): boolean;
  48488. /**
  48489. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48490. */
  48491. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48492. /**
  48493. * Gets the texture used for the alpha test.
  48494. */
  48495. getAlphaTestTexture(): Nullable<BaseTexture>;
  48496. /**
  48497. * Specifies that the submesh is ready to be used.
  48498. * @param mesh - BJS mesh.
  48499. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48500. * @param useInstances - Specifies that instances should be used.
  48501. * @returns - boolean indicating that the submesh is ready or not.
  48502. */
  48503. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48504. /**
  48505. * Specifies if the material uses metallic roughness workflow.
  48506. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48507. */
  48508. isMetallicWorkflow(): boolean;
  48509. private _prepareEffect;
  48510. private _prepareDefines;
  48511. /**
  48512. * Force shader compilation
  48513. */
  48514. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48515. clipPlane: boolean;
  48516. }>): void;
  48517. /**
  48518. * Initializes the uniform buffer layout for the shader.
  48519. */
  48520. buildUniformLayout(): void;
  48521. /**
  48522. * Unbinds the material from the mesh
  48523. */
  48524. unbind(): void;
  48525. /**
  48526. * Binds the submesh data.
  48527. * @param world - The world matrix.
  48528. * @param mesh - The BJS mesh.
  48529. * @param subMesh - A submesh of the BJS mesh.
  48530. */
  48531. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48532. /**
  48533. * Returns the animatable textures.
  48534. * @returns - Array of animatable textures.
  48535. */
  48536. getAnimatables(): IAnimatable[];
  48537. /**
  48538. * Returns the texture used for reflections.
  48539. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48540. */
  48541. private _getReflectionTexture;
  48542. /**
  48543. * Returns an array of the actively used textures.
  48544. * @returns - Array of BaseTextures
  48545. */
  48546. getActiveTextures(): BaseTexture[];
  48547. /**
  48548. * Checks to see if a texture is used in the material.
  48549. * @param texture - Base texture to use.
  48550. * @returns - Boolean specifying if a texture is used in the material.
  48551. */
  48552. hasTexture(texture: BaseTexture): boolean;
  48553. /**
  48554. * Disposes the resources of the material.
  48555. * @param forceDisposeEffect - Forces the disposal of effects.
  48556. * @param forceDisposeTextures - Forces the disposal of all textures.
  48557. */
  48558. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48559. }
  48560. }
  48561. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48562. import { Nullable } from "babylonjs/types";
  48563. import { Scene } from "babylonjs/scene";
  48564. import { Color3 } from "babylonjs/Maths/math.color";
  48565. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48566. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48568. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48569. /**
  48570. * The Physically based material of BJS.
  48571. *
  48572. * This offers the main features of a standard PBR material.
  48573. * For more information, please refer to the documentation :
  48574. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48575. */
  48576. export class PBRMaterial extends PBRBaseMaterial {
  48577. /**
  48578. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48579. */
  48580. static readonly PBRMATERIAL_OPAQUE: number;
  48581. /**
  48582. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48583. */
  48584. static readonly PBRMATERIAL_ALPHATEST: number;
  48585. /**
  48586. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48587. */
  48588. static readonly PBRMATERIAL_ALPHABLEND: number;
  48589. /**
  48590. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48591. * They are also discarded below the alpha cutoff threshold to improve performances.
  48592. */
  48593. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48594. /**
  48595. * Defines the default value of how much AO map is occluding the analytical lights
  48596. * (point spot...).
  48597. */
  48598. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48599. /**
  48600. * Intensity of the direct lights e.g. the four lights available in your scene.
  48601. * This impacts both the direct diffuse and specular highlights.
  48602. */
  48603. directIntensity: number;
  48604. /**
  48605. * Intensity of the emissive part of the material.
  48606. * This helps controlling the emissive effect without modifying the emissive color.
  48607. */
  48608. emissiveIntensity: number;
  48609. /**
  48610. * Intensity of the environment e.g. how much the environment will light the object
  48611. * either through harmonics for rough material or through the refelction for shiny ones.
  48612. */
  48613. environmentIntensity: number;
  48614. /**
  48615. * This is a special control allowing the reduction of the specular highlights coming from the
  48616. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48617. */
  48618. specularIntensity: number;
  48619. /**
  48620. * Debug Control allowing disabling the bump map on this material.
  48621. */
  48622. disableBumpMap: boolean;
  48623. /**
  48624. * AKA Diffuse Texture in standard nomenclature.
  48625. */
  48626. albedoTexture: BaseTexture;
  48627. /**
  48628. * AKA Occlusion Texture in other nomenclature.
  48629. */
  48630. ambientTexture: BaseTexture;
  48631. /**
  48632. * AKA Occlusion Texture Intensity in other nomenclature.
  48633. */
  48634. ambientTextureStrength: number;
  48635. /**
  48636. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48637. * 1 means it completely occludes it
  48638. * 0 mean it has no impact
  48639. */
  48640. ambientTextureImpactOnAnalyticalLights: number;
  48641. /**
  48642. * Stores the alpha values in a texture.
  48643. */
  48644. opacityTexture: BaseTexture;
  48645. /**
  48646. * Stores the reflection values in a texture.
  48647. */
  48648. reflectionTexture: Nullable<BaseTexture>;
  48649. /**
  48650. * Stores the emissive values in a texture.
  48651. */
  48652. emissiveTexture: BaseTexture;
  48653. /**
  48654. * AKA Specular texture in other nomenclature.
  48655. */
  48656. reflectivityTexture: BaseTexture;
  48657. /**
  48658. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48659. */
  48660. metallicTexture: BaseTexture;
  48661. /**
  48662. * Specifies the metallic scalar of the metallic/roughness workflow.
  48663. * Can also be used to scale the metalness values of the metallic texture.
  48664. */
  48665. metallic: Nullable<number>;
  48666. /**
  48667. * Specifies the roughness scalar of the metallic/roughness workflow.
  48668. * Can also be used to scale the roughness values of the metallic texture.
  48669. */
  48670. roughness: Nullable<number>;
  48671. /**
  48672. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48673. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48674. */
  48675. microSurfaceTexture: BaseTexture;
  48676. /**
  48677. * Stores surface normal data used to displace a mesh in a texture.
  48678. */
  48679. bumpTexture: BaseTexture;
  48680. /**
  48681. * Stores the pre-calculated light information of a mesh in a texture.
  48682. */
  48683. lightmapTexture: BaseTexture;
  48684. /**
  48685. * Stores the refracted light information in a texture.
  48686. */
  48687. refractionTexture: Nullable<BaseTexture>;
  48688. /**
  48689. * The color of a material in ambient lighting.
  48690. */
  48691. ambientColor: Color3;
  48692. /**
  48693. * AKA Diffuse Color in other nomenclature.
  48694. */
  48695. albedoColor: Color3;
  48696. /**
  48697. * AKA Specular Color in other nomenclature.
  48698. */
  48699. reflectivityColor: Color3;
  48700. /**
  48701. * The color reflected from the material.
  48702. */
  48703. reflectionColor: Color3;
  48704. /**
  48705. * The color emitted from the material.
  48706. */
  48707. emissiveColor: Color3;
  48708. /**
  48709. * AKA Glossiness in other nomenclature.
  48710. */
  48711. microSurface: number;
  48712. /**
  48713. * source material index of refraction (IOR)' / 'destination material IOR.
  48714. */
  48715. indexOfRefraction: number;
  48716. /**
  48717. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48718. */
  48719. invertRefractionY: boolean;
  48720. /**
  48721. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48722. * Materials half opaque for instance using refraction could benefit from this control.
  48723. */
  48724. linkRefractionWithTransparency: boolean;
  48725. /**
  48726. * If true, the light map contains occlusion information instead of lighting info.
  48727. */
  48728. useLightmapAsShadowmap: boolean;
  48729. /**
  48730. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48731. */
  48732. useAlphaFromAlbedoTexture: boolean;
  48733. /**
  48734. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48735. */
  48736. forceAlphaTest: boolean;
  48737. /**
  48738. * Defines the alpha limits in alpha test mode.
  48739. */
  48740. alphaCutOff: number;
  48741. /**
  48742. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48743. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48744. */
  48745. useSpecularOverAlpha: boolean;
  48746. /**
  48747. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48748. */
  48749. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48750. /**
  48751. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48752. */
  48753. useRoughnessFromMetallicTextureAlpha: boolean;
  48754. /**
  48755. * Specifies if the metallic texture contains the roughness information in its green channel.
  48756. */
  48757. useRoughnessFromMetallicTextureGreen: boolean;
  48758. /**
  48759. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48760. */
  48761. useMetallnessFromMetallicTextureBlue: boolean;
  48762. /**
  48763. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48764. */
  48765. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48766. /**
  48767. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48768. */
  48769. useAmbientInGrayScale: boolean;
  48770. /**
  48771. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48772. * The material will try to infer what glossiness each pixel should be.
  48773. */
  48774. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48775. /**
  48776. * BJS is using an harcoded light falloff based on a manually sets up range.
  48777. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48778. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48779. */
  48780. /**
  48781. * BJS is using an harcoded light falloff based on a manually sets up range.
  48782. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48783. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48784. */
  48785. usePhysicalLightFalloff: boolean;
  48786. /**
  48787. * In order to support the falloff compatibility with gltf, a special mode has been added
  48788. * to reproduce the gltf light falloff.
  48789. */
  48790. /**
  48791. * In order to support the falloff compatibility with gltf, a special mode has been added
  48792. * to reproduce the gltf light falloff.
  48793. */
  48794. useGLTFLightFalloff: boolean;
  48795. /**
  48796. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48797. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48798. */
  48799. useRadianceOverAlpha: boolean;
  48800. /**
  48801. * Allows using an object space normal map (instead of tangent space).
  48802. */
  48803. useObjectSpaceNormalMap: boolean;
  48804. /**
  48805. * Allows using the bump map in parallax mode.
  48806. */
  48807. useParallax: boolean;
  48808. /**
  48809. * Allows using the bump map in parallax occlusion mode.
  48810. */
  48811. useParallaxOcclusion: boolean;
  48812. /**
  48813. * Controls the scale bias of the parallax mode.
  48814. */
  48815. parallaxScaleBias: number;
  48816. /**
  48817. * If sets to true, disables all the lights affecting the material.
  48818. */
  48819. disableLighting: boolean;
  48820. /**
  48821. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48822. */
  48823. forceIrradianceInFragment: boolean;
  48824. /**
  48825. * Number of Simultaneous lights allowed on the material.
  48826. */
  48827. maxSimultaneousLights: number;
  48828. /**
  48829. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48830. */
  48831. invertNormalMapX: boolean;
  48832. /**
  48833. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48834. */
  48835. invertNormalMapY: boolean;
  48836. /**
  48837. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48838. */
  48839. twoSidedLighting: boolean;
  48840. /**
  48841. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48842. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48843. */
  48844. useAlphaFresnel: boolean;
  48845. /**
  48846. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48847. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48848. */
  48849. useLinearAlphaFresnel: boolean;
  48850. /**
  48851. * Let user defines the brdf lookup texture used for IBL.
  48852. * A default 8bit version is embedded but you could point at :
  48853. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48854. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48855. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48856. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48857. */
  48858. environmentBRDFTexture: Nullable<BaseTexture>;
  48859. /**
  48860. * Force normal to face away from face.
  48861. */
  48862. forceNormalForward: boolean;
  48863. /**
  48864. * Enables specular anti aliasing in the PBR shader.
  48865. * It will both interacts on the Geometry for analytical and IBL lighting.
  48866. * It also prefilter the roughness map based on the bump values.
  48867. */
  48868. enableSpecularAntiAliasing: boolean;
  48869. /**
  48870. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48871. * makes the reflect vector face the model (under horizon).
  48872. */
  48873. useHorizonOcclusion: boolean;
  48874. /**
  48875. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48876. * too much the area relying on ambient texture to define their ambient occlusion.
  48877. */
  48878. useRadianceOcclusion: boolean;
  48879. /**
  48880. * If set to true, no lighting calculations will be applied.
  48881. */
  48882. unlit: boolean;
  48883. /**
  48884. * Gets the image processing configuration used either in this material.
  48885. */
  48886. /**
  48887. * Sets the Default image processing configuration used either in the this material.
  48888. *
  48889. * If sets to null, the scene one is in use.
  48890. */
  48891. imageProcessingConfiguration: ImageProcessingConfiguration;
  48892. /**
  48893. * Gets wether the color curves effect is enabled.
  48894. */
  48895. /**
  48896. * Sets wether the color curves effect is enabled.
  48897. */
  48898. cameraColorCurvesEnabled: boolean;
  48899. /**
  48900. * Gets wether the color grading effect is enabled.
  48901. */
  48902. /**
  48903. * Gets wether the color grading effect is enabled.
  48904. */
  48905. cameraColorGradingEnabled: boolean;
  48906. /**
  48907. * Gets wether tonemapping is enabled or not.
  48908. */
  48909. /**
  48910. * Sets wether tonemapping is enabled or not
  48911. */
  48912. cameraToneMappingEnabled: boolean;
  48913. /**
  48914. * The camera exposure used on this material.
  48915. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48916. * This corresponds to a photographic exposure.
  48917. */
  48918. /**
  48919. * The camera exposure used on this material.
  48920. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48921. * This corresponds to a photographic exposure.
  48922. */
  48923. cameraExposure: number;
  48924. /**
  48925. * Gets The camera contrast used on this material.
  48926. */
  48927. /**
  48928. * Sets The camera contrast used on this material.
  48929. */
  48930. cameraContrast: number;
  48931. /**
  48932. * Gets the Color Grading 2D Lookup Texture.
  48933. */
  48934. /**
  48935. * Sets the Color Grading 2D Lookup Texture.
  48936. */
  48937. cameraColorGradingTexture: Nullable<BaseTexture>;
  48938. /**
  48939. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48940. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48941. * 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;
  48942. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48943. */
  48944. /**
  48945. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48946. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48947. * 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;
  48948. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48949. */
  48950. cameraColorCurves: Nullable<ColorCurves>;
  48951. /**
  48952. * Instantiates a new PBRMaterial instance.
  48953. *
  48954. * @param name The material name
  48955. * @param scene The scene the material will be use in.
  48956. */
  48957. constructor(name: string, scene: Scene);
  48958. /**
  48959. * Returns the name of this material class.
  48960. */
  48961. getClassName(): string;
  48962. /**
  48963. * Makes a duplicate of the current material.
  48964. * @param name - name to use for the new material.
  48965. */
  48966. clone(name: string): PBRMaterial;
  48967. /**
  48968. * Serializes this PBR Material.
  48969. * @returns - An object with the serialized material.
  48970. */
  48971. serialize(): any;
  48972. /**
  48973. * Parses a PBR Material from a serialized object.
  48974. * @param source - Serialized object.
  48975. * @param scene - BJS scene instance.
  48976. * @param rootUrl - url for the scene object
  48977. * @returns - PBRMaterial
  48978. */
  48979. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48980. }
  48981. }
  48982. declare module "babylonjs/Misc/dds" {
  48983. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48984. import { Engine } from "babylonjs/Engines/engine";
  48985. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48986. import { Nullable } from "babylonjs/types";
  48987. import { Scene } from "babylonjs/scene";
  48988. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48989. /**
  48990. * Direct draw surface info
  48991. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48992. */
  48993. export interface DDSInfo {
  48994. /**
  48995. * Width of the texture
  48996. */
  48997. width: number;
  48998. /**
  48999. * Width of the texture
  49000. */
  49001. height: number;
  49002. /**
  49003. * Number of Mipmaps for the texture
  49004. * @see https://en.wikipedia.org/wiki/Mipmap
  49005. */
  49006. mipmapCount: number;
  49007. /**
  49008. * If the textures format is a known fourCC format
  49009. * @see https://www.fourcc.org/
  49010. */
  49011. isFourCC: boolean;
  49012. /**
  49013. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49014. */
  49015. isRGB: boolean;
  49016. /**
  49017. * If the texture is a lumincance format
  49018. */
  49019. isLuminance: boolean;
  49020. /**
  49021. * If this is a cube texture
  49022. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49023. */
  49024. isCube: boolean;
  49025. /**
  49026. * If the texture is a compressed format eg. FOURCC_DXT1
  49027. */
  49028. isCompressed: boolean;
  49029. /**
  49030. * The dxgiFormat of the texture
  49031. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49032. */
  49033. dxgiFormat: number;
  49034. /**
  49035. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49036. */
  49037. textureType: number;
  49038. /**
  49039. * Sphericle polynomial created for the dds texture
  49040. */
  49041. sphericalPolynomial?: SphericalPolynomial;
  49042. }
  49043. /**
  49044. * Class used to provide DDS decompression tools
  49045. */
  49046. export class DDSTools {
  49047. /**
  49048. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49049. */
  49050. static StoreLODInAlphaChannel: boolean;
  49051. /**
  49052. * Gets DDS information from an array buffer
  49053. * @param arrayBuffer defines the array buffer to read data from
  49054. * @returns the DDS information
  49055. */
  49056. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49057. private static _FloatView;
  49058. private static _Int32View;
  49059. private static _ToHalfFloat;
  49060. private static _FromHalfFloat;
  49061. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49062. private static _GetHalfFloatRGBAArrayBuffer;
  49063. private static _GetFloatRGBAArrayBuffer;
  49064. private static _GetFloatAsUIntRGBAArrayBuffer;
  49065. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49066. private static _GetRGBAArrayBuffer;
  49067. private static _ExtractLongWordOrder;
  49068. private static _GetRGBArrayBuffer;
  49069. private static _GetLuminanceArrayBuffer;
  49070. /**
  49071. * Uploads DDS Levels to a Babylon Texture
  49072. * @hidden
  49073. */
  49074. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49075. }
  49076. module "babylonjs/Engines/engine" {
  49077. interface Engine {
  49078. /**
  49079. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49080. * @param rootUrl defines the url where the file to load is located
  49081. * @param scene defines the current scene
  49082. * @param lodScale defines scale to apply to the mip map selection
  49083. * @param lodOffset defines offset to apply to the mip map selection
  49084. * @param onLoad defines an optional callback raised when the texture is loaded
  49085. * @param onError defines an optional callback raised if there is an issue to load the texture
  49086. * @param format defines the format of the data
  49087. * @param forcedExtension defines the extension to use to pick the right loader
  49088. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49089. * @returns the cube texture as an InternalTexture
  49090. */
  49091. 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;
  49092. }
  49093. }
  49094. }
  49095. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49096. import { Nullable } from "babylonjs/types";
  49097. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49098. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49099. /**
  49100. * Implementation of the DDS Texture Loader.
  49101. * @hidden
  49102. */
  49103. export class _DDSTextureLoader implements IInternalTextureLoader {
  49104. /**
  49105. * Defines wether the loader supports cascade loading the different faces.
  49106. */
  49107. readonly supportCascades: boolean;
  49108. /**
  49109. * This returns if the loader support the current file information.
  49110. * @param extension defines the file extension of the file being loaded
  49111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49112. * @param fallback defines the fallback internal texture if any
  49113. * @param isBase64 defines whether the texture is encoded as a base64
  49114. * @param isBuffer defines whether the texture data are stored as a buffer
  49115. * @returns true if the loader can load the specified file
  49116. */
  49117. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49118. /**
  49119. * Transform the url before loading if required.
  49120. * @param rootUrl the url of the texture
  49121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49122. * @returns the transformed texture
  49123. */
  49124. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49125. /**
  49126. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49127. * @param rootUrl the url of the texture
  49128. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49129. * @returns the fallback texture
  49130. */
  49131. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49132. /**
  49133. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49134. * @param data contains the texture data
  49135. * @param texture defines the BabylonJS internal texture
  49136. * @param createPolynomials will be true if polynomials have been requested
  49137. * @param onLoad defines the callback to trigger once the texture is ready
  49138. * @param onError defines the callback to trigger in case of error
  49139. */
  49140. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49141. /**
  49142. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49143. * @param data contains the texture data
  49144. * @param texture defines the BabylonJS internal texture
  49145. * @param callback defines the method to call once ready to upload
  49146. */
  49147. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49148. }
  49149. }
  49150. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49151. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49152. /** @hidden */
  49153. export var rgbdEncodePixelShader: {
  49154. name: string;
  49155. shader: string;
  49156. };
  49157. }
  49158. declare module "babylonjs/Misc/environmentTextureTools" {
  49159. import { Nullable } from "babylonjs/types";
  49160. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49162. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49163. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49164. import "babylonjs/Shaders/rgbdEncode.fragment";
  49165. import "babylonjs/Shaders/rgbdDecode.fragment";
  49166. /**
  49167. * Raw texture data and descriptor sufficient for WebGL texture upload
  49168. */
  49169. export interface EnvironmentTextureInfo {
  49170. /**
  49171. * Version of the environment map
  49172. */
  49173. version: number;
  49174. /**
  49175. * Width of image
  49176. */
  49177. width: number;
  49178. /**
  49179. * Irradiance information stored in the file.
  49180. */
  49181. irradiance: any;
  49182. /**
  49183. * Specular information stored in the file.
  49184. */
  49185. specular: any;
  49186. }
  49187. /**
  49188. * Sets of helpers addressing the serialization and deserialization of environment texture
  49189. * stored in a BabylonJS env file.
  49190. * Those files are usually stored as .env files.
  49191. */
  49192. export class EnvironmentTextureTools {
  49193. /**
  49194. * Magic number identifying the env file.
  49195. */
  49196. private static _MagicBytes;
  49197. /**
  49198. * Gets the environment info from an env file.
  49199. * @param data The array buffer containing the .env bytes.
  49200. * @returns the environment file info (the json header) if successfully parsed.
  49201. */
  49202. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49203. /**
  49204. * Creates an environment texture from a loaded cube texture.
  49205. * @param texture defines the cube texture to convert in env file
  49206. * @return a promise containing the environment data if succesfull.
  49207. */
  49208. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49209. /**
  49210. * Creates a JSON representation of the spherical data.
  49211. * @param texture defines the texture containing the polynomials
  49212. * @return the JSON representation of the spherical info
  49213. */
  49214. private static _CreateEnvTextureIrradiance;
  49215. /**
  49216. * Uploads the texture info contained in the env file to the GPU.
  49217. * @param texture defines the internal texture to upload to
  49218. * @param arrayBuffer defines the buffer cotaining the data to load
  49219. * @param info defines the texture info retrieved through the GetEnvInfo method
  49220. * @returns a promise
  49221. */
  49222. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49223. /**
  49224. * Uploads the levels of image data to the GPU.
  49225. * @param texture defines the internal texture to upload to
  49226. * @param imageData defines the array buffer views of image data [mipmap][face]
  49227. * @returns a promise
  49228. */
  49229. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49230. /**
  49231. * Uploads spherical polynomials information to the texture.
  49232. * @param texture defines the texture we are trying to upload the information to
  49233. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49234. */
  49235. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49236. /** @hidden */
  49237. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49238. }
  49239. }
  49240. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49241. import { Nullable } from "babylonjs/types";
  49242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49243. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49244. /**
  49245. * Implementation of the ENV Texture Loader.
  49246. * @hidden
  49247. */
  49248. export class _ENVTextureLoader implements IInternalTextureLoader {
  49249. /**
  49250. * Defines wether the loader supports cascade loading the different faces.
  49251. */
  49252. readonly supportCascades: boolean;
  49253. /**
  49254. * This returns if the loader support the current file information.
  49255. * @param extension defines the file extension of the file being loaded
  49256. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49257. * @param fallback defines the fallback internal texture if any
  49258. * @param isBase64 defines whether the texture is encoded as a base64
  49259. * @param isBuffer defines whether the texture data are stored as a buffer
  49260. * @returns true if the loader can load the specified file
  49261. */
  49262. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49263. /**
  49264. * Transform the url before loading if required.
  49265. * @param rootUrl the url of the texture
  49266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49267. * @returns the transformed texture
  49268. */
  49269. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49270. /**
  49271. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49272. * @param rootUrl the url of the texture
  49273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49274. * @returns the fallback texture
  49275. */
  49276. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49277. /**
  49278. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49279. * @param data contains the texture data
  49280. * @param texture defines the BabylonJS internal texture
  49281. * @param createPolynomials will be true if polynomials have been requested
  49282. * @param onLoad defines the callback to trigger once the texture is ready
  49283. * @param onError defines the callback to trigger in case of error
  49284. */
  49285. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49286. /**
  49287. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49288. * @param data contains the texture data
  49289. * @param texture defines the BabylonJS internal texture
  49290. * @param callback defines the method to call once ready to upload
  49291. */
  49292. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49293. }
  49294. }
  49295. declare module "babylonjs/Misc/khronosTextureContainer" {
  49296. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49297. /**
  49298. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49299. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49300. */
  49301. export class KhronosTextureContainer {
  49302. /** contents of the KTX container file */
  49303. arrayBuffer: any;
  49304. private static HEADER_LEN;
  49305. private static COMPRESSED_2D;
  49306. private static COMPRESSED_3D;
  49307. private static TEX_2D;
  49308. private static TEX_3D;
  49309. /**
  49310. * Gets the openGL type
  49311. */
  49312. glType: number;
  49313. /**
  49314. * Gets the openGL type size
  49315. */
  49316. glTypeSize: number;
  49317. /**
  49318. * Gets the openGL format
  49319. */
  49320. glFormat: number;
  49321. /**
  49322. * Gets the openGL internal format
  49323. */
  49324. glInternalFormat: number;
  49325. /**
  49326. * Gets the base internal format
  49327. */
  49328. glBaseInternalFormat: number;
  49329. /**
  49330. * Gets image width in pixel
  49331. */
  49332. pixelWidth: number;
  49333. /**
  49334. * Gets image height in pixel
  49335. */
  49336. pixelHeight: number;
  49337. /**
  49338. * Gets image depth in pixels
  49339. */
  49340. pixelDepth: number;
  49341. /**
  49342. * Gets the number of array elements
  49343. */
  49344. numberOfArrayElements: number;
  49345. /**
  49346. * Gets the number of faces
  49347. */
  49348. numberOfFaces: number;
  49349. /**
  49350. * Gets the number of mipmap levels
  49351. */
  49352. numberOfMipmapLevels: number;
  49353. /**
  49354. * Gets the bytes of key value data
  49355. */
  49356. bytesOfKeyValueData: number;
  49357. /**
  49358. * Gets the load type
  49359. */
  49360. loadType: number;
  49361. /**
  49362. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49363. */
  49364. isInvalid: boolean;
  49365. /**
  49366. * Creates a new KhronosTextureContainer
  49367. * @param arrayBuffer contents of the KTX container file
  49368. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49369. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49370. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49371. */
  49372. constructor(
  49373. /** contents of the KTX container file */
  49374. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49375. /**
  49376. * Uploads KTX content to a Babylon Texture.
  49377. * It is assumed that the texture has already been created & is currently bound
  49378. * @hidden
  49379. */
  49380. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49381. private _upload2DCompressedLevels;
  49382. }
  49383. }
  49384. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49385. import { Nullable } from "babylonjs/types";
  49386. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49387. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49388. /**
  49389. * Implementation of the KTX Texture Loader.
  49390. * @hidden
  49391. */
  49392. export class _KTXTextureLoader implements IInternalTextureLoader {
  49393. /**
  49394. * Defines wether the loader supports cascade loading the different faces.
  49395. */
  49396. readonly supportCascades: boolean;
  49397. /**
  49398. * This returns if the loader support the current file information.
  49399. * @param extension defines the file extension of the file being loaded
  49400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49401. * @param fallback defines the fallback internal texture if any
  49402. * @param isBase64 defines whether the texture is encoded as a base64
  49403. * @param isBuffer defines whether the texture data are stored as a buffer
  49404. * @returns true if the loader can load the specified file
  49405. */
  49406. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49407. /**
  49408. * Transform the url before loading if required.
  49409. * @param rootUrl the url of the texture
  49410. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49411. * @returns the transformed texture
  49412. */
  49413. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49414. /**
  49415. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49416. * @param rootUrl the url of the texture
  49417. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49418. * @returns the fallback texture
  49419. */
  49420. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49421. /**
  49422. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49423. * @param data contains the texture data
  49424. * @param texture defines the BabylonJS internal texture
  49425. * @param createPolynomials will be true if polynomials have been requested
  49426. * @param onLoad defines the callback to trigger once the texture is ready
  49427. * @param onError defines the callback to trigger in case of error
  49428. */
  49429. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49430. /**
  49431. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49432. * @param data contains the texture data
  49433. * @param texture defines the BabylonJS internal texture
  49434. * @param callback defines the method to call once ready to upload
  49435. */
  49436. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49437. }
  49438. }
  49439. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49440. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49441. import { Scene } from "babylonjs/scene";
  49442. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49443. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49444. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49445. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49446. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49447. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49449. /**
  49450. * Options for the default xr helper
  49451. */
  49452. export class WebXRDefaultExperienceOptions {
  49453. /**
  49454. * Floor meshes that should be used for teleporting
  49455. */
  49456. floorMeshes: Array<AbstractMesh>;
  49457. }
  49458. /**
  49459. * Default experience which provides a similar setup to the previous webVRExperience
  49460. */
  49461. export class WebXRDefaultExperience {
  49462. /**
  49463. * Base experience
  49464. */
  49465. baseExperience: WebXRExperienceHelper;
  49466. /**
  49467. * Input experience extension
  49468. */
  49469. input: WebXRInput;
  49470. /**
  49471. * Loads the controller models
  49472. */
  49473. controllerModelLoader: WebXRControllerModelLoader;
  49474. /**
  49475. * Enables laser pointer and selection
  49476. */
  49477. pointerSelection: WebXRControllerPointerSelection;
  49478. /**
  49479. * Enables teleportation
  49480. */
  49481. teleportation: WebXRControllerTeleportation;
  49482. /**
  49483. * Enables ui for enetering/exiting xr
  49484. */
  49485. enterExitUI: WebXREnterExitUI;
  49486. /**
  49487. * Default output canvas xr should render to
  49488. */
  49489. outputCanvas: WebXRManagedOutputCanvas;
  49490. /**
  49491. * Creates the default xr experience
  49492. * @param scene scene
  49493. * @param options options for basic configuration
  49494. * @returns resulting WebXRDefaultExperience
  49495. */
  49496. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49497. private constructor();
  49498. /**
  49499. * DIsposes of the experience helper
  49500. */
  49501. dispose(): void;
  49502. }
  49503. }
  49504. declare module "babylonjs/Helpers/sceneHelpers" {
  49505. import { Nullable } from "babylonjs/types";
  49506. import { Mesh } from "babylonjs/Meshes/mesh";
  49507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49508. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49509. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49510. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49511. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49512. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49513. import "babylonjs/Meshes/Builders/boxBuilder";
  49514. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49515. /** @hidden */
  49516. export var _forceSceneHelpersToBundle: boolean;
  49517. module "babylonjs/scene" {
  49518. interface Scene {
  49519. /**
  49520. * Creates a default light for the scene.
  49521. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49522. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49523. */
  49524. createDefaultLight(replace?: boolean): void;
  49525. /**
  49526. * Creates a default camera for the scene.
  49527. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49528. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49529. * @param replace has default false, when true replaces the active camera in the scene
  49530. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49531. */
  49532. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49533. /**
  49534. * Creates a default camera and a default light.
  49535. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49536. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49537. * @param replace has the default false, when true replaces the active camera/light in the scene
  49538. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49539. */
  49540. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49541. /**
  49542. * Creates a new sky box
  49543. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49544. * @param environmentTexture defines the texture to use as environment texture
  49545. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49546. * @param scale defines the overall scale of the skybox
  49547. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49548. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49549. * @returns a new mesh holding the sky box
  49550. */
  49551. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49552. /**
  49553. * Creates a new environment
  49554. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49555. * @param options defines the options you can use to configure the environment
  49556. * @returns the new EnvironmentHelper
  49557. */
  49558. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49559. /**
  49560. * Creates a new VREXperienceHelper
  49561. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49562. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49563. * @returns a new VREXperienceHelper
  49564. */
  49565. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49566. /**
  49567. * Creates a new WebXRDefaultExperience
  49568. * @see http://doc.babylonjs.com/how_to/webxr
  49569. * @param options experience options
  49570. * @returns a promise for a new WebXRDefaultExperience
  49571. */
  49572. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49573. }
  49574. }
  49575. }
  49576. declare module "babylonjs/Helpers/videoDome" {
  49577. import { Scene } from "babylonjs/scene";
  49578. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49579. import { Mesh } from "babylonjs/Meshes/mesh";
  49580. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49581. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49582. import "babylonjs/Meshes/Builders/sphereBuilder";
  49583. /**
  49584. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49585. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49586. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49587. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49588. */
  49589. export class VideoDome extends TransformNode {
  49590. /**
  49591. * Define the video source as a Monoscopic panoramic 360 video.
  49592. */
  49593. static readonly MODE_MONOSCOPIC: number;
  49594. /**
  49595. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49596. */
  49597. static readonly MODE_TOPBOTTOM: number;
  49598. /**
  49599. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49600. */
  49601. static readonly MODE_SIDEBYSIDE: number;
  49602. private _useDirectMapping;
  49603. /**
  49604. * The video texture being displayed on the sphere
  49605. */
  49606. protected _videoTexture: VideoTexture;
  49607. /**
  49608. * Gets the video texture being displayed on the sphere
  49609. */
  49610. readonly videoTexture: VideoTexture;
  49611. /**
  49612. * The skybox material
  49613. */
  49614. protected _material: BackgroundMaterial;
  49615. /**
  49616. * The surface used for the skybox
  49617. */
  49618. protected _mesh: Mesh;
  49619. /**
  49620. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49621. * Also see the options.resolution property.
  49622. */
  49623. fovMultiplier: number;
  49624. private _videoMode;
  49625. /**
  49626. * Gets or set the current video mode for the video. It can be:
  49627. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49628. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49629. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49630. */
  49631. videoMode: number;
  49632. /**
  49633. * Oberserver used in Stereoscopic VR Mode.
  49634. */
  49635. private _onBeforeCameraRenderObserver;
  49636. /**
  49637. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49638. * @param name Element's name, child elements will append suffixes for their own names.
  49639. * @param urlsOrVideo defines the url(s) or the video element to use
  49640. * @param options An object containing optional or exposed sub element properties
  49641. */
  49642. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49643. resolution?: number;
  49644. clickToPlay?: boolean;
  49645. autoPlay?: boolean;
  49646. loop?: boolean;
  49647. size?: number;
  49648. poster?: string;
  49649. faceForward?: boolean;
  49650. useDirectMapping?: boolean;
  49651. }, scene: Scene);
  49652. private _changeVideoMode;
  49653. /**
  49654. * Releases resources associated with this node.
  49655. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49656. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49657. */
  49658. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49659. }
  49660. }
  49661. declare module "babylonjs/Helpers/index" {
  49662. export * from "babylonjs/Helpers/environmentHelper";
  49663. export * from "babylonjs/Helpers/photoDome";
  49664. export * from "babylonjs/Helpers/sceneHelpers";
  49665. export * from "babylonjs/Helpers/videoDome";
  49666. }
  49667. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49668. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49669. import { IDisposable } from "babylonjs/scene";
  49670. import { Engine } from "babylonjs/Engines/engine";
  49671. /**
  49672. * This class can be used to get instrumentation data from a Babylon engine
  49673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49674. */
  49675. export class EngineInstrumentation implements IDisposable {
  49676. /**
  49677. * Define the instrumented engine.
  49678. */
  49679. engine: Engine;
  49680. private _captureGPUFrameTime;
  49681. private _gpuFrameTimeToken;
  49682. private _gpuFrameTime;
  49683. private _captureShaderCompilationTime;
  49684. private _shaderCompilationTime;
  49685. private _onBeginFrameObserver;
  49686. private _onEndFrameObserver;
  49687. private _onBeforeShaderCompilationObserver;
  49688. private _onAfterShaderCompilationObserver;
  49689. /**
  49690. * Gets the perf counter used for GPU frame time
  49691. */
  49692. readonly gpuFrameTimeCounter: PerfCounter;
  49693. /**
  49694. * Gets the GPU frame time capture status
  49695. */
  49696. /**
  49697. * Enable or disable the GPU frame time capture
  49698. */
  49699. captureGPUFrameTime: boolean;
  49700. /**
  49701. * Gets the perf counter used for shader compilation time
  49702. */
  49703. readonly shaderCompilationTimeCounter: PerfCounter;
  49704. /**
  49705. * Gets the shader compilation time capture status
  49706. */
  49707. /**
  49708. * Enable or disable the shader compilation time capture
  49709. */
  49710. captureShaderCompilationTime: boolean;
  49711. /**
  49712. * Instantiates a new engine instrumentation.
  49713. * This class can be used to get instrumentation data from a Babylon engine
  49714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49715. * @param engine Defines the engine to instrument
  49716. */
  49717. constructor(
  49718. /**
  49719. * Define the instrumented engine.
  49720. */
  49721. engine: Engine);
  49722. /**
  49723. * Dispose and release associated resources.
  49724. */
  49725. dispose(): void;
  49726. }
  49727. }
  49728. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49729. import { Scene, IDisposable } from "babylonjs/scene";
  49730. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49731. /**
  49732. * This class can be used to get instrumentation data from a Babylon engine
  49733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49734. */
  49735. export class SceneInstrumentation implements IDisposable {
  49736. /**
  49737. * Defines the scene to instrument
  49738. */
  49739. scene: Scene;
  49740. private _captureActiveMeshesEvaluationTime;
  49741. private _activeMeshesEvaluationTime;
  49742. private _captureRenderTargetsRenderTime;
  49743. private _renderTargetsRenderTime;
  49744. private _captureFrameTime;
  49745. private _frameTime;
  49746. private _captureRenderTime;
  49747. private _renderTime;
  49748. private _captureInterFrameTime;
  49749. private _interFrameTime;
  49750. private _captureParticlesRenderTime;
  49751. private _particlesRenderTime;
  49752. private _captureSpritesRenderTime;
  49753. private _spritesRenderTime;
  49754. private _capturePhysicsTime;
  49755. private _physicsTime;
  49756. private _captureAnimationsTime;
  49757. private _animationsTime;
  49758. private _captureCameraRenderTime;
  49759. private _cameraRenderTime;
  49760. private _onBeforeActiveMeshesEvaluationObserver;
  49761. private _onAfterActiveMeshesEvaluationObserver;
  49762. private _onBeforeRenderTargetsRenderObserver;
  49763. private _onAfterRenderTargetsRenderObserver;
  49764. private _onAfterRenderObserver;
  49765. private _onBeforeDrawPhaseObserver;
  49766. private _onAfterDrawPhaseObserver;
  49767. private _onBeforeAnimationsObserver;
  49768. private _onBeforeParticlesRenderingObserver;
  49769. private _onAfterParticlesRenderingObserver;
  49770. private _onBeforeSpritesRenderingObserver;
  49771. private _onAfterSpritesRenderingObserver;
  49772. private _onBeforePhysicsObserver;
  49773. private _onAfterPhysicsObserver;
  49774. private _onAfterAnimationsObserver;
  49775. private _onBeforeCameraRenderObserver;
  49776. private _onAfterCameraRenderObserver;
  49777. /**
  49778. * Gets the perf counter used for active meshes evaluation time
  49779. */
  49780. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49781. /**
  49782. * Gets the active meshes evaluation time capture status
  49783. */
  49784. /**
  49785. * Enable or disable the active meshes evaluation time capture
  49786. */
  49787. captureActiveMeshesEvaluationTime: boolean;
  49788. /**
  49789. * Gets the perf counter used for render targets render time
  49790. */
  49791. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49792. /**
  49793. * Gets the render targets render time capture status
  49794. */
  49795. /**
  49796. * Enable or disable the render targets render time capture
  49797. */
  49798. captureRenderTargetsRenderTime: boolean;
  49799. /**
  49800. * Gets the perf counter used for particles render time
  49801. */
  49802. readonly particlesRenderTimeCounter: PerfCounter;
  49803. /**
  49804. * Gets the particles render time capture status
  49805. */
  49806. /**
  49807. * Enable or disable the particles render time capture
  49808. */
  49809. captureParticlesRenderTime: boolean;
  49810. /**
  49811. * Gets the perf counter used for sprites render time
  49812. */
  49813. readonly spritesRenderTimeCounter: PerfCounter;
  49814. /**
  49815. * Gets the sprites render time capture status
  49816. */
  49817. /**
  49818. * Enable or disable the sprites render time capture
  49819. */
  49820. captureSpritesRenderTime: boolean;
  49821. /**
  49822. * Gets the perf counter used for physics time
  49823. */
  49824. readonly physicsTimeCounter: PerfCounter;
  49825. /**
  49826. * Gets the physics time capture status
  49827. */
  49828. /**
  49829. * Enable or disable the physics time capture
  49830. */
  49831. capturePhysicsTime: boolean;
  49832. /**
  49833. * Gets the perf counter used for animations time
  49834. */
  49835. readonly animationsTimeCounter: PerfCounter;
  49836. /**
  49837. * Gets the animations time capture status
  49838. */
  49839. /**
  49840. * Enable or disable the animations time capture
  49841. */
  49842. captureAnimationsTime: boolean;
  49843. /**
  49844. * Gets the perf counter used for frame time capture
  49845. */
  49846. readonly frameTimeCounter: PerfCounter;
  49847. /**
  49848. * Gets the frame time capture status
  49849. */
  49850. /**
  49851. * Enable or disable the frame time capture
  49852. */
  49853. captureFrameTime: boolean;
  49854. /**
  49855. * Gets the perf counter used for inter-frames time capture
  49856. */
  49857. readonly interFrameTimeCounter: PerfCounter;
  49858. /**
  49859. * Gets the inter-frames time capture status
  49860. */
  49861. /**
  49862. * Enable or disable the inter-frames time capture
  49863. */
  49864. captureInterFrameTime: boolean;
  49865. /**
  49866. * Gets the perf counter used for render time capture
  49867. */
  49868. readonly renderTimeCounter: PerfCounter;
  49869. /**
  49870. * Gets the render time capture status
  49871. */
  49872. /**
  49873. * Enable or disable the render time capture
  49874. */
  49875. captureRenderTime: boolean;
  49876. /**
  49877. * Gets the perf counter used for camera render time capture
  49878. */
  49879. readonly cameraRenderTimeCounter: PerfCounter;
  49880. /**
  49881. * Gets the camera render time capture status
  49882. */
  49883. /**
  49884. * Enable or disable the camera render time capture
  49885. */
  49886. captureCameraRenderTime: boolean;
  49887. /**
  49888. * Gets the perf counter used for draw calls
  49889. */
  49890. readonly drawCallsCounter: PerfCounter;
  49891. /**
  49892. * Instantiates a new scene instrumentation.
  49893. * This class can be used to get instrumentation data from a Babylon engine
  49894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49895. * @param scene Defines the scene to instrument
  49896. */
  49897. constructor(
  49898. /**
  49899. * Defines the scene to instrument
  49900. */
  49901. scene: Scene);
  49902. /**
  49903. * Dispose and release associated resources.
  49904. */
  49905. dispose(): void;
  49906. }
  49907. }
  49908. declare module "babylonjs/Instrumentation/index" {
  49909. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49910. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49911. export * from "babylonjs/Instrumentation/timeToken";
  49912. }
  49913. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49914. /** @hidden */
  49915. export var glowMapGenerationPixelShader: {
  49916. name: string;
  49917. shader: string;
  49918. };
  49919. }
  49920. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49921. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49922. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49924. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49925. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49926. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49927. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49928. /** @hidden */
  49929. export var glowMapGenerationVertexShader: {
  49930. name: string;
  49931. shader: string;
  49932. };
  49933. }
  49934. declare module "babylonjs/Layers/effectLayer" {
  49935. import { Observable } from "babylonjs/Misc/observable";
  49936. import { Nullable } from "babylonjs/types";
  49937. import { Camera } from "babylonjs/Cameras/camera";
  49938. import { Scene } from "babylonjs/scene";
  49939. import { ISize } from "babylonjs/Maths/math.size";
  49940. import { Color4 } from "babylonjs/Maths/math.color";
  49941. import { Engine } from "babylonjs/Engines/engine";
  49942. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49944. import { Mesh } from "babylonjs/Meshes/mesh";
  49945. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49946. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49947. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49948. import { Effect } from "babylonjs/Materials/effect";
  49949. import { Material } from "babylonjs/Materials/material";
  49950. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49951. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49952. /**
  49953. * Effect layer options. This helps customizing the behaviour
  49954. * of the effect layer.
  49955. */
  49956. export interface IEffectLayerOptions {
  49957. /**
  49958. * Multiplication factor apply to the canvas size to compute the render target size
  49959. * used to generated the objects (the smaller the faster).
  49960. */
  49961. mainTextureRatio: number;
  49962. /**
  49963. * Enforces a fixed size texture to ensure effect stability across devices.
  49964. */
  49965. mainTextureFixedSize?: number;
  49966. /**
  49967. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49968. */
  49969. alphaBlendingMode: number;
  49970. /**
  49971. * The camera attached to the layer.
  49972. */
  49973. camera: Nullable<Camera>;
  49974. /**
  49975. * The rendering group to draw the layer in.
  49976. */
  49977. renderingGroupId: number;
  49978. }
  49979. /**
  49980. * The effect layer Helps adding post process effect blended with the main pass.
  49981. *
  49982. * This can be for instance use to generate glow or higlight effects on the scene.
  49983. *
  49984. * The effect layer class can not be used directly and is intented to inherited from to be
  49985. * customized per effects.
  49986. */
  49987. export abstract class EffectLayer {
  49988. private _vertexBuffers;
  49989. private _indexBuffer;
  49990. private _cachedDefines;
  49991. private _effectLayerMapGenerationEffect;
  49992. private _effectLayerOptions;
  49993. private _mergeEffect;
  49994. protected _scene: Scene;
  49995. protected _engine: Engine;
  49996. protected _maxSize: number;
  49997. protected _mainTextureDesiredSize: ISize;
  49998. protected _mainTexture: RenderTargetTexture;
  49999. protected _shouldRender: boolean;
  50000. protected _postProcesses: PostProcess[];
  50001. protected _textures: BaseTexture[];
  50002. protected _emissiveTextureAndColor: {
  50003. texture: Nullable<BaseTexture>;
  50004. color: Color4;
  50005. };
  50006. /**
  50007. * The name of the layer
  50008. */
  50009. name: string;
  50010. /**
  50011. * The clear color of the texture used to generate the glow map.
  50012. */
  50013. neutralColor: Color4;
  50014. /**
  50015. * Specifies wether the highlight layer is enabled or not.
  50016. */
  50017. isEnabled: boolean;
  50018. /**
  50019. * Gets the camera attached to the layer.
  50020. */
  50021. readonly camera: Nullable<Camera>;
  50022. /**
  50023. * Gets the rendering group id the layer should render in.
  50024. */
  50025. renderingGroupId: number;
  50026. /**
  50027. * An event triggered when the effect layer has been disposed.
  50028. */
  50029. onDisposeObservable: Observable<EffectLayer>;
  50030. /**
  50031. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50032. */
  50033. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50034. /**
  50035. * An event triggered when the generated texture is being merged in the scene.
  50036. */
  50037. onBeforeComposeObservable: Observable<EffectLayer>;
  50038. /**
  50039. * An event triggered when the generated texture has been merged in the scene.
  50040. */
  50041. onAfterComposeObservable: Observable<EffectLayer>;
  50042. /**
  50043. * An event triggered when the efffect layer changes its size.
  50044. */
  50045. onSizeChangedObservable: Observable<EffectLayer>;
  50046. /** @hidden */
  50047. static _SceneComponentInitialization: (scene: Scene) => void;
  50048. /**
  50049. * Instantiates a new effect Layer and references it in the scene.
  50050. * @param name The name of the layer
  50051. * @param scene The scene to use the layer in
  50052. */
  50053. constructor(
  50054. /** The Friendly of the effect in the scene */
  50055. name: string, scene: Scene);
  50056. /**
  50057. * Get the effect name of the layer.
  50058. * @return The effect name
  50059. */
  50060. abstract getEffectName(): string;
  50061. /**
  50062. * Checks for the readiness of the element composing the layer.
  50063. * @param subMesh the mesh to check for
  50064. * @param useInstances specify wether or not to use instances to render the mesh
  50065. * @return true if ready otherwise, false
  50066. */
  50067. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50068. /**
  50069. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50070. * @returns true if the effect requires stencil during the main canvas render pass.
  50071. */
  50072. abstract needStencil(): boolean;
  50073. /**
  50074. * Create the merge effect. This is the shader use to blit the information back
  50075. * to the main canvas at the end of the scene rendering.
  50076. * @returns The effect containing the shader used to merge the effect on the main canvas
  50077. */
  50078. protected abstract _createMergeEffect(): Effect;
  50079. /**
  50080. * Creates the render target textures and post processes used in the effect layer.
  50081. */
  50082. protected abstract _createTextureAndPostProcesses(): void;
  50083. /**
  50084. * Implementation specific of rendering the generating effect on the main canvas.
  50085. * @param effect The effect used to render through
  50086. */
  50087. protected abstract _internalRender(effect: Effect): void;
  50088. /**
  50089. * Sets the required values for both the emissive texture and and the main color.
  50090. */
  50091. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50092. /**
  50093. * Free any resources and references associated to a mesh.
  50094. * Internal use
  50095. * @param mesh The mesh to free.
  50096. */
  50097. abstract _disposeMesh(mesh: Mesh): void;
  50098. /**
  50099. * Serializes this layer (Glow or Highlight for example)
  50100. * @returns a serialized layer object
  50101. */
  50102. abstract serialize?(): any;
  50103. /**
  50104. * Initializes the effect layer with the required options.
  50105. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50106. */
  50107. protected _init(options: Partial<IEffectLayerOptions>): void;
  50108. /**
  50109. * Generates the index buffer of the full screen quad blending to the main canvas.
  50110. */
  50111. private _generateIndexBuffer;
  50112. /**
  50113. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50114. */
  50115. private _generateVertexBuffer;
  50116. /**
  50117. * Sets the main texture desired size which is the closest power of two
  50118. * of the engine canvas size.
  50119. */
  50120. private _setMainTextureSize;
  50121. /**
  50122. * Creates the main texture for the effect layer.
  50123. */
  50124. protected _createMainTexture(): void;
  50125. /**
  50126. * Adds specific effects defines.
  50127. * @param defines The defines to add specifics to.
  50128. */
  50129. protected _addCustomEffectDefines(defines: string[]): void;
  50130. /**
  50131. * Checks for the readiness of the element composing the layer.
  50132. * @param subMesh the mesh to check for
  50133. * @param useInstances specify wether or not to use instances to render the mesh
  50134. * @param emissiveTexture the associated emissive texture used to generate the glow
  50135. * @return true if ready otherwise, false
  50136. */
  50137. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50138. /**
  50139. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50140. */
  50141. render(): void;
  50142. /**
  50143. * Determine if a given mesh will be used in the current effect.
  50144. * @param mesh mesh to test
  50145. * @returns true if the mesh will be used
  50146. */
  50147. hasMesh(mesh: AbstractMesh): boolean;
  50148. /**
  50149. * Returns true if the layer contains information to display, otherwise false.
  50150. * @returns true if the glow layer should be rendered
  50151. */
  50152. shouldRender(): boolean;
  50153. /**
  50154. * Returns true if the mesh should render, otherwise false.
  50155. * @param mesh The mesh to render
  50156. * @returns true if it should render otherwise false
  50157. */
  50158. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50159. /**
  50160. * Returns true if the mesh can be rendered, otherwise false.
  50161. * @param mesh The mesh to render
  50162. * @param material The material used on the mesh
  50163. * @returns true if it can be rendered otherwise false
  50164. */
  50165. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50166. /**
  50167. * Returns true if the mesh should render, otherwise false.
  50168. * @param mesh The mesh to render
  50169. * @returns true if it should render otherwise false
  50170. */
  50171. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50172. /**
  50173. * Renders the submesh passed in parameter to the generation map.
  50174. */
  50175. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50176. /**
  50177. * Rebuild the required buffers.
  50178. * @hidden Internal use only.
  50179. */
  50180. _rebuild(): void;
  50181. /**
  50182. * Dispose only the render target textures and post process.
  50183. */
  50184. private _disposeTextureAndPostProcesses;
  50185. /**
  50186. * Dispose the highlight layer and free resources.
  50187. */
  50188. dispose(): void;
  50189. /**
  50190. * Gets the class name of the effect layer
  50191. * @returns the string with the class name of the effect layer
  50192. */
  50193. getClassName(): string;
  50194. /**
  50195. * Creates an effect layer from parsed effect layer data
  50196. * @param parsedEffectLayer defines effect layer data
  50197. * @param scene defines the current scene
  50198. * @param rootUrl defines the root URL containing the effect layer information
  50199. * @returns a parsed effect Layer
  50200. */
  50201. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50202. }
  50203. }
  50204. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50205. import { Scene } from "babylonjs/scene";
  50206. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50207. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50208. import { AbstractScene } from "babylonjs/abstractScene";
  50209. module "babylonjs/abstractScene" {
  50210. interface AbstractScene {
  50211. /**
  50212. * The list of effect layers (highlights/glow) added to the scene
  50213. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50214. * @see http://doc.babylonjs.com/how_to/glow_layer
  50215. */
  50216. effectLayers: Array<EffectLayer>;
  50217. /**
  50218. * Removes the given effect layer from this scene.
  50219. * @param toRemove defines the effect layer to remove
  50220. * @returns the index of the removed effect layer
  50221. */
  50222. removeEffectLayer(toRemove: EffectLayer): number;
  50223. /**
  50224. * Adds the given effect layer to this scene
  50225. * @param newEffectLayer defines the effect layer to add
  50226. */
  50227. addEffectLayer(newEffectLayer: EffectLayer): void;
  50228. }
  50229. }
  50230. /**
  50231. * Defines the layer scene component responsible to manage any effect layers
  50232. * in a given scene.
  50233. */
  50234. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50235. /**
  50236. * The component name helpfull to identify the component in the list of scene components.
  50237. */
  50238. readonly name: string;
  50239. /**
  50240. * The scene the component belongs to.
  50241. */
  50242. scene: Scene;
  50243. private _engine;
  50244. private _renderEffects;
  50245. private _needStencil;
  50246. private _previousStencilState;
  50247. /**
  50248. * Creates a new instance of the component for the given scene
  50249. * @param scene Defines the scene to register the component in
  50250. */
  50251. constructor(scene: Scene);
  50252. /**
  50253. * Registers the component in a given scene
  50254. */
  50255. register(): void;
  50256. /**
  50257. * Rebuilds the elements related to this component in case of
  50258. * context lost for instance.
  50259. */
  50260. rebuild(): void;
  50261. /**
  50262. * Serializes the component data to the specified json object
  50263. * @param serializationObject The object to serialize to
  50264. */
  50265. serialize(serializationObject: any): void;
  50266. /**
  50267. * Adds all the elements from the container to the scene
  50268. * @param container the container holding the elements
  50269. */
  50270. addFromContainer(container: AbstractScene): void;
  50271. /**
  50272. * Removes all the elements in the container from the scene
  50273. * @param container contains the elements to remove
  50274. * @param dispose if the removed element should be disposed (default: false)
  50275. */
  50276. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50277. /**
  50278. * Disposes the component and the associated ressources.
  50279. */
  50280. dispose(): void;
  50281. private _isReadyForMesh;
  50282. private _renderMainTexture;
  50283. private _setStencil;
  50284. private _setStencilBack;
  50285. private _draw;
  50286. private _drawCamera;
  50287. private _drawRenderingGroup;
  50288. }
  50289. }
  50290. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50291. /** @hidden */
  50292. export var glowMapMergePixelShader: {
  50293. name: string;
  50294. shader: string;
  50295. };
  50296. }
  50297. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50298. /** @hidden */
  50299. export var glowMapMergeVertexShader: {
  50300. name: string;
  50301. shader: string;
  50302. };
  50303. }
  50304. declare module "babylonjs/Layers/glowLayer" {
  50305. import { Nullable } from "babylonjs/types";
  50306. import { Camera } from "babylonjs/Cameras/camera";
  50307. import { Scene } from "babylonjs/scene";
  50308. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50310. import { Mesh } from "babylonjs/Meshes/mesh";
  50311. import { Texture } from "babylonjs/Materials/Textures/texture";
  50312. import { Effect } from "babylonjs/Materials/effect";
  50313. import { Material } from "babylonjs/Materials/material";
  50314. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50315. import { Color4 } from "babylonjs/Maths/math.color";
  50316. import "babylonjs/Shaders/glowMapMerge.fragment";
  50317. import "babylonjs/Shaders/glowMapMerge.vertex";
  50318. import "babylonjs/Layers/effectLayerSceneComponent";
  50319. module "babylonjs/abstractScene" {
  50320. interface AbstractScene {
  50321. /**
  50322. * Return a the first highlight layer of the scene with a given name.
  50323. * @param name The name of the highlight layer to look for.
  50324. * @return The highlight layer if found otherwise null.
  50325. */
  50326. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50327. }
  50328. }
  50329. /**
  50330. * Glow layer options. This helps customizing the behaviour
  50331. * of the glow layer.
  50332. */
  50333. export interface IGlowLayerOptions {
  50334. /**
  50335. * Multiplication factor apply to the canvas size to compute the render target size
  50336. * used to generated the glowing objects (the smaller the faster).
  50337. */
  50338. mainTextureRatio: number;
  50339. /**
  50340. * Enforces a fixed size texture to ensure resize independant blur.
  50341. */
  50342. mainTextureFixedSize?: number;
  50343. /**
  50344. * How big is the kernel of the blur texture.
  50345. */
  50346. blurKernelSize: number;
  50347. /**
  50348. * The camera attached to the layer.
  50349. */
  50350. camera: Nullable<Camera>;
  50351. /**
  50352. * Enable MSAA by chosing the number of samples.
  50353. */
  50354. mainTextureSamples?: number;
  50355. /**
  50356. * The rendering group to draw the layer in.
  50357. */
  50358. renderingGroupId: number;
  50359. }
  50360. /**
  50361. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50362. *
  50363. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50364. * glowy meshes to your scene.
  50365. *
  50366. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50367. */
  50368. export class GlowLayer extends EffectLayer {
  50369. /**
  50370. * Effect Name of the layer.
  50371. */
  50372. static readonly EffectName: string;
  50373. /**
  50374. * The default blur kernel size used for the glow.
  50375. */
  50376. static DefaultBlurKernelSize: number;
  50377. /**
  50378. * The default texture size ratio used for the glow.
  50379. */
  50380. static DefaultTextureRatio: number;
  50381. /**
  50382. * Sets the kernel size of the blur.
  50383. */
  50384. /**
  50385. * Gets the kernel size of the blur.
  50386. */
  50387. blurKernelSize: number;
  50388. /**
  50389. * Sets the glow intensity.
  50390. */
  50391. /**
  50392. * Gets the glow intensity.
  50393. */
  50394. intensity: number;
  50395. private _options;
  50396. private _intensity;
  50397. private _horizontalBlurPostprocess1;
  50398. private _verticalBlurPostprocess1;
  50399. private _horizontalBlurPostprocess2;
  50400. private _verticalBlurPostprocess2;
  50401. private _blurTexture1;
  50402. private _blurTexture2;
  50403. private _postProcesses1;
  50404. private _postProcesses2;
  50405. private _includedOnlyMeshes;
  50406. private _excludedMeshes;
  50407. /**
  50408. * Callback used to let the user override the color selection on a per mesh basis
  50409. */
  50410. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50411. /**
  50412. * Callback used to let the user override the texture selection on a per mesh basis
  50413. */
  50414. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50415. /**
  50416. * Instantiates a new glow Layer and references it to the scene.
  50417. * @param name The name of the layer
  50418. * @param scene The scene to use the layer in
  50419. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50420. */
  50421. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50422. /**
  50423. * Get the effect name of the layer.
  50424. * @return The effect name
  50425. */
  50426. getEffectName(): string;
  50427. /**
  50428. * Create the merge effect. This is the shader use to blit the information back
  50429. * to the main canvas at the end of the scene rendering.
  50430. */
  50431. protected _createMergeEffect(): Effect;
  50432. /**
  50433. * Creates the render target textures and post processes used in the glow layer.
  50434. */
  50435. protected _createTextureAndPostProcesses(): void;
  50436. /**
  50437. * Checks for the readiness of the element composing the layer.
  50438. * @param subMesh the mesh to check for
  50439. * @param useInstances specify wether or not to use instances to render the mesh
  50440. * @param emissiveTexture the associated emissive texture used to generate the glow
  50441. * @return true if ready otherwise, false
  50442. */
  50443. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50444. /**
  50445. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50446. */
  50447. needStencil(): boolean;
  50448. /**
  50449. * Returns true if the mesh can be rendered, otherwise false.
  50450. * @param mesh The mesh to render
  50451. * @param material The material used on the mesh
  50452. * @returns true if it can be rendered otherwise false
  50453. */
  50454. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50455. /**
  50456. * Implementation specific of rendering the generating effect on the main canvas.
  50457. * @param effect The effect used to render through
  50458. */
  50459. protected _internalRender(effect: Effect): void;
  50460. /**
  50461. * Sets the required values for both the emissive texture and and the main color.
  50462. */
  50463. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50464. /**
  50465. * Returns true if the mesh should render, otherwise false.
  50466. * @param mesh The mesh to render
  50467. * @returns true if it should render otherwise false
  50468. */
  50469. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50470. /**
  50471. * Adds specific effects defines.
  50472. * @param defines The defines to add specifics to.
  50473. */
  50474. protected _addCustomEffectDefines(defines: string[]): void;
  50475. /**
  50476. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50477. * @param mesh The mesh to exclude from the glow layer
  50478. */
  50479. addExcludedMesh(mesh: Mesh): void;
  50480. /**
  50481. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50482. * @param mesh The mesh to remove
  50483. */
  50484. removeExcludedMesh(mesh: Mesh): void;
  50485. /**
  50486. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50487. * @param mesh The mesh to include in the glow layer
  50488. */
  50489. addIncludedOnlyMesh(mesh: Mesh): void;
  50490. /**
  50491. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50492. * @param mesh The mesh to remove
  50493. */
  50494. removeIncludedOnlyMesh(mesh: Mesh): void;
  50495. /**
  50496. * Determine if a given mesh will be used in the glow layer
  50497. * @param mesh The mesh to test
  50498. * @returns true if the mesh will be highlighted by the current glow layer
  50499. */
  50500. hasMesh(mesh: AbstractMesh): boolean;
  50501. /**
  50502. * Free any resources and references associated to a mesh.
  50503. * Internal use
  50504. * @param mesh The mesh to free.
  50505. * @hidden
  50506. */
  50507. _disposeMesh(mesh: Mesh): void;
  50508. /**
  50509. * Gets the class name of the effect layer
  50510. * @returns the string with the class name of the effect layer
  50511. */
  50512. getClassName(): string;
  50513. /**
  50514. * Serializes this glow layer
  50515. * @returns a serialized glow layer object
  50516. */
  50517. serialize(): any;
  50518. /**
  50519. * Creates a Glow Layer from parsed glow layer data
  50520. * @param parsedGlowLayer defines glow layer data
  50521. * @param scene defines the current scene
  50522. * @param rootUrl defines the root URL containing the glow layer information
  50523. * @returns a parsed Glow Layer
  50524. */
  50525. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50526. }
  50527. }
  50528. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50529. /** @hidden */
  50530. export var glowBlurPostProcessPixelShader: {
  50531. name: string;
  50532. shader: string;
  50533. };
  50534. }
  50535. declare module "babylonjs/Layers/highlightLayer" {
  50536. import { Observable } from "babylonjs/Misc/observable";
  50537. import { Nullable } from "babylonjs/types";
  50538. import { Camera } from "babylonjs/Cameras/camera";
  50539. import { Scene } from "babylonjs/scene";
  50540. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50542. import { Mesh } from "babylonjs/Meshes/mesh";
  50543. import { Effect } from "babylonjs/Materials/effect";
  50544. import { Material } from "babylonjs/Materials/material";
  50545. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50546. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  50547. import "babylonjs/Shaders/glowMapMerge.fragment";
  50548. import "babylonjs/Shaders/glowMapMerge.vertex";
  50549. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50550. module "babylonjs/abstractScene" {
  50551. interface AbstractScene {
  50552. /**
  50553. * Return a the first highlight layer of the scene with a given name.
  50554. * @param name The name of the highlight layer to look for.
  50555. * @return The highlight layer if found otherwise null.
  50556. */
  50557. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50558. }
  50559. }
  50560. /**
  50561. * Highlight layer options. This helps customizing the behaviour
  50562. * of the highlight layer.
  50563. */
  50564. export interface IHighlightLayerOptions {
  50565. /**
  50566. * Multiplication factor apply to the canvas size to compute the render target size
  50567. * used to generated the glowing objects (the smaller the faster).
  50568. */
  50569. mainTextureRatio: number;
  50570. /**
  50571. * Enforces a fixed size texture to ensure resize independant blur.
  50572. */
  50573. mainTextureFixedSize?: number;
  50574. /**
  50575. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50576. * of the picture to blur (the smaller the faster).
  50577. */
  50578. blurTextureSizeRatio: number;
  50579. /**
  50580. * How big in texel of the blur texture is the vertical blur.
  50581. */
  50582. blurVerticalSize: number;
  50583. /**
  50584. * How big in texel of the blur texture is the horizontal blur.
  50585. */
  50586. blurHorizontalSize: number;
  50587. /**
  50588. * Alpha blending mode used to apply the blur. Default is combine.
  50589. */
  50590. alphaBlendingMode: number;
  50591. /**
  50592. * The camera attached to the layer.
  50593. */
  50594. camera: Nullable<Camera>;
  50595. /**
  50596. * Should we display highlight as a solid stroke?
  50597. */
  50598. isStroke?: boolean;
  50599. /**
  50600. * The rendering group to draw the layer in.
  50601. */
  50602. renderingGroupId: number;
  50603. }
  50604. /**
  50605. * The highlight layer Helps adding a glow effect around a mesh.
  50606. *
  50607. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50608. * glowy meshes to your scene.
  50609. *
  50610. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50611. */
  50612. export class HighlightLayer extends EffectLayer {
  50613. name: string;
  50614. /**
  50615. * Effect Name of the highlight layer.
  50616. */
  50617. static readonly EffectName: string;
  50618. /**
  50619. * The neutral color used during the preparation of the glow effect.
  50620. * This is black by default as the blend operation is a blend operation.
  50621. */
  50622. static NeutralColor: Color4;
  50623. /**
  50624. * Stencil value used for glowing meshes.
  50625. */
  50626. static GlowingMeshStencilReference: number;
  50627. /**
  50628. * Stencil value used for the other meshes in the scene.
  50629. */
  50630. static NormalMeshStencilReference: number;
  50631. /**
  50632. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50633. */
  50634. innerGlow: boolean;
  50635. /**
  50636. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50637. */
  50638. outerGlow: boolean;
  50639. /**
  50640. * Specifies the horizontal size of the blur.
  50641. */
  50642. /**
  50643. * Gets the horizontal size of the blur.
  50644. */
  50645. blurHorizontalSize: number;
  50646. /**
  50647. * Specifies the vertical size of the blur.
  50648. */
  50649. /**
  50650. * Gets the vertical size of the blur.
  50651. */
  50652. blurVerticalSize: number;
  50653. /**
  50654. * An event triggered when the highlight layer is being blurred.
  50655. */
  50656. onBeforeBlurObservable: Observable<HighlightLayer>;
  50657. /**
  50658. * An event triggered when the highlight layer has been blurred.
  50659. */
  50660. onAfterBlurObservable: Observable<HighlightLayer>;
  50661. private _instanceGlowingMeshStencilReference;
  50662. private _options;
  50663. private _downSamplePostprocess;
  50664. private _horizontalBlurPostprocess;
  50665. private _verticalBlurPostprocess;
  50666. private _blurTexture;
  50667. private _meshes;
  50668. private _excludedMeshes;
  50669. /**
  50670. * Instantiates a new highlight Layer and references it to the scene..
  50671. * @param name The name of the layer
  50672. * @param scene The scene to use the layer in
  50673. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50674. */
  50675. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50676. /**
  50677. * Get the effect name of the layer.
  50678. * @return The effect name
  50679. */
  50680. getEffectName(): string;
  50681. /**
  50682. * Create the merge effect. This is the shader use to blit the information back
  50683. * to the main canvas at the end of the scene rendering.
  50684. */
  50685. protected _createMergeEffect(): Effect;
  50686. /**
  50687. * Creates the render target textures and post processes used in the highlight layer.
  50688. */
  50689. protected _createTextureAndPostProcesses(): void;
  50690. /**
  50691. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50692. */
  50693. needStencil(): boolean;
  50694. /**
  50695. * Checks for the readiness of the element composing the layer.
  50696. * @param subMesh the mesh to check for
  50697. * @param useInstances specify wether or not to use instances to render the mesh
  50698. * @param emissiveTexture the associated emissive texture used to generate the glow
  50699. * @return true if ready otherwise, false
  50700. */
  50701. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50702. /**
  50703. * Implementation specific of rendering the generating effect on the main canvas.
  50704. * @param effect The effect used to render through
  50705. */
  50706. protected _internalRender(effect: Effect): void;
  50707. /**
  50708. * Returns true if the layer contains information to display, otherwise false.
  50709. */
  50710. shouldRender(): boolean;
  50711. /**
  50712. * Returns true if the mesh should render, otherwise false.
  50713. * @param mesh The mesh to render
  50714. * @returns true if it should render otherwise false
  50715. */
  50716. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50717. /**
  50718. * Sets the required values for both the emissive texture and and the main color.
  50719. */
  50720. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50721. /**
  50722. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50723. * @param mesh The mesh to exclude from the highlight layer
  50724. */
  50725. addExcludedMesh(mesh: Mesh): void;
  50726. /**
  50727. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50728. * @param mesh The mesh to highlight
  50729. */
  50730. removeExcludedMesh(mesh: Mesh): void;
  50731. /**
  50732. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50733. * @param mesh mesh to test
  50734. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50735. */
  50736. hasMesh(mesh: AbstractMesh): boolean;
  50737. /**
  50738. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50739. * @param mesh The mesh to highlight
  50740. * @param color The color of the highlight
  50741. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50742. */
  50743. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50744. /**
  50745. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50746. * @param mesh The mesh to highlight
  50747. */
  50748. removeMesh(mesh: Mesh): void;
  50749. /**
  50750. * Force the stencil to the normal expected value for none glowing parts
  50751. */
  50752. private _defaultStencilReference;
  50753. /**
  50754. * Free any resources and references associated to a mesh.
  50755. * Internal use
  50756. * @param mesh The mesh to free.
  50757. * @hidden
  50758. */
  50759. _disposeMesh(mesh: Mesh): void;
  50760. /**
  50761. * Dispose the highlight layer and free resources.
  50762. */
  50763. dispose(): void;
  50764. /**
  50765. * Gets the class name of the effect layer
  50766. * @returns the string with the class name of the effect layer
  50767. */
  50768. getClassName(): string;
  50769. /**
  50770. * Serializes this Highlight layer
  50771. * @returns a serialized Highlight layer object
  50772. */
  50773. serialize(): any;
  50774. /**
  50775. * Creates a Highlight layer from parsed Highlight layer data
  50776. * @param parsedHightlightLayer defines the Highlight layer data
  50777. * @param scene defines the current scene
  50778. * @param rootUrl defines the root URL containing the Highlight layer information
  50779. * @returns a parsed Highlight layer
  50780. */
  50781. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50782. }
  50783. }
  50784. declare module "babylonjs/Layers/layerSceneComponent" {
  50785. import { Scene } from "babylonjs/scene";
  50786. import { ISceneComponent } from "babylonjs/sceneComponent";
  50787. import { Layer } from "babylonjs/Layers/layer";
  50788. import { AbstractScene } from "babylonjs/abstractScene";
  50789. module "babylonjs/abstractScene" {
  50790. interface AbstractScene {
  50791. /**
  50792. * The list of layers (background and foreground) of the scene
  50793. */
  50794. layers: Array<Layer>;
  50795. }
  50796. }
  50797. /**
  50798. * Defines the layer scene component responsible to manage any layers
  50799. * in a given scene.
  50800. */
  50801. export class LayerSceneComponent implements ISceneComponent {
  50802. /**
  50803. * The component name helpfull to identify the component in the list of scene components.
  50804. */
  50805. readonly name: string;
  50806. /**
  50807. * The scene the component belongs to.
  50808. */
  50809. scene: Scene;
  50810. private _engine;
  50811. /**
  50812. * Creates a new instance of the component for the given scene
  50813. * @param scene Defines the scene to register the component in
  50814. */
  50815. constructor(scene: Scene);
  50816. /**
  50817. * Registers the component in a given scene
  50818. */
  50819. register(): void;
  50820. /**
  50821. * Rebuilds the elements related to this component in case of
  50822. * context lost for instance.
  50823. */
  50824. rebuild(): void;
  50825. /**
  50826. * Disposes the component and the associated ressources.
  50827. */
  50828. dispose(): void;
  50829. private _draw;
  50830. private _drawCameraPredicate;
  50831. private _drawCameraBackground;
  50832. private _drawCameraForeground;
  50833. private _drawRenderTargetPredicate;
  50834. private _drawRenderTargetBackground;
  50835. private _drawRenderTargetForeground;
  50836. /**
  50837. * Adds all the elements from the container to the scene
  50838. * @param container the container holding the elements
  50839. */
  50840. addFromContainer(container: AbstractScene): void;
  50841. /**
  50842. * Removes all the elements in the container from the scene
  50843. * @param container contains the elements to remove
  50844. * @param dispose if the removed element should be disposed (default: false)
  50845. */
  50846. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50847. }
  50848. }
  50849. declare module "babylonjs/Shaders/layer.fragment" {
  50850. /** @hidden */
  50851. export var layerPixelShader: {
  50852. name: string;
  50853. shader: string;
  50854. };
  50855. }
  50856. declare module "babylonjs/Shaders/layer.vertex" {
  50857. /** @hidden */
  50858. export var layerVertexShader: {
  50859. name: string;
  50860. shader: string;
  50861. };
  50862. }
  50863. declare module "babylonjs/Layers/layer" {
  50864. import { Observable } from "babylonjs/Misc/observable";
  50865. import { Nullable } from "babylonjs/types";
  50866. import { Scene } from "babylonjs/scene";
  50867. import { Vector2 } from "babylonjs/Maths/math.vector";
  50868. import { Color4 } from "babylonjs/Maths/math.color";
  50869. import { Texture } from "babylonjs/Materials/Textures/texture";
  50870. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50871. import "babylonjs/Shaders/layer.fragment";
  50872. import "babylonjs/Shaders/layer.vertex";
  50873. /**
  50874. * This represents a full screen 2d layer.
  50875. * This can be useful to display a picture in the background of your scene for instance.
  50876. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50877. */
  50878. export class Layer {
  50879. /**
  50880. * Define the name of the layer.
  50881. */
  50882. name: string;
  50883. /**
  50884. * Define the texture the layer should display.
  50885. */
  50886. texture: Nullable<Texture>;
  50887. /**
  50888. * Is the layer in background or foreground.
  50889. */
  50890. isBackground: boolean;
  50891. /**
  50892. * Define the color of the layer (instead of texture).
  50893. */
  50894. color: Color4;
  50895. /**
  50896. * Define the scale of the layer in order to zoom in out of the texture.
  50897. */
  50898. scale: Vector2;
  50899. /**
  50900. * Define an offset for the layer in order to shift the texture.
  50901. */
  50902. offset: Vector2;
  50903. /**
  50904. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50905. */
  50906. alphaBlendingMode: number;
  50907. /**
  50908. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50909. * Alpha test will not mix with the background color in case of transparency.
  50910. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50911. */
  50912. alphaTest: boolean;
  50913. /**
  50914. * Define a mask to restrict the layer to only some of the scene cameras.
  50915. */
  50916. layerMask: number;
  50917. /**
  50918. * Define the list of render target the layer is visible into.
  50919. */
  50920. renderTargetTextures: RenderTargetTexture[];
  50921. /**
  50922. * Define if the layer is only used in renderTarget or if it also
  50923. * renders in the main frame buffer of the canvas.
  50924. */
  50925. renderOnlyInRenderTargetTextures: boolean;
  50926. private _scene;
  50927. private _vertexBuffers;
  50928. private _indexBuffer;
  50929. private _effect;
  50930. private _alphaTestEffect;
  50931. /**
  50932. * An event triggered when the layer is disposed.
  50933. */
  50934. onDisposeObservable: Observable<Layer>;
  50935. private _onDisposeObserver;
  50936. /**
  50937. * Back compatibility with callback before the onDisposeObservable existed.
  50938. * The set callback will be triggered when the layer has been disposed.
  50939. */
  50940. onDispose: () => void;
  50941. /**
  50942. * An event triggered before rendering the scene
  50943. */
  50944. onBeforeRenderObservable: Observable<Layer>;
  50945. private _onBeforeRenderObserver;
  50946. /**
  50947. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50948. * The set callback will be triggered just before rendering the layer.
  50949. */
  50950. onBeforeRender: () => void;
  50951. /**
  50952. * An event triggered after rendering the scene
  50953. */
  50954. onAfterRenderObservable: Observable<Layer>;
  50955. private _onAfterRenderObserver;
  50956. /**
  50957. * Back compatibility with callback before the onAfterRenderObservable existed.
  50958. * The set callback will be triggered just after rendering the layer.
  50959. */
  50960. onAfterRender: () => void;
  50961. /**
  50962. * Instantiates a new layer.
  50963. * This represents a full screen 2d layer.
  50964. * This can be useful to display a picture in the background of your scene for instance.
  50965. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50966. * @param name Define the name of the layer in the scene
  50967. * @param imgUrl Define the url of the texture to display in the layer
  50968. * @param scene Define the scene the layer belongs to
  50969. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50970. * @param color Defines a color for the layer
  50971. */
  50972. constructor(
  50973. /**
  50974. * Define the name of the layer.
  50975. */
  50976. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50977. private _createIndexBuffer;
  50978. /** @hidden */
  50979. _rebuild(): void;
  50980. /**
  50981. * Renders the layer in the scene.
  50982. */
  50983. render(): void;
  50984. /**
  50985. * Disposes and releases the associated ressources.
  50986. */
  50987. dispose(): void;
  50988. }
  50989. }
  50990. declare module "babylonjs/Layers/index" {
  50991. export * from "babylonjs/Layers/effectLayer";
  50992. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50993. export * from "babylonjs/Layers/glowLayer";
  50994. export * from "babylonjs/Layers/highlightLayer";
  50995. export * from "babylonjs/Layers/layer";
  50996. export * from "babylonjs/Layers/layerSceneComponent";
  50997. }
  50998. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50999. /** @hidden */
  51000. export var lensFlarePixelShader: {
  51001. name: string;
  51002. shader: string;
  51003. };
  51004. }
  51005. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51006. /** @hidden */
  51007. export var lensFlareVertexShader: {
  51008. name: string;
  51009. shader: string;
  51010. };
  51011. }
  51012. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51013. import { Scene } from "babylonjs/scene";
  51014. import { Vector3 } from "babylonjs/Maths/math.vector";
  51015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51016. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51017. import "babylonjs/Shaders/lensFlare.fragment";
  51018. import "babylonjs/Shaders/lensFlare.vertex";
  51019. import { Viewport } from "babylonjs/Maths/math.viewport";
  51020. /**
  51021. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51022. * It is usually composed of several `lensFlare`.
  51023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51024. */
  51025. export class LensFlareSystem {
  51026. /**
  51027. * Define the name of the lens flare system
  51028. */
  51029. name: string;
  51030. /**
  51031. * List of lens flares used in this system.
  51032. */
  51033. lensFlares: LensFlare[];
  51034. /**
  51035. * Define a limit from the border the lens flare can be visible.
  51036. */
  51037. borderLimit: number;
  51038. /**
  51039. * Define a viewport border we do not want to see the lens flare in.
  51040. */
  51041. viewportBorder: number;
  51042. /**
  51043. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51044. */
  51045. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51046. /**
  51047. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51048. */
  51049. layerMask: number;
  51050. /**
  51051. * Define the id of the lens flare system in the scene.
  51052. * (equal to name by default)
  51053. */
  51054. id: string;
  51055. private _scene;
  51056. private _emitter;
  51057. private _vertexBuffers;
  51058. private _indexBuffer;
  51059. private _effect;
  51060. private _positionX;
  51061. private _positionY;
  51062. private _isEnabled;
  51063. /** @hidden */
  51064. static _SceneComponentInitialization: (scene: Scene) => void;
  51065. /**
  51066. * Instantiates a lens flare system.
  51067. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51068. * It is usually composed of several `lensFlare`.
  51069. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51070. * @param name Define the name of the lens flare system in the scene
  51071. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51072. * @param scene Define the scene the lens flare system belongs to
  51073. */
  51074. constructor(
  51075. /**
  51076. * Define the name of the lens flare system
  51077. */
  51078. name: string, emitter: any, scene: Scene);
  51079. /**
  51080. * Define if the lens flare system is enabled.
  51081. */
  51082. isEnabled: boolean;
  51083. /**
  51084. * Get the scene the effects belongs to.
  51085. * @returns the scene holding the lens flare system
  51086. */
  51087. getScene(): Scene;
  51088. /**
  51089. * Get the emitter of the lens flare system.
  51090. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51091. * @returns the emitter of the lens flare system
  51092. */
  51093. getEmitter(): any;
  51094. /**
  51095. * Set the emitter of the lens flare system.
  51096. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51097. * @param newEmitter Define the new emitter of the system
  51098. */
  51099. setEmitter(newEmitter: any): void;
  51100. /**
  51101. * Get the lens flare system emitter position.
  51102. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51103. * @returns the position
  51104. */
  51105. getEmitterPosition(): Vector3;
  51106. /**
  51107. * @hidden
  51108. */
  51109. computeEffectivePosition(globalViewport: Viewport): boolean;
  51110. /** @hidden */
  51111. _isVisible(): boolean;
  51112. /**
  51113. * @hidden
  51114. */
  51115. render(): boolean;
  51116. /**
  51117. * Dispose and release the lens flare with its associated resources.
  51118. */
  51119. dispose(): void;
  51120. /**
  51121. * Parse a lens flare system from a JSON repressentation
  51122. * @param parsedLensFlareSystem Define the JSON to parse
  51123. * @param scene Define the scene the parsed system should be instantiated in
  51124. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51125. * @returns the parsed system
  51126. */
  51127. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51128. /**
  51129. * Serialize the current Lens Flare System into a JSON representation.
  51130. * @returns the serialized JSON
  51131. */
  51132. serialize(): any;
  51133. }
  51134. }
  51135. declare module "babylonjs/LensFlares/lensFlare" {
  51136. import { Nullable } from "babylonjs/types";
  51137. import { Color3 } from "babylonjs/Maths/math.color";
  51138. import { Texture } from "babylonjs/Materials/Textures/texture";
  51139. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51140. /**
  51141. * This represents one of the lens effect in a `lensFlareSystem`.
  51142. * It controls one of the indiviual texture used in the effect.
  51143. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51144. */
  51145. export class LensFlare {
  51146. /**
  51147. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51148. */
  51149. size: number;
  51150. /**
  51151. * 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.
  51152. */
  51153. position: number;
  51154. /**
  51155. * Define the lens color.
  51156. */
  51157. color: Color3;
  51158. /**
  51159. * Define the lens texture.
  51160. */
  51161. texture: Nullable<Texture>;
  51162. /**
  51163. * Define the alpha mode to render this particular lens.
  51164. */
  51165. alphaMode: number;
  51166. private _system;
  51167. /**
  51168. * Creates a new Lens Flare.
  51169. * This represents one of the lens effect in a `lensFlareSystem`.
  51170. * It controls one of the indiviual texture used in the effect.
  51171. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51172. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51173. * @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.
  51174. * @param color Define the lens color
  51175. * @param imgUrl Define the lens texture url
  51176. * @param system Define the `lensFlareSystem` this flare is part of
  51177. * @returns The newly created Lens Flare
  51178. */
  51179. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51180. /**
  51181. * Instantiates a new Lens Flare.
  51182. * This represents one of the lens effect in a `lensFlareSystem`.
  51183. * It controls one of the indiviual texture used in the effect.
  51184. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51185. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51186. * @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.
  51187. * @param color Define the lens color
  51188. * @param imgUrl Define the lens texture url
  51189. * @param system Define the `lensFlareSystem` this flare is part of
  51190. */
  51191. constructor(
  51192. /**
  51193. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51194. */
  51195. size: number,
  51196. /**
  51197. * 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.
  51198. */
  51199. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51200. /**
  51201. * Dispose and release the lens flare with its associated resources.
  51202. */
  51203. dispose(): void;
  51204. }
  51205. }
  51206. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51207. import { Nullable } from "babylonjs/types";
  51208. import { Scene } from "babylonjs/scene";
  51209. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51210. import { AbstractScene } from "babylonjs/abstractScene";
  51211. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51212. module "babylonjs/abstractScene" {
  51213. interface AbstractScene {
  51214. /**
  51215. * The list of lens flare system added to the scene
  51216. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51217. */
  51218. lensFlareSystems: Array<LensFlareSystem>;
  51219. /**
  51220. * Removes the given lens flare system from this scene.
  51221. * @param toRemove The lens flare system to remove
  51222. * @returns The index of the removed lens flare system
  51223. */
  51224. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51225. /**
  51226. * Adds the given lens flare system to this scene
  51227. * @param newLensFlareSystem The lens flare system to add
  51228. */
  51229. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51230. /**
  51231. * Gets a lens flare system using its name
  51232. * @param name defines the name to look for
  51233. * @returns the lens flare system or null if not found
  51234. */
  51235. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51236. /**
  51237. * Gets a lens flare system using its id
  51238. * @param id defines the id to look for
  51239. * @returns the lens flare system or null if not found
  51240. */
  51241. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51242. }
  51243. }
  51244. /**
  51245. * Defines the lens flare scene component responsible to manage any lens flares
  51246. * in a given scene.
  51247. */
  51248. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51249. /**
  51250. * The component name helpfull to identify the component in the list of scene components.
  51251. */
  51252. readonly name: string;
  51253. /**
  51254. * The scene the component belongs to.
  51255. */
  51256. scene: Scene;
  51257. /**
  51258. * Creates a new instance of the component for the given scene
  51259. * @param scene Defines the scene to register the component in
  51260. */
  51261. constructor(scene: Scene);
  51262. /**
  51263. * Registers the component in a given scene
  51264. */
  51265. register(): void;
  51266. /**
  51267. * Rebuilds the elements related to this component in case of
  51268. * context lost for instance.
  51269. */
  51270. rebuild(): void;
  51271. /**
  51272. * Adds all the elements from the container to the scene
  51273. * @param container the container holding the elements
  51274. */
  51275. addFromContainer(container: AbstractScene): void;
  51276. /**
  51277. * Removes all the elements in the container from the scene
  51278. * @param container contains the elements to remove
  51279. * @param dispose if the removed element should be disposed (default: false)
  51280. */
  51281. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51282. /**
  51283. * Serializes the component data to the specified json object
  51284. * @param serializationObject The object to serialize to
  51285. */
  51286. serialize(serializationObject: any): void;
  51287. /**
  51288. * Disposes the component and the associated ressources.
  51289. */
  51290. dispose(): void;
  51291. private _draw;
  51292. }
  51293. }
  51294. declare module "babylonjs/LensFlares/index" {
  51295. export * from "babylonjs/LensFlares/lensFlare";
  51296. export * from "babylonjs/LensFlares/lensFlareSystem";
  51297. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51298. }
  51299. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51300. import { Scene } from "babylonjs/scene";
  51301. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51302. import { AbstractScene } from "babylonjs/abstractScene";
  51303. /**
  51304. * Defines the shadow generator component responsible to manage any shadow generators
  51305. * in a given scene.
  51306. */
  51307. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51308. /**
  51309. * The component name helpfull to identify the component in the list of scene components.
  51310. */
  51311. readonly name: string;
  51312. /**
  51313. * The scene the component belongs to.
  51314. */
  51315. scene: Scene;
  51316. /**
  51317. * Creates a new instance of the component for the given scene
  51318. * @param scene Defines the scene to register the component in
  51319. */
  51320. constructor(scene: Scene);
  51321. /**
  51322. * Registers the component in a given scene
  51323. */
  51324. register(): void;
  51325. /**
  51326. * Rebuilds the elements related to this component in case of
  51327. * context lost for instance.
  51328. */
  51329. rebuild(): void;
  51330. /**
  51331. * Serializes the component data to the specified json object
  51332. * @param serializationObject The object to serialize to
  51333. */
  51334. serialize(serializationObject: any): void;
  51335. /**
  51336. * Adds all the elements from the container to the scene
  51337. * @param container the container holding the elements
  51338. */
  51339. addFromContainer(container: AbstractScene): void;
  51340. /**
  51341. * Removes all the elements in the container from the scene
  51342. * @param container contains the elements to remove
  51343. * @param dispose if the removed element should be disposed (default: false)
  51344. */
  51345. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51346. /**
  51347. * Rebuilds the elements related to this component in case of
  51348. * context lost for instance.
  51349. */
  51350. dispose(): void;
  51351. private _gatherRenderTargets;
  51352. }
  51353. }
  51354. declare module "babylonjs/Lights/Shadows/index" {
  51355. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51356. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51357. }
  51358. declare module "babylonjs/Lights/pointLight" {
  51359. import { Scene } from "babylonjs/scene";
  51360. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51362. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51363. import { Effect } from "babylonjs/Materials/effect";
  51364. /**
  51365. * A point light is a light defined by an unique point in world space.
  51366. * The light is emitted in every direction from this point.
  51367. * A good example of a point light is a standard light bulb.
  51368. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51369. */
  51370. export class PointLight extends ShadowLight {
  51371. private _shadowAngle;
  51372. /**
  51373. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51374. * This specifies what angle the shadow will use to be created.
  51375. *
  51376. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51377. */
  51378. /**
  51379. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51380. * This specifies what angle the shadow will use to be created.
  51381. *
  51382. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51383. */
  51384. shadowAngle: number;
  51385. /**
  51386. * Gets the direction if it has been set.
  51387. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51388. */
  51389. /**
  51390. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51391. */
  51392. direction: Vector3;
  51393. /**
  51394. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51395. * A PointLight emits the light in every direction.
  51396. * It can cast shadows.
  51397. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51398. * ```javascript
  51399. * var pointLight = new PointLight("pl", camera.position, scene);
  51400. * ```
  51401. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51402. * @param name The light friendly name
  51403. * @param position The position of the point light in the scene
  51404. * @param scene The scene the lights belongs to
  51405. */
  51406. constructor(name: string, position: Vector3, scene: Scene);
  51407. /**
  51408. * Returns the string "PointLight"
  51409. * @returns the class name
  51410. */
  51411. getClassName(): string;
  51412. /**
  51413. * Returns the integer 0.
  51414. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51415. */
  51416. getTypeID(): number;
  51417. /**
  51418. * Specifies wether or not the shadowmap should be a cube texture.
  51419. * @returns true if the shadowmap needs to be a cube texture.
  51420. */
  51421. needCube(): boolean;
  51422. /**
  51423. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51424. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51425. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51426. */
  51427. getShadowDirection(faceIndex?: number): Vector3;
  51428. /**
  51429. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51430. * - fov = PI / 2
  51431. * - aspect ratio : 1.0
  51432. * - z-near and far equal to the active camera minZ and maxZ.
  51433. * Returns the PointLight.
  51434. */
  51435. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51436. protected _buildUniformLayout(): void;
  51437. /**
  51438. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51439. * @param effect The effect to update
  51440. * @param lightIndex The index of the light in the effect to update
  51441. * @returns The point light
  51442. */
  51443. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51444. /**
  51445. * Prepares the list of defines specific to the light type.
  51446. * @param defines the list of defines
  51447. * @param lightIndex defines the index of the light for the effect
  51448. */
  51449. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51450. }
  51451. }
  51452. declare module "babylonjs/Lights/index" {
  51453. export * from "babylonjs/Lights/light";
  51454. export * from "babylonjs/Lights/shadowLight";
  51455. export * from "babylonjs/Lights/Shadows/index";
  51456. export * from "babylonjs/Lights/directionalLight";
  51457. export * from "babylonjs/Lights/hemisphericLight";
  51458. export * from "babylonjs/Lights/pointLight";
  51459. export * from "babylonjs/Lights/spotLight";
  51460. }
  51461. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51462. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51463. /**
  51464. * Header information of HDR texture files.
  51465. */
  51466. export interface HDRInfo {
  51467. /**
  51468. * The height of the texture in pixels.
  51469. */
  51470. height: number;
  51471. /**
  51472. * The width of the texture in pixels.
  51473. */
  51474. width: number;
  51475. /**
  51476. * The index of the beginning of the data in the binary file.
  51477. */
  51478. dataPosition: number;
  51479. }
  51480. /**
  51481. * This groups tools to convert HDR texture to native colors array.
  51482. */
  51483. export class HDRTools {
  51484. private static Ldexp;
  51485. private static Rgbe2float;
  51486. private static readStringLine;
  51487. /**
  51488. * Reads header information from an RGBE texture stored in a native array.
  51489. * More information on this format are available here:
  51490. * https://en.wikipedia.org/wiki/RGBE_image_format
  51491. *
  51492. * @param uint8array The binary file stored in native array.
  51493. * @return The header information.
  51494. */
  51495. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51496. /**
  51497. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51498. * This RGBE texture needs to store the information as a panorama.
  51499. *
  51500. * More information on this format are available here:
  51501. * https://en.wikipedia.org/wiki/RGBE_image_format
  51502. *
  51503. * @param buffer The binary file stored in an array buffer.
  51504. * @param size The expected size of the extracted cubemap.
  51505. * @return The Cube Map information.
  51506. */
  51507. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51508. /**
  51509. * Returns the pixels data extracted from an RGBE texture.
  51510. * This pixels will be stored left to right up to down in the R G B order in one array.
  51511. *
  51512. * More information on this format are available here:
  51513. * https://en.wikipedia.org/wiki/RGBE_image_format
  51514. *
  51515. * @param uint8array The binary file stored in an array buffer.
  51516. * @param hdrInfo The header information of the file.
  51517. * @return The pixels data in RGB right to left up to down order.
  51518. */
  51519. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51520. private static RGBE_ReadPixels_RLE;
  51521. }
  51522. }
  51523. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51524. import { Nullable } from "babylonjs/types";
  51525. import { Scene } from "babylonjs/scene";
  51526. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51528. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51529. /**
  51530. * This represents a texture coming from an HDR input.
  51531. *
  51532. * The only supported format is currently panorama picture stored in RGBE format.
  51533. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51534. */
  51535. export class HDRCubeTexture extends BaseTexture {
  51536. private static _facesMapping;
  51537. private _generateHarmonics;
  51538. private _noMipmap;
  51539. private _textureMatrix;
  51540. private _size;
  51541. private _onLoad;
  51542. private _onError;
  51543. /**
  51544. * The texture URL.
  51545. */
  51546. url: string;
  51547. /**
  51548. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51549. */
  51550. coordinatesMode: number;
  51551. protected _isBlocking: boolean;
  51552. /**
  51553. * Sets wether or not the texture is blocking during loading.
  51554. */
  51555. /**
  51556. * Gets wether or not the texture is blocking during loading.
  51557. */
  51558. isBlocking: boolean;
  51559. protected _rotationY: number;
  51560. /**
  51561. * Sets texture matrix rotation angle around Y axis in radians.
  51562. */
  51563. /**
  51564. * Gets texture matrix rotation angle around Y axis radians.
  51565. */
  51566. rotationY: number;
  51567. /**
  51568. * Gets or sets the center of the bounding box associated with the cube texture
  51569. * It must define where the camera used to render the texture was set
  51570. */
  51571. boundingBoxPosition: Vector3;
  51572. private _boundingBoxSize;
  51573. /**
  51574. * Gets or sets the size of the bounding box associated with the cube texture
  51575. * When defined, the cubemap will switch to local mode
  51576. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51577. * @example https://www.babylonjs-playground.com/#RNASML
  51578. */
  51579. boundingBoxSize: Vector3;
  51580. /**
  51581. * Instantiates an HDRTexture from the following parameters.
  51582. *
  51583. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51584. * @param scene The scene the texture will be used in
  51585. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51586. * @param noMipmap Forces to not generate the mipmap if true
  51587. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51588. * @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)
  51589. * @param reserved Reserved flag for internal use.
  51590. */
  51591. 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>);
  51592. /**
  51593. * Get the current class name of the texture useful for serialization or dynamic coding.
  51594. * @returns "HDRCubeTexture"
  51595. */
  51596. getClassName(): string;
  51597. /**
  51598. * Occurs when the file is raw .hdr file.
  51599. */
  51600. private loadTexture;
  51601. clone(): HDRCubeTexture;
  51602. delayLoad(): void;
  51603. /**
  51604. * Get the texture reflection matrix used to rotate/transform the reflection.
  51605. * @returns the reflection matrix
  51606. */
  51607. getReflectionTextureMatrix(): Matrix;
  51608. /**
  51609. * Set the texture reflection matrix used to rotate/transform the reflection.
  51610. * @param value Define the reflection matrix to set
  51611. */
  51612. setReflectionTextureMatrix(value: Matrix): void;
  51613. /**
  51614. * Parses a JSON representation of an HDR Texture in order to create the texture
  51615. * @param parsedTexture Define the JSON representation
  51616. * @param scene Define the scene the texture should be created in
  51617. * @param rootUrl Define the root url in case we need to load relative dependencies
  51618. * @returns the newly created texture after parsing
  51619. */
  51620. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51621. serialize(): any;
  51622. }
  51623. }
  51624. declare module "babylonjs/Physics/physicsEngine" {
  51625. import { Nullable } from "babylonjs/types";
  51626. import { Vector3 } from "babylonjs/Maths/math.vector";
  51627. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51628. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51629. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51630. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51631. /**
  51632. * Class used to control physics engine
  51633. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51634. */
  51635. export class PhysicsEngine implements IPhysicsEngine {
  51636. private _physicsPlugin;
  51637. /**
  51638. * Global value used to control the smallest number supported by the simulation
  51639. */
  51640. static Epsilon: number;
  51641. private _impostors;
  51642. private _joints;
  51643. /**
  51644. * Gets the gravity vector used by the simulation
  51645. */
  51646. gravity: Vector3;
  51647. /**
  51648. * Factory used to create the default physics plugin.
  51649. * @returns The default physics plugin
  51650. */
  51651. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51652. /**
  51653. * Creates a new Physics Engine
  51654. * @param gravity defines the gravity vector used by the simulation
  51655. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51656. */
  51657. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51658. /**
  51659. * Sets the gravity vector used by the simulation
  51660. * @param gravity defines the gravity vector to use
  51661. */
  51662. setGravity(gravity: Vector3): void;
  51663. /**
  51664. * Set the time step of the physics engine.
  51665. * Default is 1/60.
  51666. * To slow it down, enter 1/600 for example.
  51667. * To speed it up, 1/30
  51668. * @param newTimeStep defines the new timestep to apply to this world.
  51669. */
  51670. setTimeStep(newTimeStep?: number): void;
  51671. /**
  51672. * Get the time step of the physics engine.
  51673. * @returns the current time step
  51674. */
  51675. getTimeStep(): number;
  51676. /**
  51677. * Release all resources
  51678. */
  51679. dispose(): void;
  51680. /**
  51681. * Gets the name of the current physics plugin
  51682. * @returns the name of the plugin
  51683. */
  51684. getPhysicsPluginName(): string;
  51685. /**
  51686. * Adding a new impostor for the impostor tracking.
  51687. * This will be done by the impostor itself.
  51688. * @param impostor the impostor to add
  51689. */
  51690. addImpostor(impostor: PhysicsImpostor): void;
  51691. /**
  51692. * Remove an impostor from the engine.
  51693. * This impostor and its mesh will not longer be updated by the physics engine.
  51694. * @param impostor the impostor to remove
  51695. */
  51696. removeImpostor(impostor: PhysicsImpostor): void;
  51697. /**
  51698. * Add a joint to the physics engine
  51699. * @param mainImpostor defines the main impostor to which the joint is added.
  51700. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51701. * @param joint defines the joint that will connect both impostors.
  51702. */
  51703. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51704. /**
  51705. * Removes a joint from the simulation
  51706. * @param mainImpostor defines the impostor used with the joint
  51707. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51708. * @param joint defines the joint to remove
  51709. */
  51710. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51711. /**
  51712. * Called by the scene. No need to call it.
  51713. * @param delta defines the timespam between frames
  51714. */
  51715. _step(delta: number): void;
  51716. /**
  51717. * Gets the current plugin used to run the simulation
  51718. * @returns current plugin
  51719. */
  51720. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51721. /**
  51722. * Gets the list of physic impostors
  51723. * @returns an array of PhysicsImpostor
  51724. */
  51725. getImpostors(): Array<PhysicsImpostor>;
  51726. /**
  51727. * Gets the impostor for a physics enabled object
  51728. * @param object defines the object impersonated by the impostor
  51729. * @returns the PhysicsImpostor or null if not found
  51730. */
  51731. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51732. /**
  51733. * Gets the impostor for a physics body object
  51734. * @param body defines physics body used by the impostor
  51735. * @returns the PhysicsImpostor or null if not found
  51736. */
  51737. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51738. /**
  51739. * Does a raycast in the physics world
  51740. * @param from when should the ray start?
  51741. * @param to when should the ray end?
  51742. * @returns PhysicsRaycastResult
  51743. */
  51744. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51745. }
  51746. }
  51747. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51748. import { Nullable } from "babylonjs/types";
  51749. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51751. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51752. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51753. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51754. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51755. /** @hidden */
  51756. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51757. private _useDeltaForWorldStep;
  51758. world: any;
  51759. name: string;
  51760. private _physicsMaterials;
  51761. private _fixedTimeStep;
  51762. private _cannonRaycastResult;
  51763. private _raycastResult;
  51764. private _physicsBodysToRemoveAfterStep;
  51765. BJSCANNON: any;
  51766. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51767. setGravity(gravity: Vector3): void;
  51768. setTimeStep(timeStep: number): void;
  51769. getTimeStep(): number;
  51770. executeStep(delta: number): void;
  51771. private _removeMarkedPhysicsBodiesFromWorld;
  51772. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51773. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51774. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51775. private _processChildMeshes;
  51776. removePhysicsBody(impostor: PhysicsImpostor): void;
  51777. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51778. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51779. private _addMaterial;
  51780. private _checkWithEpsilon;
  51781. private _createShape;
  51782. private _createHeightmap;
  51783. private _minus90X;
  51784. private _plus90X;
  51785. private _tmpPosition;
  51786. private _tmpDeltaPosition;
  51787. private _tmpUnityRotation;
  51788. private _updatePhysicsBodyTransformation;
  51789. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51790. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51791. isSupported(): boolean;
  51792. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51793. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51794. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51795. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51796. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51797. getBodyMass(impostor: PhysicsImpostor): number;
  51798. getBodyFriction(impostor: PhysicsImpostor): number;
  51799. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51800. getBodyRestitution(impostor: PhysicsImpostor): number;
  51801. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51802. sleepBody(impostor: PhysicsImpostor): void;
  51803. wakeUpBody(impostor: PhysicsImpostor): void;
  51804. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51805. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51806. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51807. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51808. getRadius(impostor: PhysicsImpostor): number;
  51809. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51810. dispose(): void;
  51811. private _extendNamespace;
  51812. /**
  51813. * Does a raycast in the physics world
  51814. * @param from when should the ray start?
  51815. * @param to when should the ray end?
  51816. * @returns PhysicsRaycastResult
  51817. */
  51818. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51819. }
  51820. }
  51821. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51822. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51823. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51824. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51826. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51827. import { Nullable } from "babylonjs/types";
  51828. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51829. /** @hidden */
  51830. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51831. world: any;
  51832. name: string;
  51833. BJSOIMO: any;
  51834. private _raycastResult;
  51835. constructor(iterations?: number, oimoInjection?: any);
  51836. setGravity(gravity: Vector3): void;
  51837. setTimeStep(timeStep: number): void;
  51838. getTimeStep(): number;
  51839. private _tmpImpostorsArray;
  51840. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51841. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51842. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51843. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51844. private _tmpPositionVector;
  51845. removePhysicsBody(impostor: PhysicsImpostor): void;
  51846. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51847. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51848. isSupported(): boolean;
  51849. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51850. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51851. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51852. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51853. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51854. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51855. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51856. getBodyMass(impostor: PhysicsImpostor): number;
  51857. getBodyFriction(impostor: PhysicsImpostor): number;
  51858. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51859. getBodyRestitution(impostor: PhysicsImpostor): number;
  51860. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51861. sleepBody(impostor: PhysicsImpostor): void;
  51862. wakeUpBody(impostor: PhysicsImpostor): void;
  51863. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51864. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51865. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51866. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51867. getRadius(impostor: PhysicsImpostor): number;
  51868. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51869. dispose(): void;
  51870. /**
  51871. * Does a raycast in the physics world
  51872. * @param from when should the ray start?
  51873. * @param to when should the ray end?
  51874. * @returns PhysicsRaycastResult
  51875. */
  51876. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51877. }
  51878. }
  51879. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51880. import { Nullable } from "babylonjs/types";
  51881. import { Scene } from "babylonjs/scene";
  51882. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  51883. import { Color4 } from "babylonjs/Maths/math.color";
  51884. import { Mesh } from "babylonjs/Meshes/mesh";
  51885. /**
  51886. * Class containing static functions to help procedurally build meshes
  51887. */
  51888. export class RibbonBuilder {
  51889. /**
  51890. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51891. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51892. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51893. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51894. * * 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
  51895. * * 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
  51896. * * 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
  51897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51900. * * 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
  51901. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51902. * * 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
  51903. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51905. * @param name defines the name of the mesh
  51906. * @param options defines the options used to create the mesh
  51907. * @param scene defines the hosting scene
  51908. * @returns the ribbon mesh
  51909. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51910. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51911. */
  51912. static CreateRibbon(name: string, options: {
  51913. pathArray: Vector3[][];
  51914. closeArray?: boolean;
  51915. closePath?: boolean;
  51916. offset?: number;
  51917. updatable?: boolean;
  51918. sideOrientation?: number;
  51919. frontUVs?: Vector4;
  51920. backUVs?: Vector4;
  51921. instance?: Mesh;
  51922. invertUV?: boolean;
  51923. uvs?: Vector2[];
  51924. colors?: Color4[];
  51925. }, scene?: Nullable<Scene>): Mesh;
  51926. }
  51927. }
  51928. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51929. import { Nullable } from "babylonjs/types";
  51930. import { Scene } from "babylonjs/scene";
  51931. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  51932. import { Mesh } from "babylonjs/Meshes/mesh";
  51933. /**
  51934. * Class containing static functions to help procedurally build meshes
  51935. */
  51936. export class ShapeBuilder {
  51937. /**
  51938. * 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.
  51939. * * 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.
  51940. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51941. * * 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.
  51942. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51943. * * 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
  51944. * * 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
  51945. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51950. * @param name defines the name of the mesh
  51951. * @param options defines the options used to create the mesh
  51952. * @param scene defines the hosting scene
  51953. * @returns the extruded shape mesh
  51954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51956. */
  51957. static ExtrudeShape(name: string, options: {
  51958. shape: Vector3[];
  51959. path: Vector3[];
  51960. scale?: number;
  51961. rotation?: number;
  51962. cap?: number;
  51963. updatable?: boolean;
  51964. sideOrientation?: number;
  51965. frontUVs?: Vector4;
  51966. backUVs?: Vector4;
  51967. instance?: Mesh;
  51968. invertUV?: boolean;
  51969. }, scene?: Nullable<Scene>): Mesh;
  51970. /**
  51971. * Creates an custom extruded shape mesh.
  51972. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51973. * * 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.
  51974. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51975. * * 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
  51976. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51977. * * 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
  51978. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51979. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51980. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51981. * * 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
  51982. * * 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
  51983. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51985. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51986. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51988. * @param name defines the name of the mesh
  51989. * @param options defines the options used to create the mesh
  51990. * @param scene defines the hosting scene
  51991. * @returns the custom extruded shape mesh
  51992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51995. */
  51996. static ExtrudeShapeCustom(name: string, options: {
  51997. shape: Vector3[];
  51998. path: Vector3[];
  51999. scaleFunction?: any;
  52000. rotationFunction?: any;
  52001. ribbonCloseArray?: boolean;
  52002. ribbonClosePath?: boolean;
  52003. cap?: number;
  52004. updatable?: boolean;
  52005. sideOrientation?: number;
  52006. frontUVs?: Vector4;
  52007. backUVs?: Vector4;
  52008. instance?: Mesh;
  52009. invertUV?: boolean;
  52010. }, scene?: Nullable<Scene>): Mesh;
  52011. private static _ExtrudeShapeGeneric;
  52012. }
  52013. }
  52014. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52015. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52016. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52017. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52018. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52019. import { Nullable } from "babylonjs/types";
  52020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52021. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52022. /**
  52023. * AmmoJS Physics plugin
  52024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52025. * @see https://github.com/kripken/ammo.js/
  52026. */
  52027. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52028. private _useDeltaForWorldStep;
  52029. /**
  52030. * Reference to the Ammo library
  52031. */
  52032. bjsAMMO: any;
  52033. /**
  52034. * Created ammoJS world which physics bodies are added to
  52035. */
  52036. world: any;
  52037. /**
  52038. * Name of the plugin
  52039. */
  52040. name: string;
  52041. private _timeStep;
  52042. private _fixedTimeStep;
  52043. private _maxSteps;
  52044. private _tmpQuaternion;
  52045. private _tmpAmmoTransform;
  52046. private _tmpAmmoQuaternion;
  52047. private _tmpAmmoConcreteContactResultCallback;
  52048. private _collisionConfiguration;
  52049. private _dispatcher;
  52050. private _overlappingPairCache;
  52051. private _solver;
  52052. private _softBodySolver;
  52053. private _tmpAmmoVectorA;
  52054. private _tmpAmmoVectorB;
  52055. private _tmpAmmoVectorC;
  52056. private _tmpAmmoVectorD;
  52057. private _tmpContactCallbackResult;
  52058. private _tmpAmmoVectorRCA;
  52059. private _tmpAmmoVectorRCB;
  52060. private _raycastResult;
  52061. private static readonly DISABLE_COLLISION_FLAG;
  52062. private static readonly KINEMATIC_FLAG;
  52063. private static readonly DISABLE_DEACTIVATION_FLAG;
  52064. /**
  52065. * Initializes the ammoJS plugin
  52066. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52067. * @param ammoInjection can be used to inject your own ammo reference
  52068. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52069. */
  52070. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52071. /**
  52072. * Sets the gravity of the physics world (m/(s^2))
  52073. * @param gravity Gravity to set
  52074. */
  52075. setGravity(gravity: Vector3): void;
  52076. /**
  52077. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52078. * @param timeStep timestep to use in seconds
  52079. */
  52080. setTimeStep(timeStep: number): void;
  52081. /**
  52082. * 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)
  52083. * @param fixedTimeStep fixedTimeStep to use in seconds
  52084. */
  52085. setFixedTimeStep(fixedTimeStep: number): void;
  52086. /**
  52087. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52088. * @param maxSteps the maximum number of steps by the physics engine per frame
  52089. */
  52090. setMaxSteps(maxSteps: number): void;
  52091. /**
  52092. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52093. * @returns the current timestep in seconds
  52094. */
  52095. getTimeStep(): number;
  52096. private _isImpostorInContact;
  52097. private _isImpostorPairInContact;
  52098. private _stepSimulation;
  52099. /**
  52100. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52101. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52102. * After the step the babylon meshes are set to the position of the physics imposters
  52103. * @param delta amount of time to step forward
  52104. * @param impostors array of imposters to update before/after the step
  52105. */
  52106. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52107. /**
  52108. * Update babylon mesh to match physics world object
  52109. * @param impostor imposter to match
  52110. */
  52111. private _afterSoftStep;
  52112. /**
  52113. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52114. * @param impostor imposter to match
  52115. */
  52116. private _ropeStep;
  52117. /**
  52118. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52119. * @param impostor imposter to match
  52120. */
  52121. private _softbodyOrClothStep;
  52122. private _tmpVector;
  52123. private _tmpMatrix;
  52124. /**
  52125. * Applies an impulse on the imposter
  52126. * @param impostor imposter to apply impulse to
  52127. * @param force amount of force to be applied to the imposter
  52128. * @param contactPoint the location to apply the impulse on the imposter
  52129. */
  52130. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52131. /**
  52132. * Applies a force on the imposter
  52133. * @param impostor imposter to apply force
  52134. * @param force amount of force to be applied to the imposter
  52135. * @param contactPoint the location to apply the force on the imposter
  52136. */
  52137. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52138. /**
  52139. * Creates a physics body using the plugin
  52140. * @param impostor the imposter to create the physics body on
  52141. */
  52142. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52143. /**
  52144. * Removes the physics body from the imposter and disposes of the body's memory
  52145. * @param impostor imposter to remove the physics body from
  52146. */
  52147. removePhysicsBody(impostor: PhysicsImpostor): void;
  52148. /**
  52149. * Generates a joint
  52150. * @param impostorJoint the imposter joint to create the joint with
  52151. */
  52152. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52153. /**
  52154. * Removes a joint
  52155. * @param impostorJoint the imposter joint to remove the joint from
  52156. */
  52157. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52158. private _addMeshVerts;
  52159. /**
  52160. * Initialise the soft body vertices to match its object's (mesh) vertices
  52161. * Softbody vertices (nodes) are in world space and to match this
  52162. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52163. * @param impostor to create the softbody for
  52164. */
  52165. private _softVertexData;
  52166. /**
  52167. * Create an impostor's soft body
  52168. * @param impostor to create the softbody for
  52169. */
  52170. private _createSoftbody;
  52171. /**
  52172. * Create cloth for an impostor
  52173. * @param impostor to create the softbody for
  52174. */
  52175. private _createCloth;
  52176. /**
  52177. * Create rope for an impostor
  52178. * @param impostor to create the softbody for
  52179. */
  52180. private _createRope;
  52181. private _addHullVerts;
  52182. private _createShape;
  52183. /**
  52184. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52185. * @param impostor imposter containing the physics body and babylon object
  52186. */
  52187. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52188. /**
  52189. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52190. * @param impostor imposter containing the physics body and babylon object
  52191. * @param newPosition new position
  52192. * @param newRotation new rotation
  52193. */
  52194. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52195. /**
  52196. * If this plugin is supported
  52197. * @returns true if its supported
  52198. */
  52199. isSupported(): boolean;
  52200. /**
  52201. * Sets the linear velocity of the physics body
  52202. * @param impostor imposter to set the velocity on
  52203. * @param velocity velocity to set
  52204. */
  52205. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52206. /**
  52207. * Sets the angular velocity of the physics body
  52208. * @param impostor imposter to set the velocity on
  52209. * @param velocity velocity to set
  52210. */
  52211. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52212. /**
  52213. * gets the linear velocity
  52214. * @param impostor imposter to get linear velocity from
  52215. * @returns linear velocity
  52216. */
  52217. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52218. /**
  52219. * gets the angular velocity
  52220. * @param impostor imposter to get angular velocity from
  52221. * @returns angular velocity
  52222. */
  52223. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52224. /**
  52225. * Sets the mass of physics body
  52226. * @param impostor imposter to set the mass on
  52227. * @param mass mass to set
  52228. */
  52229. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52230. /**
  52231. * Gets the mass of the physics body
  52232. * @param impostor imposter to get the mass from
  52233. * @returns mass
  52234. */
  52235. getBodyMass(impostor: PhysicsImpostor): number;
  52236. /**
  52237. * Gets friction of the impostor
  52238. * @param impostor impostor to get friction from
  52239. * @returns friction value
  52240. */
  52241. getBodyFriction(impostor: PhysicsImpostor): number;
  52242. /**
  52243. * Sets friction of the impostor
  52244. * @param impostor impostor to set friction on
  52245. * @param friction friction value
  52246. */
  52247. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52248. /**
  52249. * Gets restitution of the impostor
  52250. * @param impostor impostor to get restitution from
  52251. * @returns restitution value
  52252. */
  52253. getBodyRestitution(impostor: PhysicsImpostor): number;
  52254. /**
  52255. * Sets resitution of the impostor
  52256. * @param impostor impostor to set resitution on
  52257. * @param restitution resitution value
  52258. */
  52259. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52260. /**
  52261. * Gets pressure inside the impostor
  52262. * @param impostor impostor to get pressure from
  52263. * @returns pressure value
  52264. */
  52265. getBodyPressure(impostor: PhysicsImpostor): number;
  52266. /**
  52267. * Sets pressure inside a soft body impostor
  52268. * Cloth and rope must remain 0 pressure
  52269. * @param impostor impostor to set pressure on
  52270. * @param pressure pressure value
  52271. */
  52272. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52273. /**
  52274. * Gets stiffness of the impostor
  52275. * @param impostor impostor to get stiffness from
  52276. * @returns pressure value
  52277. */
  52278. getBodyStiffness(impostor: PhysicsImpostor): number;
  52279. /**
  52280. * Sets stiffness of the impostor
  52281. * @param impostor impostor to set stiffness on
  52282. * @param stiffness stiffness value from 0 to 1
  52283. */
  52284. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52285. /**
  52286. * Gets velocityIterations of the impostor
  52287. * @param impostor impostor to get velocity iterations from
  52288. * @returns velocityIterations value
  52289. */
  52290. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52291. /**
  52292. * Sets velocityIterations of the impostor
  52293. * @param impostor impostor to set velocity iterations on
  52294. * @param velocityIterations velocityIterations value
  52295. */
  52296. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52297. /**
  52298. * Gets positionIterations of the impostor
  52299. * @param impostor impostor to get position iterations from
  52300. * @returns positionIterations value
  52301. */
  52302. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52303. /**
  52304. * Sets positionIterations of the impostor
  52305. * @param impostor impostor to set position on
  52306. * @param positionIterations positionIterations value
  52307. */
  52308. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52309. /**
  52310. * Append an anchor to a cloth object
  52311. * @param impostor is the cloth impostor to add anchor to
  52312. * @param otherImpostor is the rigid impostor to anchor to
  52313. * @param width ratio across width from 0 to 1
  52314. * @param height ratio up height from 0 to 1
  52315. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52316. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52317. */
  52318. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52319. /**
  52320. * Append an hook to a rope object
  52321. * @param impostor is the rope impostor to add hook to
  52322. * @param otherImpostor is the rigid impostor to hook to
  52323. * @param length ratio along the rope from 0 to 1
  52324. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52325. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52326. */
  52327. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52328. /**
  52329. * Sleeps the physics body and stops it from being active
  52330. * @param impostor impostor to sleep
  52331. */
  52332. sleepBody(impostor: PhysicsImpostor): void;
  52333. /**
  52334. * Activates the physics body
  52335. * @param impostor impostor to activate
  52336. */
  52337. wakeUpBody(impostor: PhysicsImpostor): void;
  52338. /**
  52339. * Updates the distance parameters of the joint
  52340. * @param joint joint to update
  52341. * @param maxDistance maximum distance of the joint
  52342. * @param minDistance minimum distance of the joint
  52343. */
  52344. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52345. /**
  52346. * Sets a motor on the joint
  52347. * @param joint joint to set motor on
  52348. * @param speed speed of the motor
  52349. * @param maxForce maximum force of the motor
  52350. * @param motorIndex index of the motor
  52351. */
  52352. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52353. /**
  52354. * Sets the motors limit
  52355. * @param joint joint to set limit on
  52356. * @param upperLimit upper limit
  52357. * @param lowerLimit lower limit
  52358. */
  52359. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52360. /**
  52361. * Syncs the position and rotation of a mesh with the impostor
  52362. * @param mesh mesh to sync
  52363. * @param impostor impostor to update the mesh with
  52364. */
  52365. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52366. /**
  52367. * Gets the radius of the impostor
  52368. * @param impostor impostor to get radius from
  52369. * @returns the radius
  52370. */
  52371. getRadius(impostor: PhysicsImpostor): number;
  52372. /**
  52373. * Gets the box size of the impostor
  52374. * @param impostor impostor to get box size from
  52375. * @param result the resulting box size
  52376. */
  52377. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52378. /**
  52379. * Disposes of the impostor
  52380. */
  52381. dispose(): void;
  52382. /**
  52383. * Does a raycast in the physics world
  52384. * @param from when should the ray start?
  52385. * @param to when should the ray end?
  52386. * @returns PhysicsRaycastResult
  52387. */
  52388. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52389. }
  52390. }
  52391. declare module "babylonjs/Probes/reflectionProbe" {
  52392. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52393. import { Vector3 } from "babylonjs/Maths/math.vector";
  52394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52395. import { Nullable } from "babylonjs/types";
  52396. import { Scene } from "babylonjs/scene";
  52397. module "babylonjs/abstractScene" {
  52398. interface AbstractScene {
  52399. /**
  52400. * The list of reflection probes added to the scene
  52401. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52402. */
  52403. reflectionProbes: Array<ReflectionProbe>;
  52404. /**
  52405. * Removes the given reflection probe from this scene.
  52406. * @param toRemove The reflection probe to remove
  52407. * @returns The index of the removed reflection probe
  52408. */
  52409. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52410. /**
  52411. * Adds the given reflection probe to this scene.
  52412. * @param newReflectionProbe The reflection probe to add
  52413. */
  52414. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52415. }
  52416. }
  52417. /**
  52418. * Class used to generate realtime reflection / refraction cube textures
  52419. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52420. */
  52421. export class ReflectionProbe {
  52422. /** defines the name of the probe */
  52423. name: string;
  52424. private _scene;
  52425. private _renderTargetTexture;
  52426. private _projectionMatrix;
  52427. private _viewMatrix;
  52428. private _target;
  52429. private _add;
  52430. private _attachedMesh;
  52431. private _invertYAxis;
  52432. /** Gets or sets probe position (center of the cube map) */
  52433. position: Vector3;
  52434. /**
  52435. * Creates a new reflection probe
  52436. * @param name defines the name of the probe
  52437. * @param size defines the texture resolution (for each face)
  52438. * @param scene defines the hosting scene
  52439. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52440. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52441. */
  52442. constructor(
  52443. /** defines the name of the probe */
  52444. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52445. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52446. samples: number;
  52447. /** Gets or sets the refresh rate to use (on every frame by default) */
  52448. refreshRate: number;
  52449. /**
  52450. * Gets the hosting scene
  52451. * @returns a Scene
  52452. */
  52453. getScene(): Scene;
  52454. /** Gets the internal CubeTexture used to render to */
  52455. readonly cubeTexture: RenderTargetTexture;
  52456. /** Gets the list of meshes to render */
  52457. readonly renderList: Nullable<AbstractMesh[]>;
  52458. /**
  52459. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52460. * @param mesh defines the mesh to attach to
  52461. */
  52462. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52463. /**
  52464. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52465. * @param renderingGroupId The rendering group id corresponding to its index
  52466. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52467. */
  52468. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52469. /**
  52470. * Clean all associated resources
  52471. */
  52472. dispose(): void;
  52473. /**
  52474. * Converts the reflection probe information to a readable string for debug purpose.
  52475. * @param fullDetails Supports for multiple levels of logging within scene loading
  52476. * @returns the human readable reflection probe info
  52477. */
  52478. toString(fullDetails?: boolean): string;
  52479. /**
  52480. * Get the class name of the relfection probe.
  52481. * @returns "ReflectionProbe"
  52482. */
  52483. getClassName(): string;
  52484. /**
  52485. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52486. * @returns The JSON representation of the texture
  52487. */
  52488. serialize(): any;
  52489. /**
  52490. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52491. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52492. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52493. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52494. * @returns The parsed reflection probe if successful
  52495. */
  52496. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52497. }
  52498. }
  52499. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52500. /** @hidden */
  52501. export var _BabylonLoaderRegistered: boolean;
  52502. }
  52503. declare module "babylonjs/Loading/Plugins/index" {
  52504. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52505. }
  52506. declare module "babylonjs/Loading/index" {
  52507. export * from "babylonjs/Loading/loadingScreen";
  52508. export * from "babylonjs/Loading/Plugins/index";
  52509. export * from "babylonjs/Loading/sceneLoader";
  52510. export * from "babylonjs/Loading/sceneLoaderFlags";
  52511. }
  52512. declare module "babylonjs/Materials/Background/index" {
  52513. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52514. }
  52515. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52516. import { Scene } from "babylonjs/scene";
  52517. import { Color3 } from "babylonjs/Maths/math.color";
  52518. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52519. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52520. /**
  52521. * The Physically based simple base material of BJS.
  52522. *
  52523. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52524. * It is used as the base class for both the specGloss and metalRough conventions.
  52525. */
  52526. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52527. /**
  52528. * Number of Simultaneous lights allowed on the material.
  52529. */
  52530. maxSimultaneousLights: number;
  52531. /**
  52532. * If sets to true, disables all the lights affecting the material.
  52533. */
  52534. disableLighting: boolean;
  52535. /**
  52536. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52537. */
  52538. environmentTexture: BaseTexture;
  52539. /**
  52540. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52541. */
  52542. invertNormalMapX: boolean;
  52543. /**
  52544. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52545. */
  52546. invertNormalMapY: boolean;
  52547. /**
  52548. * Normal map used in the model.
  52549. */
  52550. normalTexture: BaseTexture;
  52551. /**
  52552. * Emissivie color used to self-illuminate the model.
  52553. */
  52554. emissiveColor: Color3;
  52555. /**
  52556. * Emissivie texture used to self-illuminate the model.
  52557. */
  52558. emissiveTexture: BaseTexture;
  52559. /**
  52560. * Occlusion Channel Strenght.
  52561. */
  52562. occlusionStrength: number;
  52563. /**
  52564. * Occlusion Texture of the material (adding extra occlusion effects).
  52565. */
  52566. occlusionTexture: BaseTexture;
  52567. /**
  52568. * Defines the alpha limits in alpha test mode.
  52569. */
  52570. alphaCutOff: number;
  52571. /**
  52572. * Gets the current double sided mode.
  52573. */
  52574. /**
  52575. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52576. */
  52577. doubleSided: boolean;
  52578. /**
  52579. * Stores the pre-calculated light information of a mesh in a texture.
  52580. */
  52581. lightmapTexture: BaseTexture;
  52582. /**
  52583. * If true, the light map contains occlusion information instead of lighting info.
  52584. */
  52585. useLightmapAsShadowmap: boolean;
  52586. /**
  52587. * Instantiates a new PBRMaterial instance.
  52588. *
  52589. * @param name The material name
  52590. * @param scene The scene the material will be use in.
  52591. */
  52592. constructor(name: string, scene: Scene);
  52593. getClassName(): string;
  52594. }
  52595. }
  52596. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52597. import { Scene } from "babylonjs/scene";
  52598. import { Color3 } from "babylonjs/Maths/math.color";
  52599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52600. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52601. /**
  52602. * The PBR material of BJS following the metal roughness convention.
  52603. *
  52604. * This fits to the PBR convention in the GLTF definition:
  52605. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52606. */
  52607. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52608. /**
  52609. * The base color has two different interpretations depending on the value of metalness.
  52610. * When the material is a metal, the base color is the specific measured reflectance value
  52611. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52612. * of the material.
  52613. */
  52614. baseColor: Color3;
  52615. /**
  52616. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52617. * well as opacity information in the alpha channel.
  52618. */
  52619. baseTexture: BaseTexture;
  52620. /**
  52621. * Specifies the metallic scalar value of the material.
  52622. * Can also be used to scale the metalness values of the metallic texture.
  52623. */
  52624. metallic: number;
  52625. /**
  52626. * Specifies the roughness scalar value of the material.
  52627. * Can also be used to scale the roughness values of the metallic texture.
  52628. */
  52629. roughness: number;
  52630. /**
  52631. * Texture containing both the metallic value in the B channel and the
  52632. * roughness value in the G channel to keep better precision.
  52633. */
  52634. metallicRoughnessTexture: BaseTexture;
  52635. /**
  52636. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52637. *
  52638. * @param name The material name
  52639. * @param scene The scene the material will be use in.
  52640. */
  52641. constructor(name: string, scene: Scene);
  52642. /**
  52643. * Return the currrent class name of the material.
  52644. */
  52645. getClassName(): string;
  52646. /**
  52647. * Makes a duplicate of the current material.
  52648. * @param name - name to use for the new material.
  52649. */
  52650. clone(name: string): PBRMetallicRoughnessMaterial;
  52651. /**
  52652. * Serialize the material to a parsable JSON object.
  52653. */
  52654. serialize(): any;
  52655. /**
  52656. * Parses a JSON object correponding to the serialize function.
  52657. */
  52658. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52659. }
  52660. }
  52661. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52662. import { Scene } from "babylonjs/scene";
  52663. import { Color3 } from "babylonjs/Maths/math.color";
  52664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52665. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52666. /**
  52667. * The PBR material of BJS following the specular glossiness convention.
  52668. *
  52669. * This fits to the PBR convention in the GLTF definition:
  52670. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52671. */
  52672. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52673. /**
  52674. * Specifies the diffuse color of the material.
  52675. */
  52676. diffuseColor: Color3;
  52677. /**
  52678. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52679. * channel.
  52680. */
  52681. diffuseTexture: BaseTexture;
  52682. /**
  52683. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52684. */
  52685. specularColor: Color3;
  52686. /**
  52687. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52688. */
  52689. glossiness: number;
  52690. /**
  52691. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52692. */
  52693. specularGlossinessTexture: BaseTexture;
  52694. /**
  52695. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52696. *
  52697. * @param name The material name
  52698. * @param scene The scene the material will be use in.
  52699. */
  52700. constructor(name: string, scene: Scene);
  52701. /**
  52702. * Return the currrent class name of the material.
  52703. */
  52704. getClassName(): string;
  52705. /**
  52706. * Makes a duplicate of the current material.
  52707. * @param name - name to use for the new material.
  52708. */
  52709. clone(name: string): PBRSpecularGlossinessMaterial;
  52710. /**
  52711. * Serialize the material to a parsable JSON object.
  52712. */
  52713. serialize(): any;
  52714. /**
  52715. * Parses a JSON object correponding to the serialize function.
  52716. */
  52717. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52718. }
  52719. }
  52720. declare module "babylonjs/Materials/PBR/index" {
  52721. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52722. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52723. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52724. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52725. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52726. }
  52727. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52728. import { Nullable } from "babylonjs/types";
  52729. import { Scene } from "babylonjs/scene";
  52730. import { Matrix } from "babylonjs/Maths/math.vector";
  52731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52732. /**
  52733. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52734. * It can help converting any input color in a desired output one. This can then be used to create effects
  52735. * from sepia, black and white to sixties or futuristic rendering...
  52736. *
  52737. * The only supported format is currently 3dl.
  52738. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52739. */
  52740. export class ColorGradingTexture extends BaseTexture {
  52741. /**
  52742. * The current texture matrix. (will always be identity in color grading texture)
  52743. */
  52744. private _textureMatrix;
  52745. /**
  52746. * The texture URL.
  52747. */
  52748. url: string;
  52749. /**
  52750. * Empty line regex stored for GC.
  52751. */
  52752. private static _noneEmptyLineRegex;
  52753. private _engine;
  52754. /**
  52755. * Instantiates a ColorGradingTexture from the following parameters.
  52756. *
  52757. * @param url The location of the color gradind data (currently only supporting 3dl)
  52758. * @param scene The scene the texture will be used in
  52759. */
  52760. constructor(url: string, scene: Scene);
  52761. /**
  52762. * Returns the texture matrix used in most of the material.
  52763. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52764. */
  52765. getTextureMatrix(): Matrix;
  52766. /**
  52767. * Occurs when the file being loaded is a .3dl LUT file.
  52768. */
  52769. private load3dlTexture;
  52770. /**
  52771. * Starts the loading process of the texture.
  52772. */
  52773. private loadTexture;
  52774. /**
  52775. * Clones the color gradind texture.
  52776. */
  52777. clone(): ColorGradingTexture;
  52778. /**
  52779. * Called during delayed load for textures.
  52780. */
  52781. delayLoad(): void;
  52782. /**
  52783. * Parses a color grading texture serialized by Babylon.
  52784. * @param parsedTexture The texture information being parsedTexture
  52785. * @param scene The scene to load the texture in
  52786. * @param rootUrl The root url of the data assets to load
  52787. * @return A color gradind texture
  52788. */
  52789. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52790. /**
  52791. * Serializes the LUT texture to json format.
  52792. */
  52793. serialize(): any;
  52794. }
  52795. }
  52796. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52798. import { Scene } from "babylonjs/scene";
  52799. import { Nullable } from "babylonjs/types";
  52800. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52801. /**
  52802. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52803. */
  52804. export class EquiRectangularCubeTexture extends BaseTexture {
  52805. /** The six faces of the cube. */
  52806. private static _FacesMapping;
  52807. private _noMipmap;
  52808. private _onLoad;
  52809. private _onError;
  52810. /** The size of the cubemap. */
  52811. private _size;
  52812. /** The buffer of the image. */
  52813. private _buffer;
  52814. /** The width of the input image. */
  52815. private _width;
  52816. /** The height of the input image. */
  52817. private _height;
  52818. /** The URL to the image. */
  52819. url: string;
  52820. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52821. coordinatesMode: number;
  52822. /**
  52823. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52824. * @param url The location of the image
  52825. * @param scene The scene the texture will be used in
  52826. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52827. * @param noMipmap Forces to not generate the mipmap if true
  52828. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52829. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52830. * @param onLoad — defines a callback called when texture is loaded
  52831. * @param onError — defines a callback called if there is an error
  52832. */
  52833. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52834. /**
  52835. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52836. */
  52837. private loadImage;
  52838. /**
  52839. * Convert the image buffer into a cubemap and create a CubeTexture.
  52840. */
  52841. private loadTexture;
  52842. /**
  52843. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52844. * @param buffer The ArrayBuffer that should be converted.
  52845. * @returns The buffer as Float32Array.
  52846. */
  52847. private getFloat32ArrayFromArrayBuffer;
  52848. /**
  52849. * Get the current class name of the texture useful for serialization or dynamic coding.
  52850. * @returns "EquiRectangularCubeTexture"
  52851. */
  52852. getClassName(): string;
  52853. /**
  52854. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52855. * @returns A clone of the current EquiRectangularCubeTexture.
  52856. */
  52857. clone(): EquiRectangularCubeTexture;
  52858. }
  52859. }
  52860. declare module "babylonjs/Misc/tga" {
  52861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52862. /**
  52863. * Based on jsTGALoader - Javascript loader for TGA file
  52864. * By Vincent Thibault
  52865. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52866. */
  52867. export class TGATools {
  52868. private static _TYPE_INDEXED;
  52869. private static _TYPE_RGB;
  52870. private static _TYPE_GREY;
  52871. private static _TYPE_RLE_INDEXED;
  52872. private static _TYPE_RLE_RGB;
  52873. private static _TYPE_RLE_GREY;
  52874. private static _ORIGIN_MASK;
  52875. private static _ORIGIN_SHIFT;
  52876. private static _ORIGIN_BL;
  52877. private static _ORIGIN_BR;
  52878. private static _ORIGIN_UL;
  52879. private static _ORIGIN_UR;
  52880. /**
  52881. * Gets the header of a TGA file
  52882. * @param data defines the TGA data
  52883. * @returns the header
  52884. */
  52885. static GetTGAHeader(data: Uint8Array): any;
  52886. /**
  52887. * Uploads TGA content to a Babylon Texture
  52888. * @hidden
  52889. */
  52890. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52891. /** @hidden */
  52892. 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;
  52893. /** @hidden */
  52894. 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;
  52895. /** @hidden */
  52896. 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;
  52897. /** @hidden */
  52898. 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;
  52899. /** @hidden */
  52900. 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;
  52901. /** @hidden */
  52902. 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;
  52903. }
  52904. }
  52905. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52906. import { Nullable } from "babylonjs/types";
  52907. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52908. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52909. /**
  52910. * Implementation of the TGA Texture Loader.
  52911. * @hidden
  52912. */
  52913. export class _TGATextureLoader implements IInternalTextureLoader {
  52914. /**
  52915. * Defines wether the loader supports cascade loading the different faces.
  52916. */
  52917. readonly supportCascades: boolean;
  52918. /**
  52919. * This returns if the loader support the current file information.
  52920. * @param extension defines the file extension of the file being loaded
  52921. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52922. * @param fallback defines the fallback internal texture if any
  52923. * @param isBase64 defines whether the texture is encoded as a base64
  52924. * @param isBuffer defines whether the texture data are stored as a buffer
  52925. * @returns true if the loader can load the specified file
  52926. */
  52927. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52928. /**
  52929. * Transform the url before loading if required.
  52930. * @param rootUrl the url of the texture
  52931. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52932. * @returns the transformed texture
  52933. */
  52934. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52935. /**
  52936. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52937. * @param rootUrl the url of the texture
  52938. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52939. * @returns the fallback texture
  52940. */
  52941. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52942. /**
  52943. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52944. * @param data contains the texture data
  52945. * @param texture defines the BabylonJS internal texture
  52946. * @param createPolynomials will be true if polynomials have been requested
  52947. * @param onLoad defines the callback to trigger once the texture is ready
  52948. * @param onError defines the callback to trigger in case of error
  52949. */
  52950. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52951. /**
  52952. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52953. * @param data contains the texture data
  52954. * @param texture defines the BabylonJS internal texture
  52955. * @param callback defines the method to call once ready to upload
  52956. */
  52957. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52958. }
  52959. }
  52960. declare module "babylonjs/Misc/basis" {
  52961. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52962. /**
  52963. * Info about the .basis files
  52964. */
  52965. class BasisFileInfo {
  52966. /**
  52967. * If the file has alpha
  52968. */
  52969. hasAlpha: boolean;
  52970. /**
  52971. * Info about each image of the basis file
  52972. */
  52973. images: Array<{
  52974. levels: Array<{
  52975. width: number;
  52976. height: number;
  52977. transcodedPixels: ArrayBufferView;
  52978. }>;
  52979. }>;
  52980. }
  52981. /**
  52982. * Result of transcoding a basis file
  52983. */
  52984. class TranscodeResult {
  52985. /**
  52986. * Info about the .basis file
  52987. */
  52988. fileInfo: BasisFileInfo;
  52989. /**
  52990. * Format to use when loading the file
  52991. */
  52992. format: number;
  52993. }
  52994. /**
  52995. * Configuration options for the Basis transcoder
  52996. */
  52997. export class BasisTranscodeConfiguration {
  52998. /**
  52999. * Supported compression formats used to determine the supported output format of the transcoder
  53000. */
  53001. supportedCompressionFormats?: {
  53002. /**
  53003. * etc1 compression format
  53004. */
  53005. etc1?: boolean;
  53006. /**
  53007. * s3tc compression format
  53008. */
  53009. s3tc?: boolean;
  53010. /**
  53011. * pvrtc compression format
  53012. */
  53013. pvrtc?: boolean;
  53014. /**
  53015. * etc2 compression format
  53016. */
  53017. etc2?: boolean;
  53018. };
  53019. /**
  53020. * If mipmap levels should be loaded for transcoded images (Default: true)
  53021. */
  53022. loadMipmapLevels?: boolean;
  53023. /**
  53024. * Index of a single image to load (Default: all images)
  53025. */
  53026. loadSingleImage?: number;
  53027. }
  53028. /**
  53029. * Used to load .Basis files
  53030. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53031. */
  53032. export class BasisTools {
  53033. private static _IgnoreSupportedFormats;
  53034. /**
  53035. * URL to use when loading the basis transcoder
  53036. */
  53037. static JSModuleURL: string;
  53038. /**
  53039. * URL to use when loading the wasm module for the transcoder
  53040. */
  53041. static WasmModuleURL: string;
  53042. /**
  53043. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53044. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53045. * @returns internal format corresponding to the Basis format
  53046. */
  53047. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53048. private static _WorkerPromise;
  53049. private static _Worker;
  53050. private static _actionId;
  53051. private static _CreateWorkerAsync;
  53052. /**
  53053. * Transcodes a loaded image file to compressed pixel data
  53054. * @param imageData image data to transcode
  53055. * @param config configuration options for the transcoding
  53056. * @returns a promise resulting in the transcoded image
  53057. */
  53058. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53059. /**
  53060. * Loads a texture from the transcode result
  53061. * @param texture texture load to
  53062. * @param transcodeResult the result of transcoding the basis file to load from
  53063. */
  53064. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53065. }
  53066. }
  53067. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53068. import { Nullable } from "babylonjs/types";
  53069. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53070. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53071. /**
  53072. * Loader for .basis file format
  53073. */
  53074. export class _BasisTextureLoader implements IInternalTextureLoader {
  53075. /**
  53076. * Defines whether the loader supports cascade loading the different faces.
  53077. */
  53078. readonly supportCascades: boolean;
  53079. /**
  53080. * This returns if the loader support the current file information.
  53081. * @param extension defines the file extension of the file being loaded
  53082. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53083. * @param fallback defines the fallback internal texture if any
  53084. * @param isBase64 defines whether the texture is encoded as a base64
  53085. * @param isBuffer defines whether the texture data are stored as a buffer
  53086. * @returns true if the loader can load the specified file
  53087. */
  53088. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53089. /**
  53090. * Transform the url before loading if required.
  53091. * @param rootUrl the url of the texture
  53092. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53093. * @returns the transformed texture
  53094. */
  53095. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53096. /**
  53097. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53098. * @param rootUrl the url of the texture
  53099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53100. * @returns the fallback texture
  53101. */
  53102. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53103. /**
  53104. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53105. * @param data contains the texture data
  53106. * @param texture defines the BabylonJS internal texture
  53107. * @param createPolynomials will be true if polynomials have been requested
  53108. * @param onLoad defines the callback to trigger once the texture is ready
  53109. * @param onError defines the callback to trigger in case of error
  53110. */
  53111. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53112. /**
  53113. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53114. * @param data contains the texture data
  53115. * @param texture defines the BabylonJS internal texture
  53116. * @param callback defines the method to call once ready to upload
  53117. */
  53118. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53119. }
  53120. }
  53121. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53122. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53123. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53124. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53125. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53126. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53127. }
  53128. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53129. import { Scene } from "babylonjs/scene";
  53130. import { Texture } from "babylonjs/Materials/Textures/texture";
  53131. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53132. /**
  53133. * 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.
  53134. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53135. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53136. */
  53137. export class CustomProceduralTexture extends ProceduralTexture {
  53138. private _animate;
  53139. private _time;
  53140. private _config;
  53141. private _texturePath;
  53142. /**
  53143. * Instantiates a new Custom Procedural Texture.
  53144. * 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.
  53145. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53146. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53147. * @param name Define the name of the texture
  53148. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53149. * @param size Define the size of the texture to create
  53150. * @param scene Define the scene the texture belongs to
  53151. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53152. * @param generateMipMaps Define if the texture should creates mip maps or not
  53153. */
  53154. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53155. private _loadJson;
  53156. /**
  53157. * Is the texture ready to be used ? (rendered at least once)
  53158. * @returns true if ready, otherwise, false.
  53159. */
  53160. isReady(): boolean;
  53161. /**
  53162. * Render the texture to its associated render target.
  53163. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53164. */
  53165. render(useCameraPostProcess?: boolean): void;
  53166. /**
  53167. * Update the list of dependant textures samplers in the shader.
  53168. */
  53169. updateTextures(): void;
  53170. /**
  53171. * Update the uniform values of the procedural texture in the shader.
  53172. */
  53173. updateShaderUniforms(): void;
  53174. /**
  53175. * Define if the texture animates or not.
  53176. */
  53177. animate: boolean;
  53178. }
  53179. }
  53180. declare module "babylonjs/Shaders/noise.fragment" {
  53181. /** @hidden */
  53182. export var noisePixelShader: {
  53183. name: string;
  53184. shader: string;
  53185. };
  53186. }
  53187. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53188. import { Nullable } from "babylonjs/types";
  53189. import { Scene } from "babylonjs/scene";
  53190. import { Texture } from "babylonjs/Materials/Textures/texture";
  53191. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53192. import "babylonjs/Shaders/noise.fragment";
  53193. /**
  53194. * Class used to generate noise procedural textures
  53195. */
  53196. export class NoiseProceduralTexture extends ProceduralTexture {
  53197. private _time;
  53198. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53199. brightness: number;
  53200. /** Defines the number of octaves to process */
  53201. octaves: number;
  53202. /** Defines the level of persistence (0.8 by default) */
  53203. persistence: number;
  53204. /** Gets or sets animation speed factor (default is 1) */
  53205. animationSpeedFactor: number;
  53206. /**
  53207. * Creates a new NoiseProceduralTexture
  53208. * @param name defines the name fo the texture
  53209. * @param size defines the size of the texture (default is 256)
  53210. * @param scene defines the hosting scene
  53211. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53212. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53213. */
  53214. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53215. private _updateShaderUniforms;
  53216. protected _getDefines(): string;
  53217. /** Generate the current state of the procedural texture */
  53218. render(useCameraPostProcess?: boolean): void;
  53219. /**
  53220. * Serializes this noise procedural texture
  53221. * @returns a serialized noise procedural texture object
  53222. */
  53223. serialize(): any;
  53224. /**
  53225. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53226. * @param parsedTexture defines parsed texture data
  53227. * @param scene defines the current scene
  53228. * @param rootUrl defines the root URL containing noise procedural texture information
  53229. * @returns a parsed NoiseProceduralTexture
  53230. */
  53231. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53232. }
  53233. }
  53234. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53235. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53236. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53237. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53238. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53239. }
  53240. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53241. import { Nullable } from "babylonjs/types";
  53242. import { Scene } from "babylonjs/scene";
  53243. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53244. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53245. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53246. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53247. /**
  53248. * Raw cube texture where the raw buffers are passed in
  53249. */
  53250. export class RawCubeTexture extends CubeTexture {
  53251. /**
  53252. * Creates a cube texture where the raw buffers are passed in.
  53253. * @param scene defines the scene the texture is attached to
  53254. * @param data defines the array of data to use to create each face
  53255. * @param size defines the size of the textures
  53256. * @param format defines the format of the data
  53257. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53258. * @param generateMipMaps defines if the engine should generate the mip levels
  53259. * @param invertY defines if data must be stored with Y axis inverted
  53260. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53261. * @param compression defines the compression used (null by default)
  53262. */
  53263. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53264. /**
  53265. * Updates the raw cube texture.
  53266. * @param data defines the data to store
  53267. * @param format defines the data format
  53268. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53269. * @param invertY defines if data must be stored with Y axis inverted
  53270. * @param compression defines the compression used (null by default)
  53271. * @param level defines which level of the texture to update
  53272. */
  53273. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53274. /**
  53275. * Updates a raw cube texture with RGBD encoded data.
  53276. * @param data defines the array of data [mipmap][face] to use to create each face
  53277. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53278. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53279. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53280. * @returns a promsie that resolves when the operation is complete
  53281. */
  53282. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53283. /**
  53284. * Clones the raw cube texture.
  53285. * @return a new cube texture
  53286. */
  53287. clone(): CubeTexture;
  53288. /** @hidden */
  53289. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53290. }
  53291. }
  53292. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53293. import { Scene } from "babylonjs/scene";
  53294. import { Texture } from "babylonjs/Materials/Textures/texture";
  53295. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53296. /**
  53297. * Class used to store 3D textures containing user data
  53298. */
  53299. export class RawTexture3D extends Texture {
  53300. /** Gets or sets the texture format to use */
  53301. format: number;
  53302. private _engine;
  53303. /**
  53304. * Create a new RawTexture3D
  53305. * @param data defines the data of the texture
  53306. * @param width defines the width of the texture
  53307. * @param height defines the height of the texture
  53308. * @param depth defines the depth of the texture
  53309. * @param format defines the texture format to use
  53310. * @param scene defines the hosting scene
  53311. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53312. * @param invertY defines if texture must be stored with Y axis inverted
  53313. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53314. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53315. */
  53316. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53317. /** Gets or sets the texture format to use */
  53318. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53319. /**
  53320. * Update the texture with new data
  53321. * @param data defines the data to store in the texture
  53322. */
  53323. update(data: ArrayBufferView): void;
  53324. }
  53325. }
  53326. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53327. import { Scene } from "babylonjs/scene";
  53328. import { Plane } from "babylonjs/Maths/math.plane";
  53329. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53330. /**
  53331. * Creates a refraction texture used by refraction channel of the standard material.
  53332. * It is like a mirror but to see through a material.
  53333. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53334. */
  53335. export class RefractionTexture extends RenderTargetTexture {
  53336. /**
  53337. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53338. * 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.
  53339. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53340. */
  53341. refractionPlane: Plane;
  53342. /**
  53343. * Define how deep under the surface we should see.
  53344. */
  53345. depth: number;
  53346. /**
  53347. * Creates a refraction texture used by refraction channel of the standard material.
  53348. * It is like a mirror but to see through a material.
  53349. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53350. * @param name Define the texture name
  53351. * @param size Define the size of the underlying texture
  53352. * @param scene Define the scene the refraction belongs to
  53353. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53354. */
  53355. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53356. /**
  53357. * Clone the refraction texture.
  53358. * @returns the cloned texture
  53359. */
  53360. clone(): RefractionTexture;
  53361. /**
  53362. * Serialize the texture to a JSON representation you could use in Parse later on
  53363. * @returns the serialized JSON representation
  53364. */
  53365. serialize(): any;
  53366. }
  53367. }
  53368. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53369. import { Nullable } from "babylonjs/types";
  53370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53371. import { Matrix } from "babylonjs/Maths/math.vector";
  53372. import { Engine } from "babylonjs/Engines/engine";
  53373. import { Scene } from "babylonjs/scene";
  53374. /**
  53375. * Defines the options related to the creation of an HtmlElementTexture
  53376. */
  53377. export interface IHtmlElementTextureOptions {
  53378. /**
  53379. * Defines wether mip maps should be created or not.
  53380. */
  53381. generateMipMaps?: boolean;
  53382. /**
  53383. * Defines the sampling mode of the texture.
  53384. */
  53385. samplingMode?: number;
  53386. /**
  53387. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53388. */
  53389. engine: Nullable<Engine>;
  53390. /**
  53391. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53392. */
  53393. scene: Nullable<Scene>;
  53394. }
  53395. /**
  53396. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53397. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53398. * is automatically managed.
  53399. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53400. * in your application.
  53401. *
  53402. * As the update is not automatic, you need to call them manually.
  53403. */
  53404. export class HtmlElementTexture extends BaseTexture {
  53405. /**
  53406. * The texture URL.
  53407. */
  53408. element: HTMLVideoElement | HTMLCanvasElement;
  53409. private static readonly DefaultOptions;
  53410. private _textureMatrix;
  53411. private _engine;
  53412. private _isVideo;
  53413. private _generateMipMaps;
  53414. private _samplingMode;
  53415. /**
  53416. * Instantiates a HtmlElementTexture from the following parameters.
  53417. *
  53418. * @param name Defines the name of the texture
  53419. * @param element Defines the video or canvas the texture is filled with
  53420. * @param options Defines the other none mandatory texture creation options
  53421. */
  53422. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53423. private _createInternalTexture;
  53424. /**
  53425. * Returns the texture matrix used in most of the material.
  53426. */
  53427. getTextureMatrix(): Matrix;
  53428. /**
  53429. * Updates the content of the texture.
  53430. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53431. */
  53432. update(invertY?: Nullable<boolean>): void;
  53433. }
  53434. }
  53435. declare module "babylonjs/Materials/Textures/index" {
  53436. export * from "babylonjs/Materials/Textures/baseTexture";
  53437. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53438. export * from "babylonjs/Materials/Textures/cubeTexture";
  53439. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53440. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53441. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53442. export * from "babylonjs/Materials/Textures/internalTexture";
  53443. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53444. export * from "babylonjs/Materials/Textures/Loaders/index";
  53445. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53446. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53447. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53448. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53449. export * from "babylonjs/Materials/Textures/rawTexture";
  53450. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53451. export * from "babylonjs/Materials/Textures/refractionTexture";
  53452. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53453. export * from "babylonjs/Materials/Textures/texture";
  53454. export * from "babylonjs/Materials/Textures/videoTexture";
  53455. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53456. }
  53457. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53458. /**
  53459. * Enum used to define the target of a block
  53460. */
  53461. export enum NodeMaterialBlockTargets {
  53462. /** Vertex shader */
  53463. Vertex = 1,
  53464. /** Fragment shader */
  53465. Fragment = 2,
  53466. /** Neutral */
  53467. Neutral = 4,
  53468. /** Vertex and Fragment */
  53469. VertexAndFragment = 3
  53470. }
  53471. }
  53472. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53473. /**
  53474. * Defines the kind of connection point for node based material
  53475. */
  53476. export enum NodeMaterialBlockConnectionPointTypes {
  53477. /** Float */
  53478. Float = 1,
  53479. /** Int */
  53480. Int = 2,
  53481. /** Vector2 */
  53482. Vector2 = 4,
  53483. /** Vector3 */
  53484. Vector3 = 8,
  53485. /** Vector4 */
  53486. Vector4 = 16,
  53487. /** Color3 */
  53488. Color3 = 32,
  53489. /** Color4 */
  53490. Color4 = 64,
  53491. /** Matrix */
  53492. Matrix = 128,
  53493. /** Vector3 or Color3 */
  53494. Vector3OrColor3 = 40,
  53495. /** Vector3 or Vector4 */
  53496. Vector3OrVector4 = 24,
  53497. /** Vector4 or Color4 */
  53498. Vector4OrColor4 = 80,
  53499. /** Color3 or Color4 */
  53500. Color3OrColor4 = 96,
  53501. /** Vector2 or Color3 or Color4 */
  53502. Vector2OrColor3OrColor4 = 100,
  53503. /** Vector3 or Color3 or Color4 or Vector4 */
  53504. Vector3OrColor3OrVector4OrColor4 = 120,
  53505. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  53506. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  53507. /** Detect type based on connection */
  53508. AutoDetect = 1024,
  53509. /** Output type that will be defined by input type */
  53510. BasedOnInput = 2048
  53511. }
  53512. }
  53513. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53515. /**
  53516. * Root class for all node material optimizers
  53517. */
  53518. export class NodeMaterialOptimizer {
  53519. /**
  53520. * Function used to optimize a NodeMaterial graph
  53521. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53522. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53523. */
  53524. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53525. }
  53526. }
  53527. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53531. /**
  53532. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53533. */
  53534. export class TransformBlock extends NodeMaterialBlock {
  53535. /**
  53536. * Defines the value to use to complement W value to transform it to a Vector4
  53537. */
  53538. complementW: number;
  53539. /**
  53540. * Defines the value to use to complement z value to transform it to a Vector4
  53541. */
  53542. complementZ: number;
  53543. /**
  53544. * Creates a new TransformBlock
  53545. * @param name defines the block name
  53546. */
  53547. constructor(name: string);
  53548. /**
  53549. * Gets the current class name
  53550. * @returns the class name
  53551. */
  53552. getClassName(): string;
  53553. /**
  53554. * Gets the vector input
  53555. */
  53556. readonly vector: NodeMaterialConnectionPoint;
  53557. /**
  53558. * Gets the output component
  53559. */
  53560. readonly output: NodeMaterialConnectionPoint;
  53561. /**
  53562. * Gets the matrix transform input
  53563. */
  53564. readonly transform: NodeMaterialConnectionPoint;
  53565. protected _buildBlock(state: NodeMaterialBuildState): this;
  53566. }
  53567. }
  53568. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53572. /**
  53573. * Block used to output the vertex position
  53574. */
  53575. export class VertexOutputBlock extends NodeMaterialBlock {
  53576. /**
  53577. * Creates a new VertexOutputBlock
  53578. * @param name defines the block name
  53579. */
  53580. constructor(name: string);
  53581. /**
  53582. * Gets the current class name
  53583. * @returns the class name
  53584. */
  53585. getClassName(): string;
  53586. /**
  53587. * Gets the vector input component
  53588. */
  53589. readonly vector: NodeMaterialConnectionPoint;
  53590. protected _buildBlock(state: NodeMaterialBuildState): this;
  53591. }
  53592. }
  53593. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53597. /**
  53598. * Block used to output the final color
  53599. */
  53600. export class FragmentOutputBlock extends NodeMaterialBlock {
  53601. /**
  53602. * Gets or sets a boolean indicating if this block will output an alpha value
  53603. */
  53604. alphaBlendingEnabled: boolean;
  53605. /**
  53606. * Create a new FragmentOutputBlock
  53607. * @param name defines the block name
  53608. */
  53609. constructor(name: string);
  53610. /**
  53611. * Gets the current class name
  53612. * @returns the class name
  53613. */
  53614. getClassName(): string;
  53615. /**
  53616. * Gets the color input component
  53617. */
  53618. readonly color: NodeMaterialConnectionPoint;
  53619. protected _buildBlock(state: NodeMaterialBuildState): this;
  53620. }
  53621. }
  53622. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53624. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53625. import { Scene } from "babylonjs/scene";
  53626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53627. import { Matrix } from "babylonjs/Maths/math.vector";
  53628. import { Mesh } from "babylonjs/Meshes/mesh";
  53629. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53630. import { Observable } from "babylonjs/Misc/observable";
  53631. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53632. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53633. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53634. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53635. import { Nullable } from "babylonjs/types";
  53636. /**
  53637. * Interface used to configure the node material editor
  53638. */
  53639. export interface INodeMaterialEditorOptions {
  53640. /** Define the URl to load node editor script */
  53641. editorURL?: string;
  53642. }
  53643. /** @hidden */
  53644. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53645. /** BONES */
  53646. NUM_BONE_INFLUENCERS: number;
  53647. BonesPerMesh: number;
  53648. BONETEXTURE: boolean;
  53649. /** MORPH TARGETS */
  53650. MORPHTARGETS: boolean;
  53651. MORPHTARGETS_NORMAL: boolean;
  53652. MORPHTARGETS_TANGENT: boolean;
  53653. MORPHTARGETS_UV: boolean;
  53654. NUM_MORPH_INFLUENCERS: number;
  53655. /** IMAGE PROCESSING */
  53656. IMAGEPROCESSING: boolean;
  53657. VIGNETTE: boolean;
  53658. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53659. VIGNETTEBLENDMODEOPAQUE: boolean;
  53660. TONEMAPPING: boolean;
  53661. TONEMAPPING_ACES: boolean;
  53662. CONTRAST: boolean;
  53663. EXPOSURE: boolean;
  53664. COLORCURVES: boolean;
  53665. COLORGRADING: boolean;
  53666. COLORGRADING3D: boolean;
  53667. SAMPLER3DGREENDEPTH: boolean;
  53668. SAMPLER3DBGRMAP: boolean;
  53669. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53670. constructor();
  53671. setValue(name: string, value: boolean): void;
  53672. }
  53673. /**
  53674. * Class used to configure NodeMaterial
  53675. */
  53676. export interface INodeMaterialOptions {
  53677. /**
  53678. * Defines if blocks should emit comments
  53679. */
  53680. emitComments: boolean;
  53681. }
  53682. /**
  53683. * Class used to create a node based material built by assembling shader blocks
  53684. */
  53685. export class NodeMaterial extends PushMaterial {
  53686. private _options;
  53687. private _vertexCompilationState;
  53688. private _fragmentCompilationState;
  53689. private _sharedData;
  53690. private _buildId;
  53691. private _buildWasSuccessful;
  53692. private _cachedWorldViewMatrix;
  53693. private _cachedWorldViewProjectionMatrix;
  53694. private _optimizers;
  53695. /** Define the URl to load node editor script */
  53696. static EditorURL: string;
  53697. private BJSNODEMATERIALEDITOR;
  53698. /** Get the inspector from bundle or global */
  53699. private _getGlobalNodeMaterialEditor;
  53700. /**
  53701. * Defines the maximum number of lights that can be used in the material
  53702. */
  53703. maxSimultaneousLights: number;
  53704. /**
  53705. * Observable raised when the material is built
  53706. */
  53707. onBuildObservable: Observable<NodeMaterial>;
  53708. /**
  53709. * Gets or sets the root nodes of the material vertex shader
  53710. */
  53711. _vertexOutputNodes: NodeMaterialBlock[];
  53712. /**
  53713. * Gets or sets the root nodes of the material fragment (pixel) shader
  53714. */
  53715. _fragmentOutputNodes: NodeMaterialBlock[];
  53716. /** Gets or sets options to control the node material overall behavior */
  53717. options: INodeMaterialOptions;
  53718. /**
  53719. * Default configuration related to image processing available in the standard Material.
  53720. */
  53721. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53722. /**
  53723. * Gets the image processing configuration used either in this material.
  53724. */
  53725. /**
  53726. * Sets the Default image processing configuration used either in the this material.
  53727. *
  53728. * If sets to null, the scene one is in use.
  53729. */
  53730. imageProcessingConfiguration: ImageProcessingConfiguration;
  53731. /**
  53732. * Create a new node based material
  53733. * @param name defines the material name
  53734. * @param scene defines the hosting scene
  53735. * @param options defines creation option
  53736. */
  53737. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53738. /**
  53739. * Gets the current class name of the material e.g. "NodeMaterial"
  53740. * @returns the class name
  53741. */
  53742. getClassName(): string;
  53743. /**
  53744. * Keep track of the image processing observer to allow dispose and replace.
  53745. */
  53746. private _imageProcessingObserver;
  53747. /**
  53748. * Attaches a new image processing configuration to the Standard Material.
  53749. * @param configuration
  53750. */
  53751. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53752. /**
  53753. * Adds a new optimizer to the list of optimizers
  53754. * @param optimizer defines the optimizers to add
  53755. * @returns the current material
  53756. */
  53757. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53758. /**
  53759. * Remove an optimizer from the list of optimizers
  53760. * @param optimizer defines the optimizers to remove
  53761. * @returns the current material
  53762. */
  53763. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53764. /**
  53765. * Add a new block to the list of output nodes
  53766. * @param node defines the node to add
  53767. * @returns the current material
  53768. */
  53769. addOutputNode(node: NodeMaterialBlock): this;
  53770. /**
  53771. * Remove a block from the list of root nodes
  53772. * @param node defines the node to remove
  53773. * @returns the current material
  53774. */
  53775. removeOutputNode(node: NodeMaterialBlock): this;
  53776. private _addVertexOutputNode;
  53777. private _removeVertexOutputNode;
  53778. private _addFragmentOutputNode;
  53779. private _removeFragmentOutputNode;
  53780. /**
  53781. * Specifies if the material will require alpha blending
  53782. * @returns a boolean specifying if alpha blending is needed
  53783. */
  53784. needAlphaBlending(): boolean;
  53785. /**
  53786. * Specifies if this material should be rendered in alpha test mode
  53787. * @returns a boolean specifying if an alpha test is needed.
  53788. */
  53789. needAlphaTesting(): boolean;
  53790. private _initializeBlock;
  53791. private _resetDualBlocks;
  53792. /**
  53793. * Build the material and generates the inner effect
  53794. * @param verbose defines if the build should log activity
  53795. */
  53796. build(verbose?: boolean): void;
  53797. /**
  53798. * Runs an otpimization phase to try to improve the shader code
  53799. */
  53800. optimize(): void;
  53801. private _prepareDefinesForAttributes;
  53802. /**
  53803. * Get if the submesh is ready to be used and all its information available.
  53804. * Child classes can use it to update shaders
  53805. * @param mesh defines the mesh to check
  53806. * @param subMesh defines which submesh to check
  53807. * @param useInstances specifies that instances should be used
  53808. * @returns a boolean indicating that the submesh is ready or not
  53809. */
  53810. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53811. /**
  53812. * Get a string representing the shaders built by the current node graph
  53813. */
  53814. readonly compiledShaders: string;
  53815. /**
  53816. * Binds the world matrix to the material
  53817. * @param world defines the world transformation matrix
  53818. */
  53819. bindOnlyWorldMatrix(world: Matrix): void;
  53820. /**
  53821. * Binds the submesh to this material by preparing the effect and shader to draw
  53822. * @param world defines the world transformation matrix
  53823. * @param mesh defines the mesh containing the submesh
  53824. * @param subMesh defines the submesh to bind the material to
  53825. */
  53826. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53827. /**
  53828. * Gets the active textures from the material
  53829. * @returns an array of textures
  53830. */
  53831. getActiveTextures(): BaseTexture[];
  53832. /**
  53833. * Specifies if the material uses a texture
  53834. * @param texture defines the texture to check against the material
  53835. * @returns a boolean specifying if the material uses the texture
  53836. */
  53837. hasTexture(texture: BaseTexture): boolean;
  53838. /**
  53839. * Disposes the material
  53840. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53841. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53842. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53843. */
  53844. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53845. /** Creates the node editor window. */
  53846. private _createNodeEditor;
  53847. /**
  53848. * Launch the node material editor
  53849. * @param config Define the configuration of the editor
  53850. * @return a promise fulfilled when the node editor is visible
  53851. */
  53852. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53853. /**
  53854. * Clear the current material
  53855. */
  53856. clear(): void;
  53857. /**
  53858. * Clear the current material and set it to a default state
  53859. */
  53860. setToDefault(): void;
  53861. private _gatherBlocks;
  53862. /**
  53863. * Serializes this material in a JSON representation
  53864. * @returns the serialized material object
  53865. */
  53866. serialize(): any;
  53867. /**
  53868. * Clear the current graph and load a new one from a serialization object
  53869. * @param source defines the JSON representation of the material
  53870. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53871. */
  53872. loadFromSerialization(source: any, rootUrl?: string): void;
  53873. /**
  53874. * Creates a node material from parsed material data
  53875. * @param source defines the JSON representation of the material
  53876. * @param scene defines the hosting scene
  53877. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53878. * @returns a new node material
  53879. */
  53880. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53881. }
  53882. }
  53883. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  53884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53889. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53890. import { Effect } from "babylonjs/Materials/effect";
  53891. import { Mesh } from "babylonjs/Meshes/mesh";
  53892. import { Nullable } from "babylonjs/types";
  53893. import { Scene } from "babylonjs/scene";
  53894. /**
  53895. * Block used to read a texture from a sampler
  53896. */
  53897. export class TextureBlock extends NodeMaterialBlock {
  53898. private _defineName;
  53899. private _samplerName;
  53900. private _transformedUVName;
  53901. private _textureTransformName;
  53902. private _textureInfoName;
  53903. private _mainUVName;
  53904. private _mainUVDefineName;
  53905. /**
  53906. * Gets or sets the texture associated with the node
  53907. */
  53908. texture: Nullable<BaseTexture>;
  53909. /**
  53910. * Create a new TextureBlock
  53911. * @param name defines the block name
  53912. */
  53913. constructor(name: string);
  53914. /**
  53915. * Gets the current class name
  53916. * @returns the class name
  53917. */
  53918. getClassName(): string;
  53919. /**
  53920. * Gets the uv input component
  53921. */
  53922. readonly uv: NodeMaterialConnectionPoint;
  53923. /**
  53924. * Gets the output component
  53925. */
  53926. readonly output: NodeMaterialConnectionPoint;
  53927. autoConfigure(): void;
  53928. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53930. isReady(): boolean;
  53931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53932. private _injectVertexCode;
  53933. private _writeOutput;
  53934. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53935. serialize(): any;
  53936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53937. }
  53938. }
  53939. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53942. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  53943. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  53944. /**
  53945. * Class used to store shared data between 2 NodeMaterialBuildState
  53946. */
  53947. export class NodeMaterialBuildStateSharedData {
  53948. /**
  53949. * Gets the list of emitted varyings
  53950. */
  53951. varyings: string[];
  53952. /**
  53953. * Gets the varying declaration string
  53954. */
  53955. varyingDeclaration: string;
  53956. /**
  53957. * Input blocks
  53958. */
  53959. inputBlocks: InputBlock[];
  53960. /**
  53961. * Input blocks
  53962. */
  53963. textureBlocks: TextureBlock[];
  53964. /**
  53965. * Bindable blocks (Blocks that need to set data to the effect)
  53966. */
  53967. bindableBlocks: NodeMaterialBlock[];
  53968. /**
  53969. * List of blocks that can provide a compilation fallback
  53970. */
  53971. blocksWithFallbacks: NodeMaterialBlock[];
  53972. /**
  53973. * List of blocks that can provide a define update
  53974. */
  53975. blocksWithDefines: NodeMaterialBlock[];
  53976. /**
  53977. * List of blocks that can provide a repeatable content
  53978. */
  53979. repeatableContentBlocks: NodeMaterialBlock[];
  53980. /**
  53981. * List of blocks that can provide a dynamic list of uniforms
  53982. */
  53983. dynamicUniformBlocks: NodeMaterialBlock[];
  53984. /**
  53985. * List of blocks that can block the isReady function for the material
  53986. */
  53987. blockingBlocks: NodeMaterialBlock[];
  53988. /**
  53989. * Build Id used to avoid multiple recompilations
  53990. */
  53991. buildId: number;
  53992. /** List of emitted variables */
  53993. variableNames: {
  53994. [key: string]: number;
  53995. };
  53996. /** List of emitted defines */
  53997. defineNames: {
  53998. [key: string]: number;
  53999. };
  54000. /** Should emit comments? */
  54001. emitComments: boolean;
  54002. /** Emit build activity */
  54003. verbose: boolean;
  54004. /**
  54005. * Gets the compilation hints emitted at compilation time
  54006. */
  54007. hints: {
  54008. needWorldViewMatrix: boolean;
  54009. needWorldViewProjectionMatrix: boolean;
  54010. needAlphaBlending: boolean;
  54011. needAlphaTesting: boolean;
  54012. };
  54013. /**
  54014. * List of compilation checks
  54015. */
  54016. checks: {
  54017. emitVertex: boolean;
  54018. emitFragment: boolean;
  54019. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54020. };
  54021. /** Creates a new shared data */
  54022. constructor();
  54023. /**
  54024. * Emits console errors and exceptions if there is a failing check
  54025. */
  54026. emitErrors(): void;
  54027. }
  54028. }
  54029. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54030. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54031. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54032. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54033. /**
  54034. * Class used to store node based material build state
  54035. */
  54036. export class NodeMaterialBuildState {
  54037. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54038. supportUniformBuffers: boolean;
  54039. /**
  54040. * Gets the list of emitted attributes
  54041. */
  54042. attributes: string[];
  54043. /**
  54044. * Gets the list of emitted uniforms
  54045. */
  54046. uniforms: string[];
  54047. /**
  54048. * Gets the list of emitted uniform buffers
  54049. */
  54050. uniformBuffers: string[];
  54051. /**
  54052. * Gets the list of emitted samplers
  54053. */
  54054. samplers: string[];
  54055. /**
  54056. * Gets the list of emitted functions
  54057. */
  54058. functions: {
  54059. [key: string]: string;
  54060. };
  54061. /**
  54062. * Gets the target of the compilation state
  54063. */
  54064. target: NodeMaterialBlockTargets;
  54065. /**
  54066. * Gets the list of emitted counters
  54067. */
  54068. counters: {
  54069. [key: string]: number;
  54070. };
  54071. /**
  54072. * Shared data between multiple NodeMaterialBuildState instances
  54073. */
  54074. sharedData: NodeMaterialBuildStateSharedData;
  54075. /** @hidden */
  54076. _vertexState: NodeMaterialBuildState;
  54077. /** @hidden */
  54078. _attributeDeclaration: string;
  54079. /** @hidden */
  54080. _uniformDeclaration: string;
  54081. /** @hidden */
  54082. _samplerDeclaration: string;
  54083. /** @hidden */
  54084. _varyingTransfer: string;
  54085. private _repeatableContentAnchorIndex;
  54086. /** @hidden */
  54087. _builtCompilationString: string;
  54088. /**
  54089. * Gets the emitted compilation strings
  54090. */
  54091. compilationString: string;
  54092. /**
  54093. * Finalize the compilation strings
  54094. * @param state defines the current compilation state
  54095. */
  54096. finalize(state: NodeMaterialBuildState): void;
  54097. /** @hidden */
  54098. readonly _repeatableContentAnchor: string;
  54099. /** @hidden */
  54100. _getFreeVariableName(prefix: string): string;
  54101. /** @hidden */
  54102. _getFreeDefineName(prefix: string): string;
  54103. /** @hidden */
  54104. _excludeVariableName(name: string): void;
  54105. /** @hidden */
  54106. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54107. /** @hidden */
  54108. _emitFunction(name: string, code: string, comments: string): void;
  54109. /** @hidden */
  54110. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54111. replaceStrings?: {
  54112. search: RegExp;
  54113. replace: string;
  54114. }[];
  54115. repeatKey?: string;
  54116. }): string;
  54117. /** @hidden */
  54118. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54119. repeatKey?: string;
  54120. removeAttributes?: boolean;
  54121. removeUniforms?: boolean;
  54122. removeVaryings?: boolean;
  54123. removeIfDef?: boolean;
  54124. replaceStrings?: {
  54125. search: RegExp;
  54126. replace: string;
  54127. }[];
  54128. }, storeKey?: string): void;
  54129. /** @hidden */
  54130. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54131. /** @hidden */
  54132. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54133. }
  54134. }
  54135. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54136. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54138. import { Nullable } from "babylonjs/types";
  54139. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54140. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54141. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54143. import { Mesh } from "babylonjs/Meshes/mesh";
  54144. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54145. import { Scene } from "babylonjs/scene";
  54146. /**
  54147. * Defines a block that can be used inside a node based material
  54148. */
  54149. export class NodeMaterialBlock {
  54150. private _buildId;
  54151. private _buildTarget;
  54152. private _target;
  54153. private _isFinalMerger;
  54154. private _isInput;
  54155. /** @hidden */
  54156. _inputs: NodeMaterialConnectionPoint[];
  54157. /** @hidden */
  54158. _outputs: NodeMaterialConnectionPoint[];
  54159. /**
  54160. * Gets or sets the name of the block
  54161. */
  54162. name: string;
  54163. /**
  54164. * Gets or sets the unique id of the node
  54165. */
  54166. uniqueId: number;
  54167. /**
  54168. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54169. */
  54170. readonly isFinalMerger: boolean;
  54171. /**
  54172. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54173. */
  54174. readonly isInput: boolean;
  54175. /**
  54176. * Gets or sets the build Id
  54177. */
  54178. buildId: number;
  54179. /**
  54180. * Gets or sets the target of the block
  54181. */
  54182. target: NodeMaterialBlockTargets;
  54183. /**
  54184. * Gets the list of input points
  54185. */
  54186. readonly inputs: NodeMaterialConnectionPoint[];
  54187. /** Gets the list of output points */
  54188. readonly outputs: NodeMaterialConnectionPoint[];
  54189. /**
  54190. * Find an input by its name
  54191. * @param name defines the name of the input to look for
  54192. * @returns the input or null if not found
  54193. */
  54194. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54195. /**
  54196. * Find an output by its name
  54197. * @param name defines the name of the outputto look for
  54198. * @returns the output or null if not found
  54199. */
  54200. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54201. /**
  54202. * Creates a new NodeMaterialBlock
  54203. * @param name defines the block name
  54204. * @param target defines the target of that block (Vertex by default)
  54205. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54206. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54207. */
  54208. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54209. /**
  54210. * Initialize the block and prepare the context for build
  54211. * @param state defines the state that will be used for the build
  54212. */
  54213. initialize(state: NodeMaterialBuildState): void;
  54214. /**
  54215. * Bind data to effect. Will only be called for blocks with isBindable === true
  54216. * @param effect defines the effect to bind data to
  54217. * @param nodeMaterial defines the hosting NodeMaterial
  54218. * @param mesh defines the mesh that will be rendered
  54219. */
  54220. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54221. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54222. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54223. protected _writeFloat(value: number): string;
  54224. /**
  54225. * Gets the current class name e.g. "NodeMaterialBlock"
  54226. * @returns the class name
  54227. */
  54228. getClassName(): string;
  54229. /**
  54230. * Register a new input. Must be called inside a block constructor
  54231. * @param name defines the connection point name
  54232. * @param type defines the connection point type
  54233. * @param isOptional defines a boolean indicating that this input can be omitted
  54234. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54235. * @returns the current block
  54236. */
  54237. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54238. /**
  54239. * Register a new output. Must be called inside a block constructor
  54240. * @param name defines the connection point name
  54241. * @param type defines the connection point type
  54242. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54243. * @returns the current block
  54244. */
  54245. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54246. /**
  54247. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54248. * @param forOutput defines an optional connection point to check compatibility with
  54249. * @returns the first available input or null
  54250. */
  54251. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54252. /**
  54253. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54254. * @param forBlock defines an optional block to check compatibility with
  54255. * @returns the first available input or null
  54256. */
  54257. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54258. /**
  54259. * Connect current block with another block
  54260. * @param other defines the block to connect with
  54261. * @param options define the various options to help pick the right connections
  54262. * @returns the current block
  54263. */
  54264. connectTo(other: NodeMaterialBlock, options?: {
  54265. input?: string;
  54266. output?: string;
  54267. outputSwizzle?: string;
  54268. }): this | undefined;
  54269. protected _buildBlock(state: NodeMaterialBuildState): void;
  54270. /**
  54271. * Add uniforms, samplers and uniform buffers at compilation time
  54272. * @param state defines the state to update
  54273. * @param nodeMaterial defines the node material requesting the update
  54274. * @param defines defines the material defines to update
  54275. */
  54276. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54277. /**
  54278. * Add potential fallbacks if shader compilation fails
  54279. * @param mesh defines the mesh to be rendered
  54280. * @param fallbacks defines the current prioritized list of fallbacks
  54281. */
  54282. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54283. /**
  54284. * Update defines for shader compilation
  54285. * @param mesh defines the mesh to be rendered
  54286. * @param nodeMaterial defines the node material requesting the update
  54287. * @param defines defines the material defines to update
  54288. * @param useInstances specifies that instances should be used
  54289. */
  54290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54291. /**
  54292. * Initialize defines for shader compilation
  54293. * @param mesh defines the mesh to be rendered
  54294. * @param nodeMaterial defines the node material requesting the update
  54295. * @param defines defines the material defines to be prepared
  54296. * @param useInstances specifies that instances should be used
  54297. */
  54298. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54299. /**
  54300. * Lets the block try to connect some inputs automatically
  54301. */
  54302. autoConfigure(): void;
  54303. /**
  54304. * Function called when a block is declared as repeatable content generator
  54305. * @param vertexShaderState defines the current compilation state for the vertex shader
  54306. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54307. * @param mesh defines the mesh to be rendered
  54308. * @param defines defines the material defines to update
  54309. */
  54310. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54311. /**
  54312. * Checks if the block is ready
  54313. * @param mesh defines the mesh to be rendered
  54314. * @param nodeMaterial defines the node material requesting the update
  54315. * @param defines defines the material defines to update
  54316. * @param useInstances specifies that instances should be used
  54317. * @returns true if the block is ready
  54318. */
  54319. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54320. private _processBuild;
  54321. /**
  54322. * Compile the current node and generate the shader code
  54323. * @param state defines the current compilation state (uniforms, samplers, current string)
  54324. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54325. * @returns true if already built
  54326. */
  54327. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54328. /**
  54329. * Serializes this block in a JSON representation
  54330. * @returns the serialized block object
  54331. */
  54332. serialize(): any;
  54333. /** @hidden */
  54334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54335. }
  54336. }
  54337. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54338. /**
  54339. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54340. */
  54341. export enum NodeMaterialBlockConnectionPointMode {
  54342. /** Value is an uniform */
  54343. Uniform = 0,
  54344. /** Value is a mesh attribute */
  54345. Attribute = 1,
  54346. /** Value is a varying between vertex and fragment shaders */
  54347. Varying = 2,
  54348. /** Mode is undefined */
  54349. Undefined = 3
  54350. }
  54351. }
  54352. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54353. /**
  54354. * Enum used to define well known values e.g. values automatically provided by the system
  54355. */
  54356. export enum NodeMaterialWellKnownValues {
  54357. /** World */
  54358. World = 1,
  54359. /** View */
  54360. View = 2,
  54361. /** Projection */
  54362. Projection = 3,
  54363. /** ViewProjection */
  54364. ViewProjection = 4,
  54365. /** WorldView */
  54366. WorldView = 5,
  54367. /** WorldViewProjection */
  54368. WorldViewProjection = 6,
  54369. /** CameraPosition */
  54370. CameraPosition = 7,
  54371. /** Fog Color */
  54372. FogColor = 8
  54373. }
  54374. }
  54375. declare module "babylonjs/Maths/math.vertexFormat" {
  54376. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  54377. /**
  54378. * Contains position and normal vectors for a vertex
  54379. */
  54380. export class PositionNormalVertex {
  54381. /** the position of the vertex (defaut: 0,0,0) */
  54382. position: Vector3;
  54383. /** the normal of the vertex (defaut: 0,1,0) */
  54384. normal: Vector3;
  54385. /**
  54386. * Creates a PositionNormalVertex
  54387. * @param position the position of the vertex (defaut: 0,0,0)
  54388. * @param normal the normal of the vertex (defaut: 0,1,0)
  54389. */
  54390. constructor(
  54391. /** the position of the vertex (defaut: 0,0,0) */
  54392. position?: Vector3,
  54393. /** the normal of the vertex (defaut: 0,1,0) */
  54394. normal?: Vector3);
  54395. /**
  54396. * Clones the PositionNormalVertex
  54397. * @returns the cloned PositionNormalVertex
  54398. */
  54399. clone(): PositionNormalVertex;
  54400. }
  54401. /**
  54402. * Contains position, normal and uv vectors for a vertex
  54403. */
  54404. export class PositionNormalTextureVertex {
  54405. /** the position of the vertex (defaut: 0,0,0) */
  54406. position: Vector3;
  54407. /** the normal of the vertex (defaut: 0,1,0) */
  54408. normal: Vector3;
  54409. /** the uv of the vertex (default: 0,0) */
  54410. uv: Vector2;
  54411. /**
  54412. * Creates a PositionNormalTextureVertex
  54413. * @param position the position of the vertex (defaut: 0,0,0)
  54414. * @param normal the normal of the vertex (defaut: 0,1,0)
  54415. * @param uv the uv of the vertex (default: 0,0)
  54416. */
  54417. constructor(
  54418. /** the position of the vertex (defaut: 0,0,0) */
  54419. position?: Vector3,
  54420. /** the normal of the vertex (defaut: 0,1,0) */
  54421. normal?: Vector3,
  54422. /** the uv of the vertex (default: 0,0) */
  54423. uv?: Vector2);
  54424. /**
  54425. * Clones the PositionNormalTextureVertex
  54426. * @returns the cloned PositionNormalTextureVertex
  54427. */
  54428. clone(): PositionNormalTextureVertex;
  54429. }
  54430. }
  54431. declare module "babylonjs/Maths/math" {
  54432. export * from "babylonjs/Maths/math.axis";
  54433. export * from "babylonjs/Maths/math.color";
  54434. export * from "babylonjs/Maths/math.constants";
  54435. export * from "babylonjs/Maths/math.frustum";
  54436. export * from "babylonjs/Maths/math.path";
  54437. export * from "babylonjs/Maths/math.plane";
  54438. export * from "babylonjs/Maths/math.size";
  54439. export * from "babylonjs/Maths/math.vector";
  54440. export * from "babylonjs/Maths/math.vertexFormat";
  54441. export * from "babylonjs/Maths/math.viewport";
  54442. }
  54443. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54445. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54446. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54447. import { Nullable } from "babylonjs/types";
  54448. import { Effect } from "babylonjs/Materials/effect";
  54449. import { Matrix } from "babylonjs/Maths/math.vector";
  54450. import { Scene } from "babylonjs/scene";
  54451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54453. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54454. /**
  54455. * Block used to expose an input value
  54456. */
  54457. export class InputBlock extends NodeMaterialBlock {
  54458. private _mode;
  54459. private _associatedVariableName;
  54460. private _storedValue;
  54461. private _valueCallback;
  54462. private _type;
  54463. /** @hidden */
  54464. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54465. /**
  54466. * Gets or sets the connection point type (default is float)
  54467. */
  54468. readonly type: NodeMaterialBlockConnectionPointTypes;
  54469. /**
  54470. * Creates a new InputBlock
  54471. * @param name defines the block name
  54472. * @param target defines the target of that block (Vertex by default)
  54473. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54474. */
  54475. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54476. /**
  54477. * Gets the output component
  54478. */
  54479. readonly output: NodeMaterialConnectionPoint;
  54480. /**
  54481. * Set the source of this connection point to a vertex attribute
  54482. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54483. * @returns the current connection point
  54484. */
  54485. setAsAttribute(attributeName?: string): InputBlock;
  54486. /**
  54487. * Set the source of this connection point to a well known value
  54488. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54489. * @returns the current connection point
  54490. */
  54491. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54492. /**
  54493. * Gets or sets the value of that point.
  54494. * Please note that this value will be ignored if valueCallback is defined
  54495. */
  54496. value: any;
  54497. /**
  54498. * Gets or sets a callback used to get the value of that point.
  54499. * Please note that setting this value will force the connection point to ignore the value property
  54500. */
  54501. valueCallback: () => any;
  54502. /**
  54503. * Gets or sets the associated variable name in the shader
  54504. */
  54505. associatedVariableName: string;
  54506. /**
  54507. * Gets a boolean indicating that this connection point not defined yet
  54508. */
  54509. readonly isUndefined: boolean;
  54510. /**
  54511. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54512. * In this case the connection point name must be the name of the uniform to use.
  54513. * Can only be set on inputs
  54514. */
  54515. isUniform: boolean;
  54516. /**
  54517. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54518. * In this case the connection point name must be the name of the attribute to use
  54519. * Can only be set on inputs
  54520. */
  54521. isAttribute: boolean;
  54522. /**
  54523. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54524. * Can only be set on exit points
  54525. */
  54526. isVarying: boolean;
  54527. /**
  54528. * Gets a boolean indicating that the current connection point is a well known value
  54529. */
  54530. readonly isWellKnownValue: boolean;
  54531. /**
  54532. * Gets or sets the current well known value or null if not defined as well know value
  54533. */
  54534. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54535. /**
  54536. * Gets the current class name
  54537. * @returns the class name
  54538. */
  54539. getClassName(): string;
  54540. private _emitDefine;
  54541. /**
  54542. * Set the input block to its default value (based on its type)
  54543. */
  54544. setDefaultValue(): void;
  54545. private _emit;
  54546. /** @hidden */
  54547. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54548. /** @hidden */
  54549. _transmit(effect: Effect, scene: Scene): void;
  54550. protected _buildBlock(state: NodeMaterialBuildState): void;
  54551. serialize(): any;
  54552. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54553. }
  54554. }
  54555. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54556. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54557. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54558. import { Nullable } from "babylonjs/types";
  54559. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54561. /**
  54562. * Defines a connection point for a block
  54563. */
  54564. export class NodeMaterialConnectionPoint {
  54565. /** @hidden */
  54566. _ownerBlock: NodeMaterialBlock;
  54567. /** @hidden */
  54568. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54569. private _endpoints;
  54570. private _associatedVariableName;
  54571. /** @hidden */
  54572. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54573. private _type;
  54574. /** @hidden */
  54575. _enforceAssociatedVariableName: boolean;
  54576. /**
  54577. * Gets or sets the associated variable name in the shader
  54578. */
  54579. associatedVariableName: string;
  54580. /**
  54581. * Gets or sets the connection point type (default is float)
  54582. */
  54583. type: NodeMaterialBlockConnectionPointTypes;
  54584. /**
  54585. * Gets or sets the connection point name
  54586. */
  54587. name: string;
  54588. /**
  54589. * Gets or sets the swizzle to apply to this connection point when reading or writing
  54590. */
  54591. swizzle: string;
  54592. /**
  54593. * Gets or sets a boolean indicating that this connection point can be omitted
  54594. */
  54595. isOptional: boolean;
  54596. /**
  54597. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54598. */
  54599. define: string;
  54600. /** Gets or sets the target of that connection point */
  54601. target: NodeMaterialBlockTargets;
  54602. /**
  54603. * Gets a boolean indicating that the current point is connected
  54604. */
  54605. readonly isConnected: boolean;
  54606. /**
  54607. * Gets a boolean indicating that the current point is connected to an input block
  54608. */
  54609. readonly isConnectedToInput: boolean;
  54610. /**
  54611. * Gets a the connected input block (if any)
  54612. */
  54613. readonly connectInputBlock: Nullable<InputBlock>;
  54614. /** Get the other side of the connection (if any) */
  54615. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54616. /** Get the block that owns this connection point */
  54617. readonly ownerBlock: NodeMaterialBlock;
  54618. /** Get the block connected on the other side of this connection (if any) */
  54619. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54620. /** Get the block connected on the endpoints of this connection (if any) */
  54621. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54622. /** Gets the list of connected endpoints */
  54623. readonly endpoints: NodeMaterialConnectionPoint[];
  54624. /**
  54625. * Creates a new connection point
  54626. * @param name defines the connection point name
  54627. * @param ownerBlock defines the block hosting this connection point
  54628. */
  54629. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54630. /**
  54631. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54632. * @returns the class name
  54633. */
  54634. getClassName(): string;
  54635. /**
  54636. * Gets an boolean indicating if the current point can be connected to another point
  54637. * @param connectionPoint defines the other connection point
  54638. * @returns true if the connection is possible
  54639. */
  54640. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54641. /**
  54642. * Connect this point to another connection point
  54643. * @param connectionPoint defines the other connection point
  54644. * @returns the current connection point
  54645. */
  54646. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54647. /**
  54648. * Disconnect this point from one of his endpoint
  54649. * @param endpoint defines the other connection point
  54650. * @returns the current connection point
  54651. */
  54652. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54653. /**
  54654. * Serializes this point in a JSON representation
  54655. * @returns the serialized point object
  54656. */
  54657. serialize(): any;
  54658. private static _GetTypeLength;
  54659. }
  54660. }
  54661. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  54662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54665. import { Mesh } from "babylonjs/Meshes/mesh";
  54666. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54668. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54669. /**
  54670. * Block used to add support for vertex skinning (bones)
  54671. */
  54672. export class BonesBlock extends NodeMaterialBlock {
  54673. /**
  54674. * Creates a new BonesBlock
  54675. * @param name defines the block name
  54676. */
  54677. constructor(name: string);
  54678. /**
  54679. * Initialize the block and prepare the context for build
  54680. * @param state defines the state that will be used for the build
  54681. */
  54682. initialize(state: NodeMaterialBuildState): void;
  54683. /**
  54684. * Gets the current class name
  54685. * @returns the class name
  54686. */
  54687. getClassName(): string;
  54688. /**
  54689. * Gets the matrix indices input component
  54690. */
  54691. readonly matricesIndices: NodeMaterialConnectionPoint;
  54692. /**
  54693. * Gets the matrix weights input component
  54694. */
  54695. readonly matricesWeights: NodeMaterialConnectionPoint;
  54696. /**
  54697. * Gets the extra matrix indices input component
  54698. */
  54699. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54700. /**
  54701. * Gets the extra matrix weights input component
  54702. */
  54703. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54704. /**
  54705. * Gets the world input component
  54706. */
  54707. readonly world: NodeMaterialConnectionPoint;
  54708. /**
  54709. * Gets the output component
  54710. */
  54711. readonly output: NodeMaterialConnectionPoint;
  54712. autoConfigure(): void;
  54713. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54714. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54715. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54716. protected _buildBlock(state: NodeMaterialBuildState): this;
  54717. }
  54718. }
  54719. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54721. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54724. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54725. /**
  54726. * Block used to add support for instances
  54727. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54728. */
  54729. export class InstancesBlock extends NodeMaterialBlock {
  54730. /**
  54731. * Creates a new InstancesBlock
  54732. * @param name defines the block name
  54733. */
  54734. constructor(name: string);
  54735. /**
  54736. * Gets the current class name
  54737. * @returns the class name
  54738. */
  54739. getClassName(): string;
  54740. /**
  54741. * Gets the first world row input component
  54742. */
  54743. readonly world0: NodeMaterialConnectionPoint;
  54744. /**
  54745. * Gets the second world row input component
  54746. */
  54747. readonly world1: NodeMaterialConnectionPoint;
  54748. /**
  54749. * Gets the third world row input component
  54750. */
  54751. readonly world2: NodeMaterialConnectionPoint;
  54752. /**
  54753. * Gets the forth world row input component
  54754. */
  54755. readonly world3: NodeMaterialConnectionPoint;
  54756. /**
  54757. * Gets the world input component
  54758. */
  54759. readonly world: NodeMaterialConnectionPoint;
  54760. /**
  54761. * Gets the output component
  54762. */
  54763. readonly output: NodeMaterialConnectionPoint;
  54764. autoConfigure(): void;
  54765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54766. protected _buildBlock(state: NodeMaterialBuildState): this;
  54767. }
  54768. }
  54769. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54770. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54771. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54772. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54774. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54775. import { Effect } from "babylonjs/Materials/effect";
  54776. import { Mesh } from "babylonjs/Meshes/mesh";
  54777. /**
  54778. * Block used to add morph targets support to vertex shader
  54779. */
  54780. export class MorphTargetsBlock extends NodeMaterialBlock {
  54781. private _repeatableContentAnchor;
  54782. private _repeatebleContentGenerated;
  54783. /**
  54784. * Create a new MorphTargetsBlock
  54785. * @param name defines the block name
  54786. */
  54787. constructor(name: string);
  54788. /**
  54789. * Gets the current class name
  54790. * @returns the class name
  54791. */
  54792. getClassName(): string;
  54793. /**
  54794. * Gets the position input component
  54795. */
  54796. readonly position: NodeMaterialConnectionPoint;
  54797. /**
  54798. * Gets the normal input component
  54799. */
  54800. readonly normal: NodeMaterialConnectionPoint;
  54801. /**
  54802. * Gets the tangent input component
  54803. */
  54804. readonly tangent: NodeMaterialConnectionPoint;
  54805. /**
  54806. * Gets the tangent input component
  54807. */
  54808. readonly uv: NodeMaterialConnectionPoint;
  54809. /**
  54810. * Gets the position output component
  54811. */
  54812. readonly positionOutput: NodeMaterialConnectionPoint;
  54813. /**
  54814. * Gets the normal output component
  54815. */
  54816. readonly normalOutput: NodeMaterialConnectionPoint;
  54817. /**
  54818. * Gets the tangent output component
  54819. */
  54820. readonly tangentOutput: NodeMaterialConnectionPoint;
  54821. /**
  54822. * Gets the tangent output component
  54823. */
  54824. readonly uvOutput: NodeMaterialConnectionPoint;
  54825. initialize(state: NodeMaterialBuildState): void;
  54826. autoConfigure(): void;
  54827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54829. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54830. protected _buildBlock(state: NodeMaterialBuildState): this;
  54831. }
  54832. }
  54833. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54834. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54835. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54836. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54837. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54838. }
  54839. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54840. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54843. /**
  54844. * Block used to add an alpha test in the fragment shader
  54845. */
  54846. export class AlphaTestBlock extends NodeMaterialBlock {
  54847. /**
  54848. * Gets or sets the alpha value where alpha testing happens
  54849. */
  54850. alphaCutOff: number;
  54851. /**
  54852. * Create a new AlphaTestBlock
  54853. * @param name defines the block name
  54854. */
  54855. constructor(name: string);
  54856. /**
  54857. * Gets the current class name
  54858. * @returns the class name
  54859. */
  54860. getClassName(): string;
  54861. /**
  54862. * Gets the color input component
  54863. */
  54864. readonly color: NodeMaterialConnectionPoint;
  54865. protected _buildBlock(state: NodeMaterialBuildState): this;
  54866. }
  54867. }
  54868. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54872. /**
  54873. * Block used to create a Color4 out of 4 inputs (one for each component)
  54874. */
  54875. export class RGBAMergerBlock extends NodeMaterialBlock {
  54876. /**
  54877. * Create a new RGBAMergerBlock
  54878. * @param name defines the block name
  54879. */
  54880. constructor(name: string);
  54881. /**
  54882. * Gets the current class name
  54883. * @returns the class name
  54884. */
  54885. getClassName(): string;
  54886. /**
  54887. * Gets the R input component
  54888. */
  54889. readonly r: NodeMaterialConnectionPoint;
  54890. /**
  54891. * Gets the G input component
  54892. */
  54893. readonly g: NodeMaterialConnectionPoint;
  54894. /**
  54895. * Gets the B input component
  54896. */
  54897. readonly b: NodeMaterialConnectionPoint;
  54898. /**
  54899. * Gets the RGB input component
  54900. */
  54901. readonly rgb: NodeMaterialConnectionPoint;
  54902. /**
  54903. * Gets the R input component
  54904. */
  54905. readonly a: NodeMaterialConnectionPoint;
  54906. /**
  54907. * Gets the output component
  54908. */
  54909. readonly output: NodeMaterialConnectionPoint;
  54910. protected _buildBlock(state: NodeMaterialBuildState): this;
  54911. }
  54912. }
  54913. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54917. /**
  54918. * Block used to create a Color3 out of 3 inputs (one for each component)
  54919. */
  54920. export class RGBMergerBlock extends NodeMaterialBlock {
  54921. /**
  54922. * Create a new RGBMergerBlock
  54923. * @param name defines the block name
  54924. */
  54925. constructor(name: string);
  54926. /**
  54927. * Gets the current class name
  54928. * @returns the class name
  54929. */
  54930. getClassName(): string;
  54931. /**
  54932. * Gets the R component input
  54933. */
  54934. readonly r: NodeMaterialConnectionPoint;
  54935. /**
  54936. * Gets the G component input
  54937. */
  54938. readonly g: NodeMaterialConnectionPoint;
  54939. /**
  54940. * Gets the B component input
  54941. */
  54942. readonly b: NodeMaterialConnectionPoint;
  54943. /**
  54944. * Gets the output component
  54945. */
  54946. readonly output: NodeMaterialConnectionPoint;
  54947. protected _buildBlock(state: NodeMaterialBuildState): this;
  54948. }
  54949. }
  54950. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54954. /**
  54955. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54956. */
  54957. export class RGBASplitterBlock extends NodeMaterialBlock {
  54958. /**
  54959. * Create a new RGBASplitterBlock
  54960. * @param name defines the block name
  54961. */
  54962. constructor(name: string);
  54963. /**
  54964. * Gets the current class name
  54965. * @returns the class name
  54966. */
  54967. getClassName(): string;
  54968. /**
  54969. * Gets the input component
  54970. */
  54971. readonly input: NodeMaterialConnectionPoint;
  54972. protected _buildBlock(state: NodeMaterialBuildState): this;
  54973. }
  54974. }
  54975. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54979. /**
  54980. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54981. */
  54982. export class RGBSplitterBlock extends NodeMaterialBlock {
  54983. /**
  54984. * Create a new RGBSplitterBlock
  54985. * @param name defines the block name
  54986. */
  54987. constructor(name: string);
  54988. /**
  54989. * Gets the current class name
  54990. * @returns the class name
  54991. */
  54992. getClassName(): string;
  54993. /**
  54994. * Gets the input component
  54995. */
  54996. readonly input: NodeMaterialConnectionPoint;
  54997. protected _buildBlock(state: NodeMaterialBuildState): this;
  54998. }
  54999. }
  55000. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55005. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55006. import { Effect } from "babylonjs/Materials/effect";
  55007. import { Mesh } from "babylonjs/Meshes/mesh";
  55008. /**
  55009. * Block used to add image processing support to fragment shader
  55010. */
  55011. export class ImageProcessingBlock extends NodeMaterialBlock {
  55012. /**
  55013. * Create a new ImageProcessingBlock
  55014. * @param name defines the block name
  55015. */
  55016. constructor(name: string);
  55017. /**
  55018. * Gets the current class name
  55019. * @returns the class name
  55020. */
  55021. getClassName(): string;
  55022. /**
  55023. * Gets the color input component
  55024. */
  55025. readonly color: NodeMaterialConnectionPoint;
  55026. /**
  55027. * Gets the output component
  55028. */
  55029. readonly output: NodeMaterialConnectionPoint;
  55030. /**
  55031. * Initialize the block and prepare the context for build
  55032. * @param state defines the state that will be used for the build
  55033. */
  55034. initialize(state: NodeMaterialBuildState): void;
  55035. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55036. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55037. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55038. protected _buildBlock(state: NodeMaterialBuildState): this;
  55039. }
  55040. }
  55041. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55042. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55043. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55044. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  55045. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  55046. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  55047. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  55048. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55049. }
  55050. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55052. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55053. import { Mesh } from "babylonjs/Meshes/mesh";
  55054. import { Effect } from "babylonjs/Materials/effect";
  55055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55057. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55058. /**
  55059. * Block used to add support for scene fog
  55060. */
  55061. export class FogBlock extends NodeMaterialBlock {
  55062. private _fogDistanceName;
  55063. private _fogParameters;
  55064. /**
  55065. * Create a new FogBlock
  55066. * @param name defines the block name
  55067. */
  55068. constructor(name: string);
  55069. /**
  55070. * Gets the current class name
  55071. * @returns the class name
  55072. */
  55073. getClassName(): string;
  55074. /**
  55075. * Gets the world position input component
  55076. */
  55077. readonly worldPosition: NodeMaterialConnectionPoint;
  55078. /**
  55079. * Gets the view input component
  55080. */
  55081. readonly view: NodeMaterialConnectionPoint;
  55082. /**
  55083. * Gets the color input component
  55084. */
  55085. readonly color: NodeMaterialConnectionPoint;
  55086. /**
  55087. * Gets the fog color input component
  55088. */
  55089. readonly fogColor: NodeMaterialConnectionPoint;
  55090. /**
  55091. * Gets the output component
  55092. */
  55093. readonly output: NodeMaterialConnectionPoint;
  55094. autoConfigure(): void;
  55095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55096. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55097. protected _buildBlock(state: NodeMaterialBuildState): this;
  55098. }
  55099. }
  55100. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55105. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55106. import { Effect } from "babylonjs/Materials/effect";
  55107. import { Mesh } from "babylonjs/Meshes/mesh";
  55108. import { Light } from "babylonjs/Lights/light";
  55109. import { Nullable } from "babylonjs/types";
  55110. import { Scene } from "babylonjs/scene";
  55111. /**
  55112. * Block used to add light in the fragment shader
  55113. */
  55114. export class LightBlock extends NodeMaterialBlock {
  55115. private _lightId;
  55116. /**
  55117. * Gets or sets the light associated with this block
  55118. */
  55119. light: Nullable<Light>;
  55120. /**
  55121. * Create a new LightBlock
  55122. * @param name defines the block name
  55123. */
  55124. constructor(name: string);
  55125. /**
  55126. * Gets the current class name
  55127. * @returns the class name
  55128. */
  55129. getClassName(): string;
  55130. /**
  55131. * Gets the world position input component
  55132. */
  55133. readonly worldPosition: NodeMaterialConnectionPoint;
  55134. /**
  55135. * Gets the world normal input component
  55136. */
  55137. readonly worldNormal: NodeMaterialConnectionPoint;
  55138. /**
  55139. * Gets the camera (or eye) position component
  55140. */
  55141. readonly cameraPosition: NodeMaterialConnectionPoint;
  55142. /**
  55143. * Gets the diffuse output component
  55144. */
  55145. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55146. /**
  55147. * Gets the specular output component
  55148. */
  55149. readonly specularOutput: NodeMaterialConnectionPoint;
  55150. autoConfigure(): void;
  55151. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55152. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55153. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55154. private _injectVertexCode;
  55155. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55156. serialize(): any;
  55157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55158. }
  55159. }
  55160. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55161. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55162. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55163. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55164. }
  55165. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55166. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55167. }
  55168. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55172. /**
  55173. * Block used to multiply 2 values
  55174. */
  55175. export class MultiplyBlock extends NodeMaterialBlock {
  55176. /**
  55177. * Creates a new MultiplyBlock
  55178. * @param name defines the block name
  55179. */
  55180. constructor(name: string);
  55181. /**
  55182. * Gets the current class name
  55183. * @returns the class name
  55184. */
  55185. getClassName(): string;
  55186. /**
  55187. * Gets the left operand input component
  55188. */
  55189. readonly left: NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the right operand input component
  55192. */
  55193. readonly right: NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the output component
  55196. */
  55197. readonly output: NodeMaterialConnectionPoint;
  55198. protected _buildBlock(state: NodeMaterialBuildState): this;
  55199. }
  55200. }
  55201. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55205. /**
  55206. * Block used to add 2 vectors
  55207. */
  55208. export class AddBlock extends NodeMaterialBlock {
  55209. /**
  55210. * Creates a new AddBlock
  55211. * @param name defines the block name
  55212. */
  55213. constructor(name: string);
  55214. /**
  55215. * Gets the current class name
  55216. * @returns the class name
  55217. */
  55218. getClassName(): string;
  55219. /**
  55220. * Gets the left operand input component
  55221. */
  55222. readonly left: NodeMaterialConnectionPoint;
  55223. /**
  55224. * Gets the right operand input component
  55225. */
  55226. readonly right: NodeMaterialConnectionPoint;
  55227. /**
  55228. * Gets the output component
  55229. */
  55230. readonly output: NodeMaterialConnectionPoint;
  55231. protected _buildBlock(state: NodeMaterialBuildState): this;
  55232. }
  55233. }
  55234. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55238. /**
  55239. * Block used to clamp a float
  55240. */
  55241. export class ClampBlock extends NodeMaterialBlock {
  55242. /** Gets or sets the minimum range */
  55243. minimum: number;
  55244. /** Gets or sets the maximum range */
  55245. maximum: number;
  55246. /**
  55247. * Creates a new ClampBlock
  55248. * @param name defines the block name
  55249. */
  55250. constructor(name: string);
  55251. /**
  55252. * Gets the current class name
  55253. * @returns the class name
  55254. */
  55255. getClassName(): string;
  55256. /**
  55257. * Gets the value input component
  55258. */
  55259. readonly value: NodeMaterialConnectionPoint;
  55260. /**
  55261. * Gets the output component
  55262. */
  55263. readonly output: NodeMaterialConnectionPoint;
  55264. protected _buildBlock(state: NodeMaterialBuildState): this;
  55265. }
  55266. }
  55267. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55271. /**
  55272. * Block used to apply a cross product between 2 vectors
  55273. */
  55274. export class CrossBlock extends NodeMaterialBlock {
  55275. /**
  55276. * Creates a new CrossBlock
  55277. * @param name defines the block name
  55278. */
  55279. constructor(name: string);
  55280. /**
  55281. * Gets the current class name
  55282. * @returns the class name
  55283. */
  55284. getClassName(): string;
  55285. /**
  55286. * Gets the left operand input component
  55287. */
  55288. readonly left: NodeMaterialConnectionPoint;
  55289. /**
  55290. * Gets the right operand input component
  55291. */
  55292. readonly right: NodeMaterialConnectionPoint;
  55293. /**
  55294. * Gets the output component
  55295. */
  55296. readonly output: NodeMaterialConnectionPoint;
  55297. protected _buildBlock(state: NodeMaterialBuildState): this;
  55298. }
  55299. }
  55300. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55304. /**
  55305. * Block used to apply a dot product between 2 vectors
  55306. */
  55307. export class DotBlock extends NodeMaterialBlock {
  55308. /**
  55309. * Creates a new DotBlock
  55310. * @param name defines the block name
  55311. */
  55312. constructor(name: string);
  55313. /**
  55314. * Gets the current class name
  55315. * @returns the class name
  55316. */
  55317. getClassName(): string;
  55318. /**
  55319. * Gets the left operand input component
  55320. */
  55321. readonly left: NodeMaterialConnectionPoint;
  55322. /**
  55323. * Gets the right operand input component
  55324. */
  55325. readonly right: NodeMaterialConnectionPoint;
  55326. /**
  55327. * Gets the output component
  55328. */
  55329. readonly output: NodeMaterialConnectionPoint;
  55330. protected _buildBlock(state: NodeMaterialBuildState): this;
  55331. }
  55332. }
  55333. declare module "babylonjs/Materials/Node/Blocks/index" {
  55334. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55335. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  55336. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  55337. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  55338. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  55339. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  55340. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  55341. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  55342. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  55343. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  55344. }
  55345. declare module "babylonjs/Materials/Node/Optimizers/index" {
  55346. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55347. }
  55348. declare module "babylonjs/Materials/Node/index" {
  55349. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55350. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55351. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55352. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  55353. export * from "babylonjs/Materials/Node/nodeMaterial";
  55354. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55355. export * from "babylonjs/Materials/Node/Blocks/index";
  55356. export * from "babylonjs/Materials/Node/Optimizers/index";
  55357. }
  55358. declare module "babylonjs/Materials/effectRenderer" {
  55359. import { Nullable } from "babylonjs/types";
  55360. import { Texture } from "babylonjs/Materials/Textures/texture";
  55361. import { Engine } from "babylonjs/Engines/engine";
  55362. import { Viewport } from "babylonjs/Maths/math.viewport";
  55363. import { Observable } from "babylonjs/Misc/observable";
  55364. import { Effect } from "babylonjs/Materials/effect";
  55365. import "babylonjs/Shaders/postprocess.vertex";
  55366. /**
  55367. * Effect Render Options
  55368. */
  55369. export interface IEffectRendererOptions {
  55370. /**
  55371. * Defines the vertices positions.
  55372. */
  55373. positions?: number[];
  55374. /**
  55375. * Defines the indices.
  55376. */
  55377. indices?: number[];
  55378. }
  55379. /**
  55380. * Helper class to render one or more effects
  55381. */
  55382. export class EffectRenderer {
  55383. private engine;
  55384. private static _DefaultOptions;
  55385. private _vertexBuffers;
  55386. private _indexBuffer;
  55387. private _ringBufferIndex;
  55388. private _ringScreenBuffer;
  55389. private _fullscreenViewport;
  55390. private _getNextFrameBuffer;
  55391. /**
  55392. * Creates an effect renderer
  55393. * @param engine the engine to use for rendering
  55394. * @param options defines the options of the effect renderer
  55395. */
  55396. constructor(engine: Engine, options?: IEffectRendererOptions);
  55397. /**
  55398. * Sets the current viewport in normalized coordinates 0-1
  55399. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55400. */
  55401. setViewport(viewport?: Viewport): void;
  55402. /**
  55403. * Sets the current effect wrapper to use during draw.
  55404. * The effect needs to be ready before calling this api.
  55405. * This also sets the default full screen position attribute.
  55406. * @param effectWrapper Defines the effect to draw with
  55407. */
  55408. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55409. /**
  55410. * Draws a full screen quad.
  55411. */
  55412. draw(): void;
  55413. /**
  55414. * renders one or more effects to a specified texture
  55415. * @param effectWrappers list of effects to renderer
  55416. * @param outputTexture texture to draw to, if null it will render to the screen
  55417. */
  55418. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55419. /**
  55420. * Disposes of the effect renderer
  55421. */
  55422. dispose(): void;
  55423. }
  55424. /**
  55425. * Options to create an EffectWrapper
  55426. */
  55427. interface EffectWrapperCreationOptions {
  55428. /**
  55429. * Engine to use to create the effect
  55430. */
  55431. engine: Engine;
  55432. /**
  55433. * Fragment shader for the effect
  55434. */
  55435. fragmentShader: string;
  55436. /**
  55437. * Vertex shader for the effect
  55438. */
  55439. vertexShader: string;
  55440. /**
  55441. * Attributes to use in the shader
  55442. */
  55443. attributeNames?: Array<string>;
  55444. /**
  55445. * Uniforms to use in the shader
  55446. */
  55447. uniformNames?: Array<string>;
  55448. /**
  55449. * Texture sampler names to use in the shader
  55450. */
  55451. samplerNames?: Array<string>;
  55452. /**
  55453. * The friendly name of the effect displayed in Spector.
  55454. */
  55455. name?: string;
  55456. }
  55457. /**
  55458. * Wraps an effect to be used for rendering
  55459. */
  55460. export class EffectWrapper {
  55461. /**
  55462. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55463. */
  55464. onApplyObservable: Observable<{}>;
  55465. /**
  55466. * The underlying effect
  55467. */
  55468. effect: Effect;
  55469. /**
  55470. * Creates an effect to be renderer
  55471. * @param creationOptions options to create the effect
  55472. */
  55473. constructor(creationOptions: EffectWrapperCreationOptions);
  55474. /**
  55475. * Disposes of the effect wrapper
  55476. */
  55477. dispose(): void;
  55478. }
  55479. }
  55480. declare module "babylonjs/Materials/index" {
  55481. export * from "babylonjs/Materials/Background/index";
  55482. export * from "babylonjs/Materials/colorCurves";
  55483. export * from "babylonjs/Materials/effect";
  55484. export * from "babylonjs/Materials/fresnelParameters";
  55485. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55486. export * from "babylonjs/Materials/material";
  55487. export * from "babylonjs/Materials/materialDefines";
  55488. export * from "babylonjs/Materials/materialHelper";
  55489. export * from "babylonjs/Materials/multiMaterial";
  55490. export * from "babylonjs/Materials/PBR/index";
  55491. export * from "babylonjs/Materials/pushMaterial";
  55492. export * from "babylonjs/Materials/shaderMaterial";
  55493. export * from "babylonjs/Materials/standardMaterial";
  55494. export * from "babylonjs/Materials/Textures/index";
  55495. export * from "babylonjs/Materials/uniformBuffer";
  55496. export * from "babylonjs/Materials/materialFlags";
  55497. export * from "babylonjs/Materials/Node/index";
  55498. export * from "babylonjs/Materials/effectRenderer";
  55499. }
  55500. declare module "babylonjs/Maths/index" {
  55501. export * from "babylonjs/Maths/math.scalar";
  55502. export * from "babylonjs/Maths/math";
  55503. export * from "babylonjs/Maths/sphericalPolynomial";
  55504. }
  55505. declare module "babylonjs/Misc/workerPool" {
  55506. import { IDisposable } from "babylonjs/scene";
  55507. /**
  55508. * Helper class to push actions to a pool of workers.
  55509. */
  55510. export class WorkerPool implements IDisposable {
  55511. private _workerInfos;
  55512. private _pendingActions;
  55513. /**
  55514. * Constructor
  55515. * @param workers Array of workers to use for actions
  55516. */
  55517. constructor(workers: Array<Worker>);
  55518. /**
  55519. * Terminates all workers and clears any pending actions.
  55520. */
  55521. dispose(): void;
  55522. /**
  55523. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55524. * pended until a worker has completed its action.
  55525. * @param action The action to perform. Call onComplete when the action is complete.
  55526. */
  55527. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55528. private _execute;
  55529. }
  55530. }
  55531. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  55532. import { IDisposable } from "babylonjs/scene";
  55533. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55534. /**
  55535. * Configuration for Draco compression
  55536. */
  55537. export interface IDracoCompressionConfiguration {
  55538. /**
  55539. * Configuration for the decoder.
  55540. */
  55541. decoder: {
  55542. /**
  55543. * The url to the WebAssembly module.
  55544. */
  55545. wasmUrl?: string;
  55546. /**
  55547. * The url to the WebAssembly binary.
  55548. */
  55549. wasmBinaryUrl?: string;
  55550. /**
  55551. * The url to the fallback JavaScript module.
  55552. */
  55553. fallbackUrl?: string;
  55554. };
  55555. }
  55556. /**
  55557. * Draco compression (https://google.github.io/draco/)
  55558. *
  55559. * This class wraps the Draco module.
  55560. *
  55561. * **Encoder**
  55562. *
  55563. * The encoder is not currently implemented.
  55564. *
  55565. * **Decoder**
  55566. *
  55567. * 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.
  55568. *
  55569. * To update the configuration, use the following code:
  55570. * ```javascript
  55571. * DracoCompression.Configuration = {
  55572. * decoder: {
  55573. * wasmUrl: "<url to the WebAssembly library>",
  55574. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55575. * fallbackUrl: "<url to the fallback JavaScript library>",
  55576. * }
  55577. * };
  55578. * ```
  55579. *
  55580. * 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.
  55581. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55582. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55583. *
  55584. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55585. * ```javascript
  55586. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55587. * ```
  55588. *
  55589. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55590. */
  55591. export class DracoCompression implements IDisposable {
  55592. private _workerPoolPromise?;
  55593. private _decoderModulePromise?;
  55594. /**
  55595. * The configuration. Defaults to the following urls:
  55596. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55597. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55598. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55599. */
  55600. static Configuration: IDracoCompressionConfiguration;
  55601. /**
  55602. * Returns true if the decoder configuration is available.
  55603. */
  55604. static readonly DecoderAvailable: boolean;
  55605. /**
  55606. * Default number of workers to create when creating the draco compression object.
  55607. */
  55608. static DefaultNumWorkers: number;
  55609. private static GetDefaultNumWorkers;
  55610. private static _Default;
  55611. /**
  55612. * Default instance for the draco compression object.
  55613. */
  55614. static readonly Default: DracoCompression;
  55615. /**
  55616. * Constructor
  55617. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55618. */
  55619. constructor(numWorkers?: number);
  55620. /**
  55621. * Stop all async operations and release resources.
  55622. */
  55623. dispose(): void;
  55624. /**
  55625. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55626. * @returns a promise that resolves when ready
  55627. */
  55628. whenReadyAsync(): Promise<void>;
  55629. /**
  55630. * Decode Draco compressed mesh data to vertex data.
  55631. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55632. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55633. * @returns A promise that resolves with the decoded vertex data
  55634. */
  55635. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55636. [kind: string]: number;
  55637. }): Promise<VertexData>;
  55638. }
  55639. }
  55640. declare module "babylonjs/Meshes/Compression/index" {
  55641. export * from "babylonjs/Meshes/Compression/dracoCompression";
  55642. }
  55643. declare module "babylonjs/Meshes/csg" {
  55644. import { Nullable } from "babylonjs/types";
  55645. import { Scene } from "babylonjs/scene";
  55646. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55647. import { Mesh } from "babylonjs/Meshes/mesh";
  55648. import { Material } from "babylonjs/Materials/material";
  55649. /**
  55650. * Class for building Constructive Solid Geometry
  55651. */
  55652. export class CSG {
  55653. private polygons;
  55654. /**
  55655. * The world matrix
  55656. */
  55657. matrix: Matrix;
  55658. /**
  55659. * Stores the position
  55660. */
  55661. position: Vector3;
  55662. /**
  55663. * Stores the rotation
  55664. */
  55665. rotation: Vector3;
  55666. /**
  55667. * Stores the rotation quaternion
  55668. */
  55669. rotationQuaternion: Nullable<Quaternion>;
  55670. /**
  55671. * Stores the scaling vector
  55672. */
  55673. scaling: Vector3;
  55674. /**
  55675. * Convert the Mesh to CSG
  55676. * @param mesh The Mesh to convert to CSG
  55677. * @returns A new CSG from the Mesh
  55678. */
  55679. static FromMesh(mesh: Mesh): CSG;
  55680. /**
  55681. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55682. * @param polygons Polygons used to construct a CSG solid
  55683. */
  55684. private static FromPolygons;
  55685. /**
  55686. * Clones, or makes a deep copy, of the CSG
  55687. * @returns A new CSG
  55688. */
  55689. clone(): CSG;
  55690. /**
  55691. * Unions this CSG with another CSG
  55692. * @param csg The CSG to union against this CSG
  55693. * @returns The unioned CSG
  55694. */
  55695. union(csg: CSG): CSG;
  55696. /**
  55697. * Unions this CSG with another CSG in place
  55698. * @param csg The CSG to union against this CSG
  55699. */
  55700. unionInPlace(csg: CSG): void;
  55701. /**
  55702. * Subtracts this CSG with another CSG
  55703. * @param csg The CSG to subtract against this CSG
  55704. * @returns A new CSG
  55705. */
  55706. subtract(csg: CSG): CSG;
  55707. /**
  55708. * Subtracts this CSG with another CSG in place
  55709. * @param csg The CSG to subtact against this CSG
  55710. */
  55711. subtractInPlace(csg: CSG): void;
  55712. /**
  55713. * Intersect this CSG with another CSG
  55714. * @param csg The CSG to intersect against this CSG
  55715. * @returns A new CSG
  55716. */
  55717. intersect(csg: CSG): CSG;
  55718. /**
  55719. * Intersects this CSG with another CSG in place
  55720. * @param csg The CSG to intersect against this CSG
  55721. */
  55722. intersectInPlace(csg: CSG): void;
  55723. /**
  55724. * Return a new CSG solid with solid and empty space switched. This solid is
  55725. * not modified.
  55726. * @returns A new CSG solid with solid and empty space switched
  55727. */
  55728. inverse(): CSG;
  55729. /**
  55730. * Inverses the CSG in place
  55731. */
  55732. inverseInPlace(): void;
  55733. /**
  55734. * This is used to keep meshes transformations so they can be restored
  55735. * when we build back a Babylon Mesh
  55736. * NB : All CSG operations are performed in world coordinates
  55737. * @param csg The CSG to copy the transform attributes from
  55738. * @returns This CSG
  55739. */
  55740. copyTransformAttributes(csg: CSG): CSG;
  55741. /**
  55742. * Build Raw mesh from CSG
  55743. * Coordinates here are in world space
  55744. * @param name The name of the mesh geometry
  55745. * @param scene The Scene
  55746. * @param keepSubMeshes Specifies if the submeshes should be kept
  55747. * @returns A new Mesh
  55748. */
  55749. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55750. /**
  55751. * Build Mesh from CSG taking material and transforms into account
  55752. * @param name The name of the Mesh
  55753. * @param material The material of the Mesh
  55754. * @param scene The Scene
  55755. * @param keepSubMeshes Specifies if submeshes should be kept
  55756. * @returns The new Mesh
  55757. */
  55758. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55759. }
  55760. }
  55761. declare module "babylonjs/Meshes/trailMesh" {
  55762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55763. import { Mesh } from "babylonjs/Meshes/mesh";
  55764. import { Scene } from "babylonjs/scene";
  55765. /**
  55766. * Class used to create a trail following a mesh
  55767. */
  55768. export class TrailMesh extends Mesh {
  55769. private _generator;
  55770. private _autoStart;
  55771. private _running;
  55772. private _diameter;
  55773. private _length;
  55774. private _sectionPolygonPointsCount;
  55775. private _sectionVectors;
  55776. private _sectionNormalVectors;
  55777. private _beforeRenderObserver;
  55778. /**
  55779. * @constructor
  55780. * @param name The value used by scene.getMeshByName() to do a lookup.
  55781. * @param generator The mesh to generate a trail.
  55782. * @param scene The scene to add this mesh to.
  55783. * @param diameter Diameter of trailing mesh. Default is 1.
  55784. * @param length Length of trailing mesh. Default is 60.
  55785. * @param autoStart Automatically start trailing mesh. Default true.
  55786. */
  55787. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55788. /**
  55789. * "TrailMesh"
  55790. * @returns "TrailMesh"
  55791. */
  55792. getClassName(): string;
  55793. private _createMesh;
  55794. /**
  55795. * Start trailing mesh.
  55796. */
  55797. start(): void;
  55798. /**
  55799. * Stop trailing mesh.
  55800. */
  55801. stop(): void;
  55802. /**
  55803. * Update trailing mesh geometry.
  55804. */
  55805. update(): void;
  55806. /**
  55807. * Returns a new TrailMesh object.
  55808. * @param name is a string, the name given to the new mesh
  55809. * @param newGenerator use new generator object for cloned trail mesh
  55810. * @returns a new mesh
  55811. */
  55812. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55813. /**
  55814. * Serializes this trail mesh
  55815. * @param serializationObject object to write serialization to
  55816. */
  55817. serialize(serializationObject: any): void;
  55818. /**
  55819. * Parses a serialized trail mesh
  55820. * @param parsedMesh the serialized mesh
  55821. * @param scene the scene to create the trail mesh in
  55822. * @returns the created trail mesh
  55823. */
  55824. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55825. }
  55826. }
  55827. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55828. import { Nullable } from "babylonjs/types";
  55829. import { Scene } from "babylonjs/scene";
  55830. import { Vector4 } from "babylonjs/Maths/math.vector";
  55831. import { Color4 } from "babylonjs/Maths/math.color";
  55832. import { Mesh } from "babylonjs/Meshes/mesh";
  55833. /**
  55834. * Class containing static functions to help procedurally build meshes
  55835. */
  55836. export class TiledBoxBuilder {
  55837. /**
  55838. * Creates a box mesh
  55839. * 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)
  55840. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55844. * @param name defines the name of the mesh
  55845. * @param options defines the options used to create the mesh
  55846. * @param scene defines the hosting scene
  55847. * @returns the box mesh
  55848. */
  55849. static CreateTiledBox(name: string, options: {
  55850. pattern?: number;
  55851. width?: number;
  55852. height?: number;
  55853. depth?: number;
  55854. tileSize?: number;
  55855. tileWidth?: number;
  55856. tileHeight?: number;
  55857. alignHorizontal?: number;
  55858. alignVertical?: number;
  55859. faceUV?: Vector4[];
  55860. faceColors?: Color4[];
  55861. sideOrientation?: number;
  55862. updatable?: boolean;
  55863. }, scene?: Nullable<Scene>): Mesh;
  55864. }
  55865. }
  55866. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55867. import { Vector4 } from "babylonjs/Maths/math.vector";
  55868. import { Mesh } from "babylonjs/Meshes/mesh";
  55869. /**
  55870. * Class containing static functions to help procedurally build meshes
  55871. */
  55872. export class TorusKnotBuilder {
  55873. /**
  55874. * Creates a torus knot mesh
  55875. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55876. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55877. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55878. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55882. * @param name defines the name of the mesh
  55883. * @param options defines the options used to create the mesh
  55884. * @param scene defines the hosting scene
  55885. * @returns the torus knot mesh
  55886. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55887. */
  55888. static CreateTorusKnot(name: string, options: {
  55889. radius?: number;
  55890. tube?: number;
  55891. radialSegments?: number;
  55892. tubularSegments?: number;
  55893. p?: number;
  55894. q?: number;
  55895. updatable?: boolean;
  55896. sideOrientation?: number;
  55897. frontUVs?: Vector4;
  55898. backUVs?: Vector4;
  55899. }, scene: any): Mesh;
  55900. }
  55901. }
  55902. declare module "babylonjs/Meshes/polygonMesh" {
  55903. import { Scene } from "babylonjs/scene";
  55904. import { Vector2 } from "babylonjs/Maths/math.vector";
  55905. import { Mesh } from "babylonjs/Meshes/mesh";
  55906. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55907. import { Path2 } from "babylonjs/Maths/math.path";
  55908. /**
  55909. * Polygon
  55910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55911. */
  55912. export class Polygon {
  55913. /**
  55914. * Creates a rectangle
  55915. * @param xmin bottom X coord
  55916. * @param ymin bottom Y coord
  55917. * @param xmax top X coord
  55918. * @param ymax top Y coord
  55919. * @returns points that make the resulting rectation
  55920. */
  55921. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55922. /**
  55923. * Creates a circle
  55924. * @param radius radius of circle
  55925. * @param cx scale in x
  55926. * @param cy scale in y
  55927. * @param numberOfSides number of sides that make up the circle
  55928. * @returns points that make the resulting circle
  55929. */
  55930. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55931. /**
  55932. * Creates a polygon from input string
  55933. * @param input Input polygon data
  55934. * @returns the parsed points
  55935. */
  55936. static Parse(input: string): Vector2[];
  55937. /**
  55938. * Starts building a polygon from x and y coordinates
  55939. * @param x x coordinate
  55940. * @param y y coordinate
  55941. * @returns the started path2
  55942. */
  55943. static StartingAt(x: number, y: number): Path2;
  55944. }
  55945. /**
  55946. * Builds a polygon
  55947. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55948. */
  55949. export class PolygonMeshBuilder {
  55950. private _points;
  55951. private _outlinepoints;
  55952. private _holes;
  55953. private _name;
  55954. private _scene;
  55955. private _epoints;
  55956. private _eholes;
  55957. private _addToepoint;
  55958. /**
  55959. * Babylon reference to the earcut plugin.
  55960. */
  55961. bjsEarcut: any;
  55962. /**
  55963. * Creates a PolygonMeshBuilder
  55964. * @param name name of the builder
  55965. * @param contours Path of the polygon
  55966. * @param scene scene to add to when creating the mesh
  55967. * @param earcutInjection can be used to inject your own earcut reference
  55968. */
  55969. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55970. /**
  55971. * Adds a whole within the polygon
  55972. * @param hole Array of points defining the hole
  55973. * @returns this
  55974. */
  55975. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55976. /**
  55977. * Creates the polygon
  55978. * @param updatable If the mesh should be updatable
  55979. * @param depth The depth of the mesh created
  55980. * @returns the created mesh
  55981. */
  55982. build(updatable?: boolean, depth?: number): Mesh;
  55983. /**
  55984. * Creates the polygon
  55985. * @param depth The depth of the mesh created
  55986. * @returns the created VertexData
  55987. */
  55988. buildVertexData(depth?: number): VertexData;
  55989. /**
  55990. * Adds a side to the polygon
  55991. * @param positions points that make the polygon
  55992. * @param normals normals of the polygon
  55993. * @param uvs uvs of the polygon
  55994. * @param indices indices of the polygon
  55995. * @param bounds bounds of the polygon
  55996. * @param points points of the polygon
  55997. * @param depth depth of the polygon
  55998. * @param flip flip of the polygon
  55999. */
  56000. private addSide;
  56001. }
  56002. }
  56003. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56004. import { Scene } from "babylonjs/scene";
  56005. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56006. import { Color4 } from "babylonjs/Maths/math.color";
  56007. import { Mesh } from "babylonjs/Meshes/mesh";
  56008. import { Nullable } from "babylonjs/types";
  56009. /**
  56010. * Class containing static functions to help procedurally build meshes
  56011. */
  56012. export class PolygonBuilder {
  56013. /**
  56014. * Creates a polygon mesh
  56015. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56016. * * 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
  56017. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56020. * * Remember you can only change the shape positions, not their number when updating a polygon
  56021. * @param name defines the name of the mesh
  56022. * @param options defines the options used to create the mesh
  56023. * @param scene defines the hosting scene
  56024. * @param earcutInjection can be used to inject your own earcut reference
  56025. * @returns the polygon mesh
  56026. */
  56027. static CreatePolygon(name: string, options: {
  56028. shape: Vector3[];
  56029. holes?: Vector3[][];
  56030. depth?: number;
  56031. faceUV?: Vector4[];
  56032. faceColors?: Color4[];
  56033. updatable?: boolean;
  56034. sideOrientation?: number;
  56035. frontUVs?: Vector4;
  56036. backUVs?: Vector4;
  56037. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56038. /**
  56039. * Creates an extruded polygon mesh, with depth in the Y direction.
  56040. * * 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)
  56041. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56042. * @param name defines the name of the mesh
  56043. * @param options defines the options used to create the mesh
  56044. * @param scene defines the hosting scene
  56045. * @param earcutInjection can be used to inject your own earcut reference
  56046. * @returns the polygon mesh
  56047. */
  56048. static ExtrudePolygon(name: string, options: {
  56049. shape: Vector3[];
  56050. holes?: Vector3[][];
  56051. depth?: number;
  56052. faceUV?: Vector4[];
  56053. faceColors?: Color4[];
  56054. updatable?: boolean;
  56055. sideOrientation?: number;
  56056. frontUVs?: Vector4;
  56057. backUVs?: Vector4;
  56058. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56059. }
  56060. }
  56061. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56062. import { Scene } from "babylonjs/scene";
  56063. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56064. import { Mesh } from "babylonjs/Meshes/mesh";
  56065. import { Nullable } from "babylonjs/types";
  56066. /**
  56067. * Class containing static functions to help procedurally build meshes
  56068. */
  56069. export class LatheBuilder {
  56070. /**
  56071. * Creates lathe mesh.
  56072. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56073. * * 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
  56074. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56075. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56076. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56077. * * 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
  56078. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56079. * * 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
  56080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56082. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56084. * @param name defines the name of the mesh
  56085. * @param options defines the options used to create the mesh
  56086. * @param scene defines the hosting scene
  56087. * @returns the lathe mesh
  56088. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56089. */
  56090. static CreateLathe(name: string, options: {
  56091. shape: Vector3[];
  56092. radius?: number;
  56093. tessellation?: number;
  56094. clip?: number;
  56095. arc?: number;
  56096. closed?: boolean;
  56097. updatable?: boolean;
  56098. sideOrientation?: number;
  56099. frontUVs?: Vector4;
  56100. backUVs?: Vector4;
  56101. cap?: number;
  56102. invertUV?: boolean;
  56103. }, scene?: Nullable<Scene>): Mesh;
  56104. }
  56105. }
  56106. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56107. import { Nullable } from "babylonjs/types";
  56108. import { Scene } from "babylonjs/scene";
  56109. import { Vector4 } from "babylonjs/Maths/math.vector";
  56110. import { Mesh } from "babylonjs/Meshes/mesh";
  56111. /**
  56112. * Class containing static functions to help procedurally build meshes
  56113. */
  56114. export class TiledPlaneBuilder {
  56115. /**
  56116. * Creates a tiled plane mesh
  56117. * * The parameter `pattern` will, depending on value, do nothing or
  56118. * * * flip (reflect about central vertical) alternate tiles across and up
  56119. * * * flip every tile on alternate rows
  56120. * * * rotate (180 degs) alternate tiles across and up
  56121. * * * rotate every tile on alternate rows
  56122. * * * flip and rotate alternate tiles across and up
  56123. * * * flip and rotate every tile on alternate rows
  56124. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56125. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56128. * * 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)
  56129. * * 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)
  56130. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56131. * @param name defines the name of the mesh
  56132. * @param options defines the options used to create the mesh
  56133. * @param scene defines the hosting scene
  56134. * @returns the box mesh
  56135. */
  56136. static CreateTiledPlane(name: string, options: {
  56137. pattern?: number;
  56138. tileSize?: number;
  56139. tileWidth?: number;
  56140. tileHeight?: number;
  56141. size?: number;
  56142. width?: number;
  56143. height?: number;
  56144. alignHorizontal?: number;
  56145. alignVertical?: number;
  56146. sideOrientation?: number;
  56147. frontUVs?: Vector4;
  56148. backUVs?: Vector4;
  56149. updatable?: boolean;
  56150. }, scene?: Nullable<Scene>): Mesh;
  56151. }
  56152. }
  56153. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56154. import { Nullable } from "babylonjs/types";
  56155. import { Scene } from "babylonjs/scene";
  56156. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56157. import { Mesh } from "babylonjs/Meshes/mesh";
  56158. /**
  56159. * Class containing static functions to help procedurally build meshes
  56160. */
  56161. export class TubeBuilder {
  56162. /**
  56163. * Creates a tube mesh.
  56164. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56165. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56166. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56167. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56168. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56169. * * 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)
  56170. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56171. * * 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
  56172. * * 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
  56173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56175. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56177. * @param name defines the name of the mesh
  56178. * @param options defines the options used to create the mesh
  56179. * @param scene defines the hosting scene
  56180. * @returns the tube mesh
  56181. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56182. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56183. */
  56184. static CreateTube(name: string, options: {
  56185. path: Vector3[];
  56186. radius?: number;
  56187. tessellation?: number;
  56188. radiusFunction?: {
  56189. (i: number, distance: number): number;
  56190. };
  56191. cap?: number;
  56192. arc?: number;
  56193. updatable?: boolean;
  56194. sideOrientation?: number;
  56195. frontUVs?: Vector4;
  56196. backUVs?: Vector4;
  56197. instance?: Mesh;
  56198. invertUV?: boolean;
  56199. }, scene?: Nullable<Scene>): Mesh;
  56200. }
  56201. }
  56202. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56203. import { Scene } from "babylonjs/scene";
  56204. import { Vector4 } from "babylonjs/Maths/math.vector";
  56205. import { Mesh } from "babylonjs/Meshes/mesh";
  56206. import { Nullable } from "babylonjs/types";
  56207. /**
  56208. * Class containing static functions to help procedurally build meshes
  56209. */
  56210. export class IcoSphereBuilder {
  56211. /**
  56212. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56213. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56214. * * 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`)
  56215. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56216. * * 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
  56217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56220. * @param name defines the name of the mesh
  56221. * @param options defines the options used to create the mesh
  56222. * @param scene defines the hosting scene
  56223. * @returns the icosahedron mesh
  56224. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56225. */
  56226. static CreateIcoSphere(name: string, options: {
  56227. radius?: number;
  56228. radiusX?: number;
  56229. radiusY?: number;
  56230. radiusZ?: number;
  56231. flat?: boolean;
  56232. subdivisions?: number;
  56233. sideOrientation?: number;
  56234. frontUVs?: Vector4;
  56235. backUVs?: Vector4;
  56236. updatable?: boolean;
  56237. }, scene?: Nullable<Scene>): Mesh;
  56238. }
  56239. }
  56240. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56241. import { Vector3 } from "babylonjs/Maths/math.vector";
  56242. import { Mesh } from "babylonjs/Meshes/mesh";
  56243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56244. /**
  56245. * Class containing static functions to help procedurally build meshes
  56246. */
  56247. export class DecalBuilder {
  56248. /**
  56249. * Creates a decal mesh.
  56250. * 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
  56251. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56252. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56253. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56254. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56255. * @param name defines the name of the mesh
  56256. * @param sourceMesh defines the mesh where the decal must be applied
  56257. * @param options defines the options used to create the mesh
  56258. * @param scene defines the hosting scene
  56259. * @returns the decal mesh
  56260. * @see https://doc.babylonjs.com/how_to/decals
  56261. */
  56262. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56263. position?: Vector3;
  56264. normal?: Vector3;
  56265. size?: Vector3;
  56266. angle?: number;
  56267. }): Mesh;
  56268. }
  56269. }
  56270. declare module "babylonjs/Meshes/meshBuilder" {
  56271. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56272. import { Nullable } from "babylonjs/types";
  56273. import { Scene } from "babylonjs/scene";
  56274. import { Mesh } from "babylonjs/Meshes/mesh";
  56275. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56276. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56278. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56279. import { Plane } from "babylonjs/Maths/math.plane";
  56280. /**
  56281. * Class containing static functions to help procedurally build meshes
  56282. */
  56283. export class MeshBuilder {
  56284. /**
  56285. * Creates a box mesh
  56286. * * The parameter `size` sets the size (float) of each box side (default 1)
  56287. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56288. * * 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)
  56289. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56293. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56294. * @param name defines the name of the mesh
  56295. * @param options defines the options used to create the mesh
  56296. * @param scene defines the hosting scene
  56297. * @returns the box mesh
  56298. */
  56299. static CreateBox(name: string, options: {
  56300. size?: number;
  56301. width?: number;
  56302. height?: number;
  56303. depth?: number;
  56304. faceUV?: Vector4[];
  56305. faceColors?: Color4[];
  56306. sideOrientation?: number;
  56307. frontUVs?: Vector4;
  56308. backUVs?: Vector4;
  56309. updatable?: boolean;
  56310. }, scene?: Nullable<Scene>): Mesh;
  56311. /**
  56312. * Creates a tiled box mesh
  56313. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56315. * @param name defines the name of the mesh
  56316. * @param options defines the options used to create the mesh
  56317. * @param scene defines the hosting scene
  56318. * @returns the tiled box mesh
  56319. */
  56320. static CreateTiledBox(name: string, options: {
  56321. pattern?: number;
  56322. size?: number;
  56323. width?: number;
  56324. height?: number;
  56325. depth: number;
  56326. tileSize?: number;
  56327. tileWidth?: number;
  56328. tileHeight?: number;
  56329. faceUV?: Vector4[];
  56330. faceColors?: Color4[];
  56331. alignHorizontal?: number;
  56332. alignVertical?: number;
  56333. sideOrientation?: number;
  56334. updatable?: boolean;
  56335. }, scene?: Nullable<Scene>): Mesh;
  56336. /**
  56337. * Creates a sphere mesh
  56338. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56339. * * 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`)
  56340. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56341. * * 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
  56342. * * 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)
  56343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56346. * @param name defines the name of the mesh
  56347. * @param options defines the options used to create the mesh
  56348. * @param scene defines the hosting scene
  56349. * @returns the sphere mesh
  56350. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56351. */
  56352. static CreateSphere(name: string, options: {
  56353. segments?: number;
  56354. diameter?: number;
  56355. diameterX?: number;
  56356. diameterY?: number;
  56357. diameterZ?: number;
  56358. arc?: number;
  56359. slice?: number;
  56360. sideOrientation?: number;
  56361. frontUVs?: Vector4;
  56362. backUVs?: Vector4;
  56363. updatable?: boolean;
  56364. }, scene?: Nullable<Scene>): Mesh;
  56365. /**
  56366. * Creates a plane polygonal mesh. By default, this is a disc
  56367. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56368. * * 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
  56369. * * 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
  56370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56373. * @param name defines the name of the mesh
  56374. * @param options defines the options used to create the mesh
  56375. * @param scene defines the hosting scene
  56376. * @returns the plane polygonal mesh
  56377. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56378. */
  56379. static CreateDisc(name: string, options: {
  56380. radius?: number;
  56381. tessellation?: number;
  56382. arc?: number;
  56383. updatable?: boolean;
  56384. sideOrientation?: number;
  56385. frontUVs?: Vector4;
  56386. backUVs?: Vector4;
  56387. }, scene?: Nullable<Scene>): Mesh;
  56388. /**
  56389. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56390. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56391. * * 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`)
  56392. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56393. * * 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
  56394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56397. * @param name defines the name of the mesh
  56398. * @param options defines the options used to create the mesh
  56399. * @param scene defines the hosting scene
  56400. * @returns the icosahedron mesh
  56401. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56402. */
  56403. static CreateIcoSphere(name: string, options: {
  56404. radius?: number;
  56405. radiusX?: number;
  56406. radiusY?: number;
  56407. radiusZ?: number;
  56408. flat?: boolean;
  56409. subdivisions?: number;
  56410. sideOrientation?: number;
  56411. frontUVs?: Vector4;
  56412. backUVs?: Vector4;
  56413. updatable?: boolean;
  56414. }, scene?: Nullable<Scene>): Mesh;
  56415. /**
  56416. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56417. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56418. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56419. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56420. * * 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
  56421. * * 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
  56422. * * 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
  56423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56426. * * 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
  56427. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56428. * * 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
  56429. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56431. * @param name defines the name of the mesh
  56432. * @param options defines the options used to create the mesh
  56433. * @param scene defines the hosting scene
  56434. * @returns the ribbon mesh
  56435. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56436. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56437. */
  56438. static CreateRibbon(name: string, options: {
  56439. pathArray: Vector3[][];
  56440. closeArray?: boolean;
  56441. closePath?: boolean;
  56442. offset?: number;
  56443. updatable?: boolean;
  56444. sideOrientation?: number;
  56445. frontUVs?: Vector4;
  56446. backUVs?: Vector4;
  56447. instance?: Mesh;
  56448. invertUV?: boolean;
  56449. uvs?: Vector2[];
  56450. colors?: Color4[];
  56451. }, scene?: Nullable<Scene>): Mesh;
  56452. /**
  56453. * Creates a cylinder or a cone mesh
  56454. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56455. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56456. * * 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.
  56457. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56458. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56459. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56460. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56461. * * 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).
  56462. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56463. * * 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).
  56464. * * 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
  56465. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56466. * * 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
  56467. * * 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.
  56468. * * If `enclose` is false, a ring surface is one element.
  56469. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56470. * * 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
  56471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56474. * @param name defines the name of the mesh
  56475. * @param options defines the options used to create the mesh
  56476. * @param scene defines the hosting scene
  56477. * @returns the cylinder mesh
  56478. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56479. */
  56480. static CreateCylinder(name: string, options: {
  56481. height?: number;
  56482. diameterTop?: number;
  56483. diameterBottom?: number;
  56484. diameter?: number;
  56485. tessellation?: number;
  56486. subdivisions?: number;
  56487. arc?: number;
  56488. faceColors?: Color4[];
  56489. faceUV?: Vector4[];
  56490. updatable?: boolean;
  56491. hasRings?: boolean;
  56492. enclose?: boolean;
  56493. cap?: number;
  56494. sideOrientation?: number;
  56495. frontUVs?: Vector4;
  56496. backUVs?: Vector4;
  56497. }, scene?: Nullable<Scene>): Mesh;
  56498. /**
  56499. * Creates a torus mesh
  56500. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56501. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56502. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56506. * @param name defines the name of the mesh
  56507. * @param options defines the options used to create the mesh
  56508. * @param scene defines the hosting scene
  56509. * @returns the torus mesh
  56510. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56511. */
  56512. static CreateTorus(name: string, options: {
  56513. diameter?: number;
  56514. thickness?: number;
  56515. tessellation?: number;
  56516. updatable?: boolean;
  56517. sideOrientation?: number;
  56518. frontUVs?: Vector4;
  56519. backUVs?: Vector4;
  56520. }, scene?: Nullable<Scene>): Mesh;
  56521. /**
  56522. * Creates a torus knot mesh
  56523. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56524. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56525. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56526. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56530. * @param name defines the name of the mesh
  56531. * @param options defines the options used to create the mesh
  56532. * @param scene defines the hosting scene
  56533. * @returns the torus knot mesh
  56534. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56535. */
  56536. static CreateTorusKnot(name: string, options: {
  56537. radius?: number;
  56538. tube?: number;
  56539. radialSegments?: number;
  56540. tubularSegments?: number;
  56541. p?: number;
  56542. q?: number;
  56543. updatable?: boolean;
  56544. sideOrientation?: number;
  56545. frontUVs?: Vector4;
  56546. backUVs?: Vector4;
  56547. }, scene?: Nullable<Scene>): Mesh;
  56548. /**
  56549. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56550. * * 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
  56551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56552. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56553. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56554. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56555. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56556. * * 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
  56557. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56560. * @param name defines the name of the new line system
  56561. * @param options defines the options used to create the line system
  56562. * @param scene defines the hosting scene
  56563. * @returns a new line system mesh
  56564. */
  56565. static CreateLineSystem(name: string, options: {
  56566. lines: Vector3[][];
  56567. updatable?: boolean;
  56568. instance?: Nullable<LinesMesh>;
  56569. colors?: Nullable<Color4[][]>;
  56570. useVertexAlpha?: boolean;
  56571. }, scene: Nullable<Scene>): LinesMesh;
  56572. /**
  56573. * Creates a line mesh
  56574. * 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
  56575. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56576. * * The parameter `points` is an array successive Vector3
  56577. * * 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
  56578. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56579. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56580. * * When updating an instance, remember that only point positions can change, not the number of points
  56581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56582. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56583. * @param name defines the name of the new line system
  56584. * @param options defines the options used to create the line system
  56585. * @param scene defines the hosting scene
  56586. * @returns a new line mesh
  56587. */
  56588. static CreateLines(name: string, options: {
  56589. points: Vector3[];
  56590. updatable?: boolean;
  56591. instance?: Nullable<LinesMesh>;
  56592. colors?: Color4[];
  56593. useVertexAlpha?: boolean;
  56594. }, scene?: Nullable<Scene>): LinesMesh;
  56595. /**
  56596. * Creates a dashed line mesh
  56597. * * 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
  56598. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56599. * * The parameter `points` is an array successive Vector3
  56600. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56601. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56602. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56603. * * 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
  56604. * * When updating an instance, remember that only point positions can change, not the number of points
  56605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56606. * @param name defines the name of the mesh
  56607. * @param options defines the options used to create the mesh
  56608. * @param scene defines the hosting scene
  56609. * @returns the dashed line mesh
  56610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56611. */
  56612. static CreateDashedLines(name: string, options: {
  56613. points: Vector3[];
  56614. dashSize?: number;
  56615. gapSize?: number;
  56616. dashNb?: number;
  56617. updatable?: boolean;
  56618. instance?: LinesMesh;
  56619. }, scene?: Nullable<Scene>): LinesMesh;
  56620. /**
  56621. * 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.
  56622. * * 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.
  56623. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56624. * * 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.
  56625. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56626. * * 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
  56627. * * 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
  56628. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56631. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56633. * @param name defines the name of the mesh
  56634. * @param options defines the options used to create the mesh
  56635. * @param scene defines the hosting scene
  56636. * @returns the extruded shape mesh
  56637. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56639. */
  56640. static ExtrudeShape(name: string, options: {
  56641. shape: Vector3[];
  56642. path: Vector3[];
  56643. scale?: number;
  56644. rotation?: number;
  56645. cap?: number;
  56646. updatable?: boolean;
  56647. sideOrientation?: number;
  56648. frontUVs?: Vector4;
  56649. backUVs?: Vector4;
  56650. instance?: Mesh;
  56651. invertUV?: boolean;
  56652. }, scene?: Nullable<Scene>): Mesh;
  56653. /**
  56654. * Creates an custom extruded shape mesh.
  56655. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56656. * * 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.
  56657. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56658. * * 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
  56659. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56660. * * 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
  56661. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56662. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56663. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56664. * * 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
  56665. * * 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
  56666. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56671. * @param name defines the name of the mesh
  56672. * @param options defines the options used to create the mesh
  56673. * @param scene defines the hosting scene
  56674. * @returns the custom extruded shape mesh
  56675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56678. */
  56679. static ExtrudeShapeCustom(name: string, options: {
  56680. shape: Vector3[];
  56681. path: Vector3[];
  56682. scaleFunction?: any;
  56683. rotationFunction?: any;
  56684. ribbonCloseArray?: boolean;
  56685. ribbonClosePath?: boolean;
  56686. cap?: number;
  56687. updatable?: boolean;
  56688. sideOrientation?: number;
  56689. frontUVs?: Vector4;
  56690. backUVs?: Vector4;
  56691. instance?: Mesh;
  56692. invertUV?: boolean;
  56693. }, scene?: Nullable<Scene>): Mesh;
  56694. /**
  56695. * Creates lathe mesh.
  56696. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56697. * * 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
  56698. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56699. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56700. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56701. * * 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
  56702. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56703. * * 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
  56704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56706. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56708. * @param name defines the name of the mesh
  56709. * @param options defines the options used to create the mesh
  56710. * @param scene defines the hosting scene
  56711. * @returns the lathe mesh
  56712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56713. */
  56714. static CreateLathe(name: string, options: {
  56715. shape: Vector3[];
  56716. radius?: number;
  56717. tessellation?: number;
  56718. clip?: number;
  56719. arc?: number;
  56720. closed?: boolean;
  56721. updatable?: boolean;
  56722. sideOrientation?: number;
  56723. frontUVs?: Vector4;
  56724. backUVs?: Vector4;
  56725. cap?: number;
  56726. invertUV?: boolean;
  56727. }, scene?: Nullable<Scene>): Mesh;
  56728. /**
  56729. * Creates a tiled plane mesh
  56730. * * You can set a limited pattern arrangement with the tiles
  56731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56734. * @param name defines the name of the mesh
  56735. * @param options defines the options used to create the mesh
  56736. * @param scene defines the hosting scene
  56737. * @returns the plane mesh
  56738. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56739. */
  56740. static CreateTiledPlane(name: string, options: {
  56741. pattern?: number;
  56742. tileSize?: number;
  56743. tileWidth?: number;
  56744. tileHeight?: number;
  56745. size?: number;
  56746. width?: number;
  56747. height?: number;
  56748. alignHorizontal?: number;
  56749. alignVertical?: number;
  56750. sideOrientation?: number;
  56751. frontUVs?: Vector4;
  56752. backUVs?: Vector4;
  56753. updatable?: boolean;
  56754. }, scene?: Nullable<Scene>): Mesh;
  56755. /**
  56756. * Creates a plane mesh
  56757. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56758. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56759. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56763. * @param name defines the name of the mesh
  56764. * @param options defines the options used to create the mesh
  56765. * @param scene defines the hosting scene
  56766. * @returns the plane mesh
  56767. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56768. */
  56769. static CreatePlane(name: string, options: {
  56770. size?: number;
  56771. width?: number;
  56772. height?: number;
  56773. sideOrientation?: number;
  56774. frontUVs?: Vector4;
  56775. backUVs?: Vector4;
  56776. updatable?: boolean;
  56777. sourcePlane?: Plane;
  56778. }, scene?: Nullable<Scene>): Mesh;
  56779. /**
  56780. * Creates a ground mesh
  56781. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56782. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56784. * @param name defines the name of the mesh
  56785. * @param options defines the options used to create the mesh
  56786. * @param scene defines the hosting scene
  56787. * @returns the ground mesh
  56788. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56789. */
  56790. static CreateGround(name: string, options: {
  56791. width?: number;
  56792. height?: number;
  56793. subdivisions?: number;
  56794. subdivisionsX?: number;
  56795. subdivisionsY?: number;
  56796. updatable?: boolean;
  56797. }, scene?: Nullable<Scene>): Mesh;
  56798. /**
  56799. * Creates a tiled ground mesh
  56800. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56801. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56802. * * 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
  56803. * * 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
  56804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56805. * @param name defines the name of the mesh
  56806. * @param options defines the options used to create the mesh
  56807. * @param scene defines the hosting scene
  56808. * @returns the tiled ground mesh
  56809. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56810. */
  56811. static CreateTiledGround(name: string, options: {
  56812. xmin: number;
  56813. zmin: number;
  56814. xmax: number;
  56815. zmax: number;
  56816. subdivisions?: {
  56817. w: number;
  56818. h: number;
  56819. };
  56820. precision?: {
  56821. w: number;
  56822. h: number;
  56823. };
  56824. updatable?: boolean;
  56825. }, scene?: Nullable<Scene>): Mesh;
  56826. /**
  56827. * Creates a ground mesh from a height map
  56828. * * The parameter `url` sets the URL of the height map image resource.
  56829. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56830. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56831. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56832. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56833. * * 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.
  56834. * * 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).
  56835. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56837. * @param name defines the name of the mesh
  56838. * @param url defines the url to the height map
  56839. * @param options defines the options used to create the mesh
  56840. * @param scene defines the hosting scene
  56841. * @returns the ground mesh
  56842. * @see https://doc.babylonjs.com/babylon101/height_map
  56843. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56844. */
  56845. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56846. width?: number;
  56847. height?: number;
  56848. subdivisions?: number;
  56849. minHeight?: number;
  56850. maxHeight?: number;
  56851. colorFilter?: Color3;
  56852. alphaFilter?: number;
  56853. updatable?: boolean;
  56854. onReady?: (mesh: GroundMesh) => void;
  56855. }, scene?: Nullable<Scene>): GroundMesh;
  56856. /**
  56857. * Creates a polygon mesh
  56858. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56859. * * 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
  56860. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56863. * * Remember you can only change the shape positions, not their number when updating a polygon
  56864. * @param name defines the name of the mesh
  56865. * @param options defines the options used to create the mesh
  56866. * @param scene defines the hosting scene
  56867. * @param earcutInjection can be used to inject your own earcut reference
  56868. * @returns the polygon mesh
  56869. */
  56870. static CreatePolygon(name: string, options: {
  56871. shape: Vector3[];
  56872. holes?: Vector3[][];
  56873. depth?: number;
  56874. faceUV?: Vector4[];
  56875. faceColors?: Color4[];
  56876. updatable?: boolean;
  56877. sideOrientation?: number;
  56878. frontUVs?: Vector4;
  56879. backUVs?: Vector4;
  56880. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56881. /**
  56882. * Creates an extruded polygon mesh, with depth in the Y direction.
  56883. * * 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)
  56884. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56885. * @param name defines the name of the mesh
  56886. * @param options defines the options used to create the mesh
  56887. * @param scene defines the hosting scene
  56888. * @param earcutInjection can be used to inject your own earcut reference
  56889. * @returns the polygon mesh
  56890. */
  56891. static ExtrudePolygon(name: string, options: {
  56892. shape: Vector3[];
  56893. holes?: Vector3[][];
  56894. depth?: number;
  56895. faceUV?: Vector4[];
  56896. faceColors?: Color4[];
  56897. updatable?: boolean;
  56898. sideOrientation?: number;
  56899. frontUVs?: Vector4;
  56900. backUVs?: Vector4;
  56901. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56902. /**
  56903. * Creates a tube mesh.
  56904. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56905. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56906. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56907. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56908. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56909. * * 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)
  56910. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56911. * * 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
  56912. * * 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
  56913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56917. * @param name defines the name of the mesh
  56918. * @param options defines the options used to create the mesh
  56919. * @param scene defines the hosting scene
  56920. * @returns the tube mesh
  56921. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56922. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56923. */
  56924. static CreateTube(name: string, options: {
  56925. path: Vector3[];
  56926. radius?: number;
  56927. tessellation?: number;
  56928. radiusFunction?: {
  56929. (i: number, distance: number): number;
  56930. };
  56931. cap?: number;
  56932. arc?: number;
  56933. updatable?: boolean;
  56934. sideOrientation?: number;
  56935. frontUVs?: Vector4;
  56936. backUVs?: Vector4;
  56937. instance?: Mesh;
  56938. invertUV?: boolean;
  56939. }, scene?: Nullable<Scene>): Mesh;
  56940. /**
  56941. * Creates a polyhedron mesh
  56942. * * 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
  56943. * * The parameter `size` (positive float, default 1) sets the polygon size
  56944. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56945. * * 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`
  56946. * * 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
  56947. * * 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)`)
  56948. * * 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
  56949. * * 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
  56950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56953. * @param name defines the name of the mesh
  56954. * @param options defines the options used to create the mesh
  56955. * @param scene defines the hosting scene
  56956. * @returns the polyhedron mesh
  56957. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56958. */
  56959. static CreatePolyhedron(name: string, options: {
  56960. type?: number;
  56961. size?: number;
  56962. sizeX?: number;
  56963. sizeY?: number;
  56964. sizeZ?: number;
  56965. custom?: any;
  56966. faceUV?: Vector4[];
  56967. faceColors?: Color4[];
  56968. flat?: boolean;
  56969. updatable?: boolean;
  56970. sideOrientation?: number;
  56971. frontUVs?: Vector4;
  56972. backUVs?: Vector4;
  56973. }, scene?: Nullable<Scene>): Mesh;
  56974. /**
  56975. * Creates a decal mesh.
  56976. * 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
  56977. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56978. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56979. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56980. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56981. * @param name defines the name of the mesh
  56982. * @param sourceMesh defines the mesh where the decal must be applied
  56983. * @param options defines the options used to create the mesh
  56984. * @param scene defines the hosting scene
  56985. * @returns the decal mesh
  56986. * @see https://doc.babylonjs.com/how_to/decals
  56987. */
  56988. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56989. position?: Vector3;
  56990. normal?: Vector3;
  56991. size?: Vector3;
  56992. angle?: number;
  56993. }): Mesh;
  56994. }
  56995. }
  56996. declare module "babylonjs/Meshes/meshSimplification" {
  56997. import { Mesh } from "babylonjs/Meshes/mesh";
  56998. /**
  56999. * A simplifier interface for future simplification implementations
  57000. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57001. */
  57002. export interface ISimplifier {
  57003. /**
  57004. * Simplification of a given mesh according to the given settings.
  57005. * Since this requires computation, it is assumed that the function runs async.
  57006. * @param settings The settings of the simplification, including quality and distance
  57007. * @param successCallback A callback that will be called after the mesh was simplified.
  57008. * @param errorCallback in case of an error, this callback will be called. optional.
  57009. */
  57010. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57011. }
  57012. /**
  57013. * Expected simplification settings.
  57014. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57015. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57016. */
  57017. export interface ISimplificationSettings {
  57018. /**
  57019. * Gets or sets the expected quality
  57020. */
  57021. quality: number;
  57022. /**
  57023. * Gets or sets the distance when this optimized version should be used
  57024. */
  57025. distance: number;
  57026. /**
  57027. * Gets an already optimized mesh
  57028. */
  57029. optimizeMesh?: boolean;
  57030. }
  57031. /**
  57032. * Class used to specify simplification options
  57033. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57034. */
  57035. export class SimplificationSettings implements ISimplificationSettings {
  57036. /** expected quality */
  57037. quality: number;
  57038. /** distance when this optimized version should be used */
  57039. distance: number;
  57040. /** already optimized mesh */
  57041. optimizeMesh?: boolean | undefined;
  57042. /**
  57043. * Creates a SimplificationSettings
  57044. * @param quality expected quality
  57045. * @param distance distance when this optimized version should be used
  57046. * @param optimizeMesh already optimized mesh
  57047. */
  57048. constructor(
  57049. /** expected quality */
  57050. quality: number,
  57051. /** distance when this optimized version should be used */
  57052. distance: number,
  57053. /** already optimized mesh */
  57054. optimizeMesh?: boolean | undefined);
  57055. }
  57056. /**
  57057. * Interface used to define a simplification task
  57058. */
  57059. export interface ISimplificationTask {
  57060. /**
  57061. * Array of settings
  57062. */
  57063. settings: Array<ISimplificationSettings>;
  57064. /**
  57065. * Simplification type
  57066. */
  57067. simplificationType: SimplificationType;
  57068. /**
  57069. * Mesh to simplify
  57070. */
  57071. mesh: Mesh;
  57072. /**
  57073. * Callback called on success
  57074. */
  57075. successCallback?: () => void;
  57076. /**
  57077. * Defines if parallel processing can be used
  57078. */
  57079. parallelProcessing: boolean;
  57080. }
  57081. /**
  57082. * Queue used to order the simplification tasks
  57083. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57084. */
  57085. export class SimplificationQueue {
  57086. private _simplificationArray;
  57087. /**
  57088. * Gets a boolean indicating that the process is still running
  57089. */
  57090. running: boolean;
  57091. /**
  57092. * Creates a new queue
  57093. */
  57094. constructor();
  57095. /**
  57096. * Adds a new simplification task
  57097. * @param task defines a task to add
  57098. */
  57099. addTask(task: ISimplificationTask): void;
  57100. /**
  57101. * Execute next task
  57102. */
  57103. executeNext(): void;
  57104. /**
  57105. * Execute a simplification task
  57106. * @param task defines the task to run
  57107. */
  57108. runSimplification(task: ISimplificationTask): void;
  57109. private getSimplifier;
  57110. }
  57111. /**
  57112. * The implemented types of simplification
  57113. * At the moment only Quadratic Error Decimation is implemented
  57114. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57115. */
  57116. export enum SimplificationType {
  57117. /** Quadratic error decimation */
  57118. QUADRATIC = 0
  57119. }
  57120. }
  57121. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57122. import { Scene } from "babylonjs/scene";
  57123. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57124. import { ISceneComponent } from "babylonjs/sceneComponent";
  57125. module "babylonjs/scene" {
  57126. interface Scene {
  57127. /** @hidden (Backing field) */
  57128. _simplificationQueue: SimplificationQueue;
  57129. /**
  57130. * Gets or sets the simplification queue attached to the scene
  57131. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57132. */
  57133. simplificationQueue: SimplificationQueue;
  57134. }
  57135. }
  57136. module "babylonjs/Meshes/mesh" {
  57137. interface Mesh {
  57138. /**
  57139. * Simplify the mesh according to the given array of settings.
  57140. * Function will return immediately and will simplify async
  57141. * @param settings a collection of simplification settings
  57142. * @param parallelProcessing should all levels calculate parallel or one after the other
  57143. * @param simplificationType the type of simplification to run
  57144. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57145. * @returns the current mesh
  57146. */
  57147. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57148. }
  57149. }
  57150. /**
  57151. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57152. * created in a scene
  57153. */
  57154. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57155. /**
  57156. * The component name helpfull to identify the component in the list of scene components.
  57157. */
  57158. readonly name: string;
  57159. /**
  57160. * The scene the component belongs to.
  57161. */
  57162. scene: Scene;
  57163. /**
  57164. * Creates a new instance of the component for the given scene
  57165. * @param scene Defines the scene to register the component in
  57166. */
  57167. constructor(scene: Scene);
  57168. /**
  57169. * Registers the component in a given scene
  57170. */
  57171. register(): void;
  57172. /**
  57173. * Rebuilds the elements related to this component in case of
  57174. * context lost for instance.
  57175. */
  57176. rebuild(): void;
  57177. /**
  57178. * Disposes the component and the associated ressources
  57179. */
  57180. dispose(): void;
  57181. private _beforeCameraUpdate;
  57182. }
  57183. }
  57184. declare module "babylonjs/Meshes/Builders/index" {
  57185. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57186. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57187. export * from "babylonjs/Meshes/Builders/discBuilder";
  57188. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57189. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57190. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57191. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57192. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57193. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57194. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57195. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57196. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57197. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57198. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57199. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57200. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57201. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57202. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57203. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57204. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57205. }
  57206. declare module "babylonjs/Meshes/index" {
  57207. export * from "babylonjs/Meshes/abstractMesh";
  57208. export * from "babylonjs/Meshes/buffer";
  57209. export * from "babylonjs/Meshes/Compression/index";
  57210. export * from "babylonjs/Meshes/csg";
  57211. export * from "babylonjs/Meshes/geometry";
  57212. export * from "babylonjs/Meshes/groundMesh";
  57213. export * from "babylonjs/Meshes/trailMesh";
  57214. export * from "babylonjs/Meshes/instancedMesh";
  57215. export * from "babylonjs/Meshes/linesMesh";
  57216. export * from "babylonjs/Meshes/mesh";
  57217. export * from "babylonjs/Meshes/mesh.vertexData";
  57218. export * from "babylonjs/Meshes/meshBuilder";
  57219. export * from "babylonjs/Meshes/meshSimplification";
  57220. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57221. export * from "babylonjs/Meshes/polygonMesh";
  57222. export * from "babylonjs/Meshes/subMesh";
  57223. export * from "babylonjs/Meshes/meshLODLevel";
  57224. export * from "babylonjs/Meshes/transformNode";
  57225. export * from "babylonjs/Meshes/Builders/index";
  57226. export * from "babylonjs/Meshes/dataBuffer";
  57227. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57228. }
  57229. declare module "babylonjs/Morph/index" {
  57230. export * from "babylonjs/Morph/morphTarget";
  57231. export * from "babylonjs/Morph/morphTargetManager";
  57232. }
  57233. declare module "babylonjs/Navigation/INavigationEngine" {
  57234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57235. import { Vector3 } from "babylonjs/Maths/math";
  57236. import { Mesh } from "babylonjs/Meshes/mesh";
  57237. import { Scene } from "babylonjs/scene";
  57238. /**
  57239. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57240. */
  57241. export interface INavigationEnginePlugin {
  57242. /**
  57243. * plugin name
  57244. */
  57245. name: string;
  57246. /**
  57247. * Creates a navigation mesh
  57248. * @param meshes array of all the geometry used to compute the navigatio mesh
  57249. * @param parameters bunch of parameters used to filter geometry
  57250. */
  57251. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57252. /**
  57253. * Create a navigation mesh debug mesh
  57254. * @param scene is where the mesh will be added
  57255. * @returns debug display mesh
  57256. */
  57257. createDebugNavMesh(scene: Scene): Mesh;
  57258. /**
  57259. * Get a navigation mesh constrained position, closest to the parameter position
  57260. * @param position world position
  57261. * @returns the closest point to position constrained by the navigation mesh
  57262. */
  57263. getClosestPoint(position: Vector3): Vector3;
  57264. /**
  57265. * Get a navigation mesh constrained position, within a particular radius
  57266. * @param position world position
  57267. * @param maxRadius the maximum distance to the constrained world position
  57268. * @returns the closest point to position constrained by the navigation mesh
  57269. */
  57270. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57271. /**
  57272. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57273. * @param start world position
  57274. * @param end world position
  57275. * @returns array containing world position composing the path
  57276. */
  57277. computePath(start: Vector3, end: Vector3): Vector3[];
  57278. /**
  57279. * If this plugin is supported
  57280. * @returns true if plugin is supported
  57281. */
  57282. isSupported(): boolean;
  57283. /**
  57284. * Create a new Crowd so you can add agents
  57285. * @param maxAgents the maximum agent count in the crowd
  57286. * @param maxAgentRadius the maximum radius an agent can have
  57287. * @param scene to attach the crowd to
  57288. * @returns the crowd you can add agents to
  57289. */
  57290. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57291. /**
  57292. * Release all resources
  57293. */
  57294. dispose(): void;
  57295. }
  57296. /**
  57297. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57298. */
  57299. export interface ICrowd {
  57300. /**
  57301. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57302. * You can attach anything to that node. The node position is updated in the scene update tick.
  57303. * @param pos world position that will be constrained by the navigation mesh
  57304. * @param parameters agent parameters
  57305. * @param transform hooked to the agent that will be update by the scene
  57306. * @returns agent index
  57307. */
  57308. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57309. /**
  57310. * Returns the agent position in world space
  57311. * @param index agent index returned by addAgent
  57312. * @returns world space position
  57313. */
  57314. getAgentPosition(index: number): Vector3;
  57315. /**
  57316. * Gets the agent velocity in world space
  57317. * @param index agent index returned by addAgent
  57318. * @returns world space velocity
  57319. */
  57320. getAgentVelocity(index: number): Vector3;
  57321. /**
  57322. * remove a particular agent previously created
  57323. * @param index agent index returned by addAgent
  57324. */
  57325. removeAgent(index: number): void;
  57326. /**
  57327. * get the list of all agents attached to this crowd
  57328. * @returns list of agent indices
  57329. */
  57330. getAgents(): number[];
  57331. /**
  57332. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57333. * @param deltaTime in seconds
  57334. */
  57335. update(deltaTime: number): void;
  57336. /**
  57337. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57338. * @param index agent index returned by addAgent
  57339. * @param destination targeted world position
  57340. */
  57341. agentGoto(index: number, destination: Vector3): void;
  57342. /**
  57343. * Release all resources
  57344. */
  57345. dispose(): void;
  57346. }
  57347. /**
  57348. * Configures an agent
  57349. */
  57350. export interface IAgentParameters {
  57351. /**
  57352. * Agent radius. [Limit: >= 0]
  57353. */
  57354. radius: number;
  57355. /**
  57356. * Agent height. [Limit: > 0]
  57357. */
  57358. height: number;
  57359. /**
  57360. * Maximum allowed acceleration. [Limit: >= 0]
  57361. */
  57362. maxAcceleration: number;
  57363. /**
  57364. * Maximum allowed speed. [Limit: >= 0]
  57365. */
  57366. maxSpeed: number;
  57367. /**
  57368. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57369. */
  57370. collisionQueryRange: number;
  57371. /**
  57372. * The path visibility optimization range. [Limit: > 0]
  57373. */
  57374. pathOptimizationRange: number;
  57375. /**
  57376. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57377. */
  57378. separationWeight: number;
  57379. }
  57380. /**
  57381. * Configures the navigation mesh creation
  57382. */
  57383. export interface INavMeshParameters {
  57384. /**
  57385. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57386. */
  57387. cs: number;
  57388. /**
  57389. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57390. */
  57391. ch: number;
  57392. /**
  57393. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57394. */
  57395. walkableSlopeAngle: number;
  57396. /**
  57397. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57398. * be considered walkable. [Limit: >= 3] [Units: vx]
  57399. */
  57400. walkableHeight: number;
  57401. /**
  57402. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57403. */
  57404. walkableClimb: number;
  57405. /**
  57406. * The distance to erode/shrink the walkable area of the heightfield away from
  57407. * obstructions. [Limit: >=0] [Units: vx]
  57408. */
  57409. walkableRadius: number;
  57410. /**
  57411. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57412. */
  57413. maxEdgeLen: number;
  57414. /**
  57415. * The maximum distance a simplfied contour's border edges should deviate
  57416. * the original raw contour. [Limit: >=0] [Units: vx]
  57417. */
  57418. maxSimplificationError: number;
  57419. /**
  57420. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57421. */
  57422. minRegionArea: number;
  57423. /**
  57424. * Any regions with a span count smaller than this value will, if possible,
  57425. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57426. */
  57427. mergeRegionArea: number;
  57428. /**
  57429. * The maximum number of vertices allowed for polygons generated during the
  57430. * contour to polygon conversion process. [Limit: >= 3]
  57431. */
  57432. maxVertsPerPoly: number;
  57433. /**
  57434. * Sets the sampling distance to use when generating the detail mesh.
  57435. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57436. */
  57437. detailSampleDist: number;
  57438. /**
  57439. * The maximum distance the detail mesh surface should deviate from heightfield
  57440. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57441. */
  57442. detailSampleMaxError: number;
  57443. }
  57444. }
  57445. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  57446. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  57447. import { Mesh } from "babylonjs/Meshes/mesh";
  57448. import { Scene } from "babylonjs/scene";
  57449. import { Vector3 } from "babylonjs/Maths/math";
  57450. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57451. /**
  57452. * RecastJS navigation plugin
  57453. */
  57454. export class RecastJSPlugin implements INavigationEnginePlugin {
  57455. /**
  57456. * Reference to the Recast library
  57457. */
  57458. bjsRECAST: any;
  57459. /**
  57460. * plugin name
  57461. */
  57462. name: string;
  57463. /**
  57464. * the first navmesh created. We might extend this to support multiple navmeshes
  57465. */
  57466. navMesh: any;
  57467. /**
  57468. * Initializes the recastJS plugin
  57469. * @param recastInjection can be used to inject your own recast reference
  57470. */
  57471. constructor(recastInjection?: any);
  57472. /**
  57473. * Creates a navigation mesh
  57474. * @param meshes array of all the geometry used to compute the navigatio mesh
  57475. * @param parameters bunch of parameters used to filter geometry
  57476. */
  57477. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57478. /**
  57479. * Create a navigation mesh debug mesh
  57480. * @param scene is where the mesh will be added
  57481. * @returns debug display mesh
  57482. */
  57483. createDebugNavMesh(scene: Scene): Mesh;
  57484. /**
  57485. * Get a navigation mesh constrained position, closest to the parameter position
  57486. * @param position world position
  57487. * @returns the closest point to position constrained by the navigation mesh
  57488. */
  57489. getClosestPoint(position: Vector3): Vector3;
  57490. /**
  57491. * Get a navigation mesh constrained position, within a particular radius
  57492. * @param position world position
  57493. * @param maxRadius the maximum distance to the constrained world position
  57494. * @returns the closest point to position constrained by the navigation mesh
  57495. */
  57496. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57497. /**
  57498. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57499. * @param start world position
  57500. * @param end world position
  57501. * @returns array containing world position composing the path
  57502. */
  57503. computePath(start: Vector3, end: Vector3): Vector3[];
  57504. /**
  57505. * Create a new Crowd so you can add agents
  57506. * @param maxAgents the maximum agent count in the crowd
  57507. * @param maxAgentRadius the maximum radius an agent can have
  57508. * @param scene to attach the crowd to
  57509. * @returns the crowd you can add agents to
  57510. */
  57511. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57512. /**
  57513. * Disposes
  57514. */
  57515. dispose(): void;
  57516. /**
  57517. * If this plugin is supported
  57518. * @returns true if plugin is supported
  57519. */
  57520. isSupported(): boolean;
  57521. }
  57522. /**
  57523. * Recast detour crowd implementation
  57524. */
  57525. export class RecastJSCrowd implements ICrowd {
  57526. /**
  57527. * Recast/detour plugin
  57528. */
  57529. bjsRECASTPlugin: RecastJSPlugin;
  57530. /**
  57531. * Link to the detour crowd
  57532. */
  57533. recastCrowd: any;
  57534. /**
  57535. * One transform per agent
  57536. */
  57537. transforms: TransformNode[];
  57538. /**
  57539. * All agents created
  57540. */
  57541. agents: number[];
  57542. /**
  57543. * Link to the scene is kept to unregister the crowd from the scene
  57544. */
  57545. private _scene;
  57546. /**
  57547. * Observer for crowd updates
  57548. */
  57549. private _onBeforeAnimationsObserver;
  57550. /**
  57551. * Constructor
  57552. * @param plugin recastJS plugin
  57553. * @param maxAgents the maximum agent count in the crowd
  57554. * @param maxAgentRadius the maximum radius an agent can have
  57555. * @param scene to attach the crowd to
  57556. * @returns the crowd you can add agents to
  57557. */
  57558. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57559. /**
  57560. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57561. * You can attach anything to that node. The node position is updated in the scene update tick.
  57562. * @param pos world position that will be constrained by the navigation mesh
  57563. * @param parameters agent parameters
  57564. * @param transform hooked to the agent that will be update by the scene
  57565. * @returns agent index
  57566. */
  57567. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57568. /**
  57569. * Returns the agent position in world space
  57570. * @param index agent index returned by addAgent
  57571. * @returns world space position
  57572. */
  57573. getAgentPosition(index: number): Vector3;
  57574. /**
  57575. * Returns the agent velocity in world space
  57576. * @param index agent index returned by addAgent
  57577. * @returns world space velocity
  57578. */
  57579. getAgentVelocity(index: number): Vector3;
  57580. /**
  57581. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57582. * @param index agent index returned by addAgent
  57583. * @param destination targeted world position
  57584. */
  57585. agentGoto(index: number, destination: Vector3): void;
  57586. /**
  57587. * remove a particular agent previously created
  57588. * @param index agent index returned by addAgent
  57589. */
  57590. removeAgent(index: number): void;
  57591. /**
  57592. * get the list of all agents attached to this crowd
  57593. * @returns list of agent indices
  57594. */
  57595. getAgents(): number[];
  57596. /**
  57597. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57598. * @param deltaTime in seconds
  57599. */
  57600. update(deltaTime: number): void;
  57601. /**
  57602. * Release all resources
  57603. */
  57604. dispose(): void;
  57605. }
  57606. }
  57607. declare module "babylonjs/Navigation/Plugins/index" {
  57608. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  57609. }
  57610. declare module "babylonjs/Navigation/index" {
  57611. export * from "babylonjs/Navigation/INavigationEngine";
  57612. export * from "babylonjs/Navigation/Plugins/index";
  57613. }
  57614. declare module "babylonjs/Offline/database" {
  57615. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  57616. /**
  57617. * Class used to enable access to IndexedDB
  57618. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57619. */
  57620. export class Database implements IOfflineProvider {
  57621. private _callbackManifestChecked;
  57622. private _currentSceneUrl;
  57623. private _db;
  57624. private _enableSceneOffline;
  57625. private _enableTexturesOffline;
  57626. private _manifestVersionFound;
  57627. private _mustUpdateRessources;
  57628. private _hasReachedQuota;
  57629. private _isSupported;
  57630. private _idbFactory;
  57631. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57632. private static IsUASupportingBlobStorage;
  57633. /**
  57634. * Gets a boolean indicating if Database storate is enabled (off by default)
  57635. */
  57636. static IDBStorageEnabled: boolean;
  57637. /**
  57638. * Gets a boolean indicating if scene must be saved in the database
  57639. */
  57640. readonly enableSceneOffline: boolean;
  57641. /**
  57642. * Gets a boolean indicating if textures must be saved in the database
  57643. */
  57644. readonly enableTexturesOffline: boolean;
  57645. /**
  57646. * Creates a new Database
  57647. * @param urlToScene defines the url to load the scene
  57648. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57649. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57650. */
  57651. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57652. private static _ParseURL;
  57653. private static _ReturnFullUrlLocation;
  57654. private _checkManifestFile;
  57655. /**
  57656. * Open the database and make it available
  57657. * @param successCallback defines the callback to call on success
  57658. * @param errorCallback defines the callback to call on error
  57659. */
  57660. open(successCallback: () => void, errorCallback: () => void): void;
  57661. /**
  57662. * Loads an image from the database
  57663. * @param url defines the url to load from
  57664. * @param image defines the target DOM image
  57665. */
  57666. loadImage(url: string, image: HTMLImageElement): void;
  57667. private _loadImageFromDBAsync;
  57668. private _saveImageIntoDBAsync;
  57669. private _checkVersionFromDB;
  57670. private _loadVersionFromDBAsync;
  57671. private _saveVersionIntoDBAsync;
  57672. /**
  57673. * Loads a file from database
  57674. * @param url defines the URL to load from
  57675. * @param sceneLoaded defines a callback to call on success
  57676. * @param progressCallBack defines a callback to call when progress changed
  57677. * @param errorCallback defines a callback to call on error
  57678. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57679. */
  57680. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57681. private _loadFileAsync;
  57682. private _saveFileAsync;
  57683. /**
  57684. * Validates if xhr data is correct
  57685. * @param xhr defines the request to validate
  57686. * @param dataType defines the expected data type
  57687. * @returns true if data is correct
  57688. */
  57689. private static _ValidateXHRData;
  57690. }
  57691. }
  57692. declare module "babylonjs/Offline/index" {
  57693. export * from "babylonjs/Offline/database";
  57694. export * from "babylonjs/Offline/IOfflineProvider";
  57695. }
  57696. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  57697. /** @hidden */
  57698. export var gpuUpdateParticlesPixelShader: {
  57699. name: string;
  57700. shader: string;
  57701. };
  57702. }
  57703. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  57704. /** @hidden */
  57705. export var gpuUpdateParticlesVertexShader: {
  57706. name: string;
  57707. shader: string;
  57708. };
  57709. }
  57710. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  57711. /** @hidden */
  57712. export var clipPlaneFragmentDeclaration2: {
  57713. name: string;
  57714. shader: string;
  57715. };
  57716. }
  57717. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  57718. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  57719. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57720. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57721. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57722. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57723. /** @hidden */
  57724. export var gpuRenderParticlesPixelShader: {
  57725. name: string;
  57726. shader: string;
  57727. };
  57728. }
  57729. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  57730. /** @hidden */
  57731. export var clipPlaneVertexDeclaration2: {
  57732. name: string;
  57733. shader: string;
  57734. };
  57735. }
  57736. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  57737. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  57738. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57739. /** @hidden */
  57740. export var gpuRenderParticlesVertexShader: {
  57741. name: string;
  57742. shader: string;
  57743. };
  57744. }
  57745. declare module "babylonjs/Particles/gpuParticleSystem" {
  57746. import { Nullable } from "babylonjs/types";
  57747. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  57748. import { Observable } from "babylonjs/Misc/observable";
  57749. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57750. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57751. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  57752. import { Scene, IDisposable } from "babylonjs/scene";
  57753. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  57754. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57755. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  57756. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  57757. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  57758. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  57759. /**
  57760. * This represents a GPU particle system in Babylon
  57761. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57762. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57763. */
  57764. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57765. /**
  57766. * The layer mask we are rendering the particles through.
  57767. */
  57768. layerMask: number;
  57769. private _capacity;
  57770. private _activeCount;
  57771. private _currentActiveCount;
  57772. private _accumulatedCount;
  57773. private _renderEffect;
  57774. private _updateEffect;
  57775. private _buffer0;
  57776. private _buffer1;
  57777. private _spriteBuffer;
  57778. private _updateVAO;
  57779. private _renderVAO;
  57780. private _targetIndex;
  57781. private _sourceBuffer;
  57782. private _targetBuffer;
  57783. private _engine;
  57784. private _currentRenderId;
  57785. private _started;
  57786. private _stopped;
  57787. private _timeDelta;
  57788. private _randomTexture;
  57789. private _randomTexture2;
  57790. private _attributesStrideSize;
  57791. private _updateEffectOptions;
  57792. private _randomTextureSize;
  57793. private _actualFrame;
  57794. private readonly _rawTextureWidth;
  57795. /**
  57796. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57797. */
  57798. static readonly IsSupported: boolean;
  57799. /**
  57800. * An event triggered when the system is disposed.
  57801. */
  57802. onDisposeObservable: Observable<GPUParticleSystem>;
  57803. /**
  57804. * Gets the maximum number of particles active at the same time.
  57805. * @returns The max number of active particles.
  57806. */
  57807. getCapacity(): number;
  57808. /**
  57809. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57810. * to override the particles.
  57811. */
  57812. forceDepthWrite: boolean;
  57813. /**
  57814. * Gets or set the number of active particles
  57815. */
  57816. activeParticleCount: number;
  57817. private _preWarmDone;
  57818. /**
  57819. * Is this system ready to be used/rendered
  57820. * @return true if the system is ready
  57821. */
  57822. isReady(): boolean;
  57823. /**
  57824. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57825. * @returns True if it has been started, otherwise false.
  57826. */
  57827. isStarted(): boolean;
  57828. /**
  57829. * Starts the particle system and begins to emit
  57830. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57831. */
  57832. start(delay?: number): void;
  57833. /**
  57834. * Stops the particle system.
  57835. */
  57836. stop(): void;
  57837. /**
  57838. * Remove all active particles
  57839. */
  57840. reset(): void;
  57841. /**
  57842. * Returns the string "GPUParticleSystem"
  57843. * @returns a string containing the class name
  57844. */
  57845. getClassName(): string;
  57846. private _colorGradientsTexture;
  57847. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57848. /**
  57849. * Adds a new color gradient
  57850. * @param gradient defines the gradient to use (between 0 and 1)
  57851. * @param color1 defines the color to affect to the specified gradient
  57852. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57853. * @returns the current particle system
  57854. */
  57855. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57856. /**
  57857. * Remove a specific color gradient
  57858. * @param gradient defines the gradient to remove
  57859. * @returns the current particle system
  57860. */
  57861. removeColorGradient(gradient: number): GPUParticleSystem;
  57862. private _angularSpeedGradientsTexture;
  57863. private _sizeGradientsTexture;
  57864. private _velocityGradientsTexture;
  57865. private _limitVelocityGradientsTexture;
  57866. private _dragGradientsTexture;
  57867. private _addFactorGradient;
  57868. /**
  57869. * Adds a new size gradient
  57870. * @param gradient defines the gradient to use (between 0 and 1)
  57871. * @param factor defines the size factor to affect to the specified gradient
  57872. * @returns the current particle system
  57873. */
  57874. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57875. /**
  57876. * Remove a specific size gradient
  57877. * @param gradient defines the gradient to remove
  57878. * @returns the current particle system
  57879. */
  57880. removeSizeGradient(gradient: number): GPUParticleSystem;
  57881. /**
  57882. * Adds a new angular speed gradient
  57883. * @param gradient defines the gradient to use (between 0 and 1)
  57884. * @param factor defines the angular speed to affect to the specified gradient
  57885. * @returns the current particle system
  57886. */
  57887. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57888. /**
  57889. * Remove a specific angular speed gradient
  57890. * @param gradient defines the gradient to remove
  57891. * @returns the current particle system
  57892. */
  57893. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57894. /**
  57895. * Adds a new velocity gradient
  57896. * @param gradient defines the gradient to use (between 0 and 1)
  57897. * @param factor defines the velocity to affect to the specified gradient
  57898. * @returns the current particle system
  57899. */
  57900. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57901. /**
  57902. * Remove a specific velocity gradient
  57903. * @param gradient defines the gradient to remove
  57904. * @returns the current particle system
  57905. */
  57906. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57907. /**
  57908. * Adds a new limit velocity gradient
  57909. * @param gradient defines the gradient to use (between 0 and 1)
  57910. * @param factor defines the limit velocity value to affect to the specified gradient
  57911. * @returns the current particle system
  57912. */
  57913. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57914. /**
  57915. * Remove a specific limit velocity gradient
  57916. * @param gradient defines the gradient to remove
  57917. * @returns the current particle system
  57918. */
  57919. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57920. /**
  57921. * Adds a new drag gradient
  57922. * @param gradient defines the gradient to use (between 0 and 1)
  57923. * @param factor defines the drag value to affect to the specified gradient
  57924. * @returns the current particle system
  57925. */
  57926. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57927. /**
  57928. * Remove a specific drag gradient
  57929. * @param gradient defines the gradient to remove
  57930. * @returns the current particle system
  57931. */
  57932. removeDragGradient(gradient: number): GPUParticleSystem;
  57933. /**
  57934. * Not supported by GPUParticleSystem
  57935. * @param gradient defines the gradient to use (between 0 and 1)
  57936. * @param factor defines the emit rate value to affect to the specified gradient
  57937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57938. * @returns the current particle system
  57939. */
  57940. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57941. /**
  57942. * Not supported by GPUParticleSystem
  57943. * @param gradient defines the gradient to remove
  57944. * @returns the current particle system
  57945. */
  57946. removeEmitRateGradient(gradient: number): IParticleSystem;
  57947. /**
  57948. * Not supported by GPUParticleSystem
  57949. * @param gradient defines the gradient to use (between 0 and 1)
  57950. * @param factor defines the start size value to affect to the specified gradient
  57951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57952. * @returns the current particle system
  57953. */
  57954. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57955. /**
  57956. * Not supported by GPUParticleSystem
  57957. * @param gradient defines the gradient to remove
  57958. * @returns the current particle system
  57959. */
  57960. removeStartSizeGradient(gradient: number): IParticleSystem;
  57961. /**
  57962. * Not supported by GPUParticleSystem
  57963. * @param gradient defines the gradient to use (between 0 and 1)
  57964. * @param min defines the color remap minimal range
  57965. * @param max defines the color remap maximal range
  57966. * @returns the current particle system
  57967. */
  57968. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57969. /**
  57970. * Not supported by GPUParticleSystem
  57971. * @param gradient defines the gradient to remove
  57972. * @returns the current particle system
  57973. */
  57974. removeColorRemapGradient(): IParticleSystem;
  57975. /**
  57976. * Not supported by GPUParticleSystem
  57977. * @param gradient defines the gradient to use (between 0 and 1)
  57978. * @param min defines the alpha remap minimal range
  57979. * @param max defines the alpha remap maximal range
  57980. * @returns the current particle system
  57981. */
  57982. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57983. /**
  57984. * Not supported by GPUParticleSystem
  57985. * @param gradient defines the gradient to remove
  57986. * @returns the current particle system
  57987. */
  57988. removeAlphaRemapGradient(): IParticleSystem;
  57989. /**
  57990. * Not supported by GPUParticleSystem
  57991. * @param gradient defines the gradient to use (between 0 and 1)
  57992. * @param color defines the color to affect to the specified gradient
  57993. * @returns the current particle system
  57994. */
  57995. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57996. /**
  57997. * Not supported by GPUParticleSystem
  57998. * @param gradient defines the gradient to remove
  57999. * @returns the current particle system
  58000. */
  58001. removeRampGradient(): IParticleSystem;
  58002. /**
  58003. * Not supported by GPUParticleSystem
  58004. * @returns the list of ramp gradients
  58005. */
  58006. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58007. /**
  58008. * Not supported by GPUParticleSystem
  58009. * Gets or sets a boolean indicating that ramp gradients must be used
  58010. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58011. */
  58012. useRampGradients: boolean;
  58013. /**
  58014. * Not supported by GPUParticleSystem
  58015. * @param gradient defines the gradient to use (between 0 and 1)
  58016. * @param factor defines the life time factor to affect to the specified gradient
  58017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58018. * @returns the current particle system
  58019. */
  58020. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58021. /**
  58022. * Not supported by GPUParticleSystem
  58023. * @param gradient defines the gradient to remove
  58024. * @returns the current particle system
  58025. */
  58026. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58027. /**
  58028. * Instantiates a GPU particle system.
  58029. * 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.
  58030. * @param name The name of the particle system
  58031. * @param options The options used to create the system
  58032. * @param scene The scene the particle system belongs to
  58033. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58034. */
  58035. constructor(name: string, options: Partial<{
  58036. capacity: number;
  58037. randomTextureSize: number;
  58038. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58039. protected _reset(): void;
  58040. private _createUpdateVAO;
  58041. private _createRenderVAO;
  58042. private _initialize;
  58043. /** @hidden */
  58044. _recreateUpdateEffect(): void;
  58045. /** @hidden */
  58046. _recreateRenderEffect(): void;
  58047. /**
  58048. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58049. * @param preWarm defines if we are in the pre-warmimg phase
  58050. */
  58051. animate(preWarm?: boolean): void;
  58052. private _createFactorGradientTexture;
  58053. private _createSizeGradientTexture;
  58054. private _createAngularSpeedGradientTexture;
  58055. private _createVelocityGradientTexture;
  58056. private _createLimitVelocityGradientTexture;
  58057. private _createDragGradientTexture;
  58058. private _createColorGradientTexture;
  58059. /**
  58060. * Renders the particle system in its current state
  58061. * @param preWarm defines if the system should only update the particles but not render them
  58062. * @returns the current number of particles
  58063. */
  58064. render(preWarm?: boolean): number;
  58065. /**
  58066. * Rebuilds the particle system
  58067. */
  58068. rebuild(): void;
  58069. private _releaseBuffers;
  58070. private _releaseVAOs;
  58071. /**
  58072. * Disposes the particle system and free the associated resources
  58073. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58074. */
  58075. dispose(disposeTexture?: boolean): void;
  58076. /**
  58077. * Clones the particle system.
  58078. * @param name The name of the cloned object
  58079. * @param newEmitter The new emitter to use
  58080. * @returns the cloned particle system
  58081. */
  58082. clone(name: string, newEmitter: any): GPUParticleSystem;
  58083. /**
  58084. * Serializes the particle system to a JSON object.
  58085. * @returns the JSON object
  58086. */
  58087. serialize(): any;
  58088. /**
  58089. * Parses a JSON object to create a GPU particle system.
  58090. * @param parsedParticleSystem The JSON object to parse
  58091. * @param scene The scene to create the particle system in
  58092. * @param rootUrl The root url to use to load external dependencies like texture
  58093. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58094. * @returns the parsed GPU particle system
  58095. */
  58096. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58097. }
  58098. }
  58099. declare module "babylonjs/Particles/particleSystemSet" {
  58100. import { Nullable } from "babylonjs/types";
  58101. import { Color3 } from "babylonjs/Maths/math.color";
  58102. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58104. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58105. import { Scene, IDisposable } from "babylonjs/scene";
  58106. /**
  58107. * Represents a set of particle systems working together to create a specific effect
  58108. */
  58109. export class ParticleSystemSet implements IDisposable {
  58110. private _emitterCreationOptions;
  58111. private _emitterNode;
  58112. /**
  58113. * Gets the particle system list
  58114. */
  58115. systems: IParticleSystem[];
  58116. /**
  58117. * Gets the emitter node used with this set
  58118. */
  58119. readonly emitterNode: Nullable<TransformNode>;
  58120. /**
  58121. * Creates a new emitter mesh as a sphere
  58122. * @param options defines the options used to create the sphere
  58123. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58124. * @param scene defines the hosting scene
  58125. */
  58126. setEmitterAsSphere(options: {
  58127. diameter: number;
  58128. segments: number;
  58129. color: Color3;
  58130. }, renderingGroupId: number, scene: Scene): void;
  58131. /**
  58132. * Starts all particle systems of the set
  58133. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58134. */
  58135. start(emitter?: AbstractMesh): void;
  58136. /**
  58137. * Release all associated resources
  58138. */
  58139. dispose(): void;
  58140. /**
  58141. * Serialize the set into a JSON compatible object
  58142. * @returns a JSON compatible representation of the set
  58143. */
  58144. serialize(): any;
  58145. /**
  58146. * Parse a new ParticleSystemSet from a serialized source
  58147. * @param data defines a JSON compatible representation of the set
  58148. * @param scene defines the hosting scene
  58149. * @param gpu defines if we want GPU particles or CPU particles
  58150. * @returns a new ParticleSystemSet
  58151. */
  58152. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58153. }
  58154. }
  58155. declare module "babylonjs/Particles/particleHelper" {
  58156. import { Nullable } from "babylonjs/types";
  58157. import { Scene } from "babylonjs/scene";
  58158. import { Vector3 } from "babylonjs/Maths/math.vector";
  58159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58160. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58161. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58162. /**
  58163. * This class is made for on one-liner static method to help creating particle system set.
  58164. */
  58165. export class ParticleHelper {
  58166. /**
  58167. * Gets or sets base Assets URL
  58168. */
  58169. static BaseAssetsUrl: string;
  58170. /**
  58171. * Create a default particle system that you can tweak
  58172. * @param emitter defines the emitter to use
  58173. * @param capacity defines the system capacity (default is 500 particles)
  58174. * @param scene defines the hosting scene
  58175. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58176. * @returns the new Particle system
  58177. */
  58178. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58179. /**
  58180. * This is the main static method (one-liner) of this helper to create different particle systems
  58181. * @param type This string represents the type to the particle system to create
  58182. * @param scene The scene where the particle system should live
  58183. * @param gpu If the system will use gpu
  58184. * @returns the ParticleSystemSet created
  58185. */
  58186. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58187. /**
  58188. * Static function used to export a particle system to a ParticleSystemSet variable.
  58189. * Please note that the emitter shape is not exported
  58190. * @param systems defines the particle systems to export
  58191. * @returns the created particle system set
  58192. */
  58193. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58194. }
  58195. }
  58196. declare module "babylonjs/Particles/particleSystemComponent" {
  58197. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58198. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58199. import "babylonjs/Shaders/particles.vertex";
  58200. module "babylonjs/Engines/engine" {
  58201. interface Engine {
  58202. /**
  58203. * Create an effect to use with particle systems.
  58204. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58205. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58206. * @param uniformsNames defines a list of attribute names
  58207. * @param samplers defines an array of string used to represent textures
  58208. * @param defines defines the string containing the defines to use to compile the shaders
  58209. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58210. * @param onCompiled defines a function to call when the effect creation is successful
  58211. * @param onError defines a function to call when the effect creation has failed
  58212. * @returns the new Effect
  58213. */
  58214. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58215. }
  58216. }
  58217. module "babylonjs/Meshes/mesh" {
  58218. interface Mesh {
  58219. /**
  58220. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58221. * @returns an array of IParticleSystem
  58222. */
  58223. getEmittedParticleSystems(): IParticleSystem[];
  58224. /**
  58225. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58226. * @returns an array of IParticleSystem
  58227. */
  58228. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58229. }
  58230. }
  58231. /**
  58232. * @hidden
  58233. */
  58234. export var _IDoNeedToBeInTheBuild: number;
  58235. }
  58236. declare module "babylonjs/Particles/index" {
  58237. export * from "babylonjs/Particles/baseParticleSystem";
  58238. export * from "babylonjs/Particles/EmitterTypes/index";
  58239. export * from "babylonjs/Particles/gpuParticleSystem";
  58240. export * from "babylonjs/Particles/IParticleSystem";
  58241. export * from "babylonjs/Particles/particle";
  58242. export * from "babylonjs/Particles/particleHelper";
  58243. export * from "babylonjs/Particles/particleSystem";
  58244. export * from "babylonjs/Particles/particleSystemComponent";
  58245. export * from "babylonjs/Particles/particleSystemSet";
  58246. export * from "babylonjs/Particles/solidParticle";
  58247. export * from "babylonjs/Particles/solidParticleSystem";
  58248. export * from "babylonjs/Particles/subEmitter";
  58249. }
  58250. declare module "babylonjs/Physics/physicsEngineComponent" {
  58251. import { Nullable } from "babylonjs/types";
  58252. import { Observable, Observer } from "babylonjs/Misc/observable";
  58253. import { Vector3 } from "babylonjs/Maths/math.vector";
  58254. import { Mesh } from "babylonjs/Meshes/mesh";
  58255. import { ISceneComponent } from "babylonjs/sceneComponent";
  58256. import { Scene } from "babylonjs/scene";
  58257. import { Node } from "babylonjs/node";
  58258. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58259. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58260. module "babylonjs/scene" {
  58261. interface Scene {
  58262. /** @hidden (Backing field) */
  58263. _physicsEngine: Nullable<IPhysicsEngine>;
  58264. /**
  58265. * Gets the current physics engine
  58266. * @returns a IPhysicsEngine or null if none attached
  58267. */
  58268. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58269. /**
  58270. * Enables physics to the current scene
  58271. * @param gravity defines the scene's gravity for the physics engine
  58272. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58273. * @return a boolean indicating if the physics engine was initialized
  58274. */
  58275. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58276. /**
  58277. * Disables and disposes the physics engine associated with the scene
  58278. */
  58279. disablePhysicsEngine(): void;
  58280. /**
  58281. * Gets a boolean indicating if there is an active physics engine
  58282. * @returns a boolean indicating if there is an active physics engine
  58283. */
  58284. isPhysicsEnabled(): boolean;
  58285. /**
  58286. * Deletes a physics compound impostor
  58287. * @param compound defines the compound to delete
  58288. */
  58289. deleteCompoundImpostor(compound: any): void;
  58290. /**
  58291. * An event triggered when physic simulation is about to be run
  58292. */
  58293. onBeforePhysicsObservable: Observable<Scene>;
  58294. /**
  58295. * An event triggered when physic simulation has been done
  58296. */
  58297. onAfterPhysicsObservable: Observable<Scene>;
  58298. }
  58299. }
  58300. module "babylonjs/Meshes/abstractMesh" {
  58301. interface AbstractMesh {
  58302. /** @hidden */
  58303. _physicsImpostor: Nullable<PhysicsImpostor>;
  58304. /**
  58305. * Gets or sets impostor used for physic simulation
  58306. * @see http://doc.babylonjs.com/features/physics_engine
  58307. */
  58308. physicsImpostor: Nullable<PhysicsImpostor>;
  58309. /**
  58310. * Gets the current physics impostor
  58311. * @see http://doc.babylonjs.com/features/physics_engine
  58312. * @returns a physics impostor or null
  58313. */
  58314. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58315. /** Apply a physic impulse to the mesh
  58316. * @param force defines the force to apply
  58317. * @param contactPoint defines where to apply the force
  58318. * @returns the current mesh
  58319. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58320. */
  58321. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58322. /**
  58323. * Creates a physic joint between two meshes
  58324. * @param otherMesh defines the other mesh to use
  58325. * @param pivot1 defines the pivot to use on this mesh
  58326. * @param pivot2 defines the pivot to use on the other mesh
  58327. * @param options defines additional options (can be plugin dependent)
  58328. * @returns the current mesh
  58329. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58330. */
  58331. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58332. /** @hidden */
  58333. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58334. }
  58335. }
  58336. /**
  58337. * Defines the physics engine scene component responsible to manage a physics engine
  58338. */
  58339. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58340. /**
  58341. * The component name helpful to identify the component in the list of scene components.
  58342. */
  58343. readonly name: string;
  58344. /**
  58345. * The scene the component belongs to.
  58346. */
  58347. scene: Scene;
  58348. /**
  58349. * Creates a new instance of the component for the given scene
  58350. * @param scene Defines the scene to register the component in
  58351. */
  58352. constructor(scene: Scene);
  58353. /**
  58354. * Registers the component in a given scene
  58355. */
  58356. register(): void;
  58357. /**
  58358. * Rebuilds the elements related to this component in case of
  58359. * context lost for instance.
  58360. */
  58361. rebuild(): void;
  58362. /**
  58363. * Disposes the component and the associated ressources
  58364. */
  58365. dispose(): void;
  58366. }
  58367. }
  58368. declare module "babylonjs/Physics/physicsHelper" {
  58369. import { Nullable } from "babylonjs/types";
  58370. import { Vector3 } from "babylonjs/Maths/math.vector";
  58371. import { Mesh } from "babylonjs/Meshes/mesh";
  58372. import { Scene } from "babylonjs/scene";
  58373. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58374. /**
  58375. * A helper for physics simulations
  58376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58377. */
  58378. export class PhysicsHelper {
  58379. private _scene;
  58380. private _physicsEngine;
  58381. /**
  58382. * Initializes the Physics helper
  58383. * @param scene Babylon.js scene
  58384. */
  58385. constructor(scene: Scene);
  58386. /**
  58387. * Applies a radial explosion impulse
  58388. * @param origin the origin of the explosion
  58389. * @param radiusOrEventOptions the radius or the options of radial explosion
  58390. * @param strength the explosion strength
  58391. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58392. * @returns A physics radial explosion event, or null
  58393. */
  58394. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58395. /**
  58396. * Applies a radial explosion force
  58397. * @param origin the origin of the explosion
  58398. * @param radiusOrEventOptions the radius or the options of radial explosion
  58399. * @param strength the explosion strength
  58400. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58401. * @returns A physics radial explosion event, or null
  58402. */
  58403. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58404. /**
  58405. * Creates a gravitational field
  58406. * @param origin the origin of the explosion
  58407. * @param radiusOrEventOptions the radius or the options of radial explosion
  58408. * @param strength the explosion strength
  58409. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58410. * @returns A physics gravitational field event, or null
  58411. */
  58412. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58413. /**
  58414. * Creates a physics updraft event
  58415. * @param origin the origin of the updraft
  58416. * @param radiusOrEventOptions the radius or the options of the updraft
  58417. * @param strength the strength of the updraft
  58418. * @param height the height of the updraft
  58419. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58420. * @returns A physics updraft event, or null
  58421. */
  58422. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58423. /**
  58424. * Creates a physics vortex event
  58425. * @param origin the of the vortex
  58426. * @param radiusOrEventOptions the radius or the options of the vortex
  58427. * @param strength the strength of the vortex
  58428. * @param height the height of the vortex
  58429. * @returns a Physics vortex event, or null
  58430. * A physics vortex event or null
  58431. */
  58432. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58433. }
  58434. /**
  58435. * Represents a physics radial explosion event
  58436. */
  58437. class PhysicsRadialExplosionEvent {
  58438. private _scene;
  58439. private _options;
  58440. private _sphere;
  58441. private _dataFetched;
  58442. /**
  58443. * Initializes a radial explosioin event
  58444. * @param _scene BabylonJS scene
  58445. * @param _options The options for the vortex event
  58446. */
  58447. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58448. /**
  58449. * Returns the data related to the radial explosion event (sphere).
  58450. * @returns The radial explosion event data
  58451. */
  58452. getData(): PhysicsRadialExplosionEventData;
  58453. /**
  58454. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58455. * @param impostor A physics imposter
  58456. * @param origin the origin of the explosion
  58457. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58458. */
  58459. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58460. /**
  58461. * Triggers affecterd impostors callbacks
  58462. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58463. */
  58464. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58465. /**
  58466. * Disposes the sphere.
  58467. * @param force Specifies if the sphere should be disposed by force
  58468. */
  58469. dispose(force?: boolean): void;
  58470. /*** Helpers ***/
  58471. private _prepareSphere;
  58472. private _intersectsWithSphere;
  58473. }
  58474. /**
  58475. * Represents a gravitational field event
  58476. */
  58477. class PhysicsGravitationalFieldEvent {
  58478. private _physicsHelper;
  58479. private _scene;
  58480. private _origin;
  58481. private _options;
  58482. private _tickCallback;
  58483. private _sphere;
  58484. private _dataFetched;
  58485. /**
  58486. * Initializes the physics gravitational field event
  58487. * @param _physicsHelper A physics helper
  58488. * @param _scene BabylonJS scene
  58489. * @param _origin The origin position of the gravitational field event
  58490. * @param _options The options for the vortex event
  58491. */
  58492. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58493. /**
  58494. * Returns the data related to the gravitational field event (sphere).
  58495. * @returns A gravitational field event
  58496. */
  58497. getData(): PhysicsGravitationalFieldEventData;
  58498. /**
  58499. * Enables the gravitational field.
  58500. */
  58501. enable(): void;
  58502. /**
  58503. * Disables the gravitational field.
  58504. */
  58505. disable(): void;
  58506. /**
  58507. * Disposes the sphere.
  58508. * @param force The force to dispose from the gravitational field event
  58509. */
  58510. dispose(force?: boolean): void;
  58511. private _tick;
  58512. }
  58513. /**
  58514. * Represents a physics updraft event
  58515. */
  58516. class PhysicsUpdraftEvent {
  58517. private _scene;
  58518. private _origin;
  58519. private _options;
  58520. private _physicsEngine;
  58521. private _originTop;
  58522. private _originDirection;
  58523. private _tickCallback;
  58524. private _cylinder;
  58525. private _cylinderPosition;
  58526. private _dataFetched;
  58527. /**
  58528. * Initializes the physics updraft event
  58529. * @param _scene BabylonJS scene
  58530. * @param _origin The origin position of the updraft
  58531. * @param _options The options for the updraft event
  58532. */
  58533. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58534. /**
  58535. * Returns the data related to the updraft event (cylinder).
  58536. * @returns A physics updraft event
  58537. */
  58538. getData(): PhysicsUpdraftEventData;
  58539. /**
  58540. * Enables the updraft.
  58541. */
  58542. enable(): void;
  58543. /**
  58544. * Disables the updraft.
  58545. */
  58546. disable(): void;
  58547. /**
  58548. * Disposes the cylinder.
  58549. * @param force Specifies if the updraft should be disposed by force
  58550. */
  58551. dispose(force?: boolean): void;
  58552. private getImpostorHitData;
  58553. private _tick;
  58554. /*** Helpers ***/
  58555. private _prepareCylinder;
  58556. private _intersectsWithCylinder;
  58557. }
  58558. /**
  58559. * Represents a physics vortex event
  58560. */
  58561. class PhysicsVortexEvent {
  58562. private _scene;
  58563. private _origin;
  58564. private _options;
  58565. private _physicsEngine;
  58566. private _originTop;
  58567. private _tickCallback;
  58568. private _cylinder;
  58569. private _cylinderPosition;
  58570. private _dataFetched;
  58571. /**
  58572. * Initializes the physics vortex event
  58573. * @param _scene The BabylonJS scene
  58574. * @param _origin The origin position of the vortex
  58575. * @param _options The options for the vortex event
  58576. */
  58577. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58578. /**
  58579. * Returns the data related to the vortex event (cylinder).
  58580. * @returns The physics vortex event data
  58581. */
  58582. getData(): PhysicsVortexEventData;
  58583. /**
  58584. * Enables the vortex.
  58585. */
  58586. enable(): void;
  58587. /**
  58588. * Disables the cortex.
  58589. */
  58590. disable(): void;
  58591. /**
  58592. * Disposes the sphere.
  58593. * @param force
  58594. */
  58595. dispose(force?: boolean): void;
  58596. private getImpostorHitData;
  58597. private _tick;
  58598. /*** Helpers ***/
  58599. private _prepareCylinder;
  58600. private _intersectsWithCylinder;
  58601. }
  58602. /**
  58603. * Options fot the radial explosion event
  58604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58605. */
  58606. export class PhysicsRadialExplosionEventOptions {
  58607. /**
  58608. * The radius of the sphere for the radial explosion.
  58609. */
  58610. radius: number;
  58611. /**
  58612. * The strenth of the explosion.
  58613. */
  58614. strength: number;
  58615. /**
  58616. * The strenght of the force in correspondence to the distance of the affected object
  58617. */
  58618. falloff: PhysicsRadialImpulseFalloff;
  58619. /**
  58620. * Sphere options for the radial explosion.
  58621. */
  58622. sphere: {
  58623. segments: number;
  58624. diameter: number;
  58625. };
  58626. /**
  58627. * Sphere options for the radial explosion.
  58628. */
  58629. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58630. }
  58631. /**
  58632. * Options fot the updraft event
  58633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58634. */
  58635. export class PhysicsUpdraftEventOptions {
  58636. /**
  58637. * The radius of the cylinder for the vortex
  58638. */
  58639. radius: number;
  58640. /**
  58641. * The strenth of the updraft.
  58642. */
  58643. strength: number;
  58644. /**
  58645. * The height of the cylinder for the updraft.
  58646. */
  58647. height: number;
  58648. /**
  58649. * The mode for the the updraft.
  58650. */
  58651. updraftMode: PhysicsUpdraftMode;
  58652. }
  58653. /**
  58654. * Options fot the vortex event
  58655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58656. */
  58657. export class PhysicsVortexEventOptions {
  58658. /**
  58659. * The radius of the cylinder for the vortex
  58660. */
  58661. radius: number;
  58662. /**
  58663. * The strenth of the vortex.
  58664. */
  58665. strength: number;
  58666. /**
  58667. * The height of the cylinder for the vortex.
  58668. */
  58669. height: number;
  58670. /**
  58671. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58672. */
  58673. centripetalForceThreshold: number;
  58674. /**
  58675. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58676. */
  58677. centripetalForceMultiplier: number;
  58678. /**
  58679. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58680. */
  58681. centrifugalForceMultiplier: number;
  58682. /**
  58683. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58684. */
  58685. updraftForceMultiplier: number;
  58686. }
  58687. /**
  58688. * The strenght of the force in correspondence to the distance of the affected object
  58689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58690. */
  58691. export enum PhysicsRadialImpulseFalloff {
  58692. /** Defines that impulse is constant in strength across it's whole radius */
  58693. Constant = 0,
  58694. /** Defines that impulse gets weaker if it's further from the origin */
  58695. Linear = 1
  58696. }
  58697. /**
  58698. * The strength of the force in correspondence to the distance of the affected object
  58699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58700. */
  58701. export enum PhysicsUpdraftMode {
  58702. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58703. Center = 0,
  58704. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58705. Perpendicular = 1
  58706. }
  58707. /**
  58708. * Interface for a physics hit data
  58709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58710. */
  58711. export interface PhysicsHitData {
  58712. /**
  58713. * The force applied at the contact point
  58714. */
  58715. force: Vector3;
  58716. /**
  58717. * The contact point
  58718. */
  58719. contactPoint: Vector3;
  58720. /**
  58721. * The distance from the origin to the contact point
  58722. */
  58723. distanceFromOrigin: number;
  58724. }
  58725. /**
  58726. * Interface for radial explosion event data
  58727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58728. */
  58729. export interface PhysicsRadialExplosionEventData {
  58730. /**
  58731. * A sphere used for the radial explosion event
  58732. */
  58733. sphere: Mesh;
  58734. }
  58735. /**
  58736. * Interface for gravitational field event data
  58737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58738. */
  58739. export interface PhysicsGravitationalFieldEventData {
  58740. /**
  58741. * A sphere mesh used for the gravitational field event
  58742. */
  58743. sphere: Mesh;
  58744. }
  58745. /**
  58746. * Interface for updraft event data
  58747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58748. */
  58749. export interface PhysicsUpdraftEventData {
  58750. /**
  58751. * A cylinder used for the updraft event
  58752. */
  58753. cylinder: Mesh;
  58754. }
  58755. /**
  58756. * Interface for vortex event data
  58757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58758. */
  58759. export interface PhysicsVortexEventData {
  58760. /**
  58761. * A cylinder used for the vortex event
  58762. */
  58763. cylinder: Mesh;
  58764. }
  58765. /**
  58766. * Interface for an affected physics impostor
  58767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58768. */
  58769. export interface PhysicsAffectedImpostorWithData {
  58770. /**
  58771. * The impostor affected by the effect
  58772. */
  58773. impostor: PhysicsImpostor;
  58774. /**
  58775. * The data about the hit/horce from the explosion
  58776. */
  58777. hitData: PhysicsHitData;
  58778. }
  58779. }
  58780. declare module "babylonjs/Physics/Plugins/index" {
  58781. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  58782. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  58783. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  58784. }
  58785. declare module "babylonjs/Physics/index" {
  58786. export * from "babylonjs/Physics/IPhysicsEngine";
  58787. export * from "babylonjs/Physics/physicsEngine";
  58788. export * from "babylonjs/Physics/physicsEngineComponent";
  58789. export * from "babylonjs/Physics/physicsHelper";
  58790. export * from "babylonjs/Physics/physicsImpostor";
  58791. export * from "babylonjs/Physics/physicsJoint";
  58792. export * from "babylonjs/Physics/Plugins/index";
  58793. }
  58794. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  58795. /** @hidden */
  58796. export var blackAndWhitePixelShader: {
  58797. name: string;
  58798. shader: string;
  58799. };
  58800. }
  58801. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  58802. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58803. import { Camera } from "babylonjs/Cameras/camera";
  58804. import { Engine } from "babylonjs/Engines/engine";
  58805. import "babylonjs/Shaders/blackAndWhite.fragment";
  58806. /**
  58807. * Post process used to render in black and white
  58808. */
  58809. export class BlackAndWhitePostProcess extends PostProcess {
  58810. /**
  58811. * Linear about to convert he result to black and white (default: 1)
  58812. */
  58813. degree: number;
  58814. /**
  58815. * Creates a black and white post process
  58816. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58817. * @param name The name of the effect.
  58818. * @param options The required width/height ratio to downsize to before computing the render pass.
  58819. * @param camera The camera to apply the render pass to.
  58820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58821. * @param engine The engine which the post process will be applied. (default: current engine)
  58822. * @param reusable If the post process can be reused on the same frame. (default: false)
  58823. */
  58824. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58825. }
  58826. }
  58827. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  58828. import { Nullable } from "babylonjs/types";
  58829. import { Camera } from "babylonjs/Cameras/camera";
  58830. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58831. import { Engine } from "babylonjs/Engines/engine";
  58832. /**
  58833. * This represents a set of one or more post processes in Babylon.
  58834. * A post process can be used to apply a shader to a texture after it is rendered.
  58835. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58836. */
  58837. export class PostProcessRenderEffect {
  58838. private _postProcesses;
  58839. private _getPostProcesses;
  58840. private _singleInstance;
  58841. private _cameras;
  58842. private _indicesForCamera;
  58843. /**
  58844. * Name of the effect
  58845. * @hidden
  58846. */
  58847. _name: string;
  58848. /**
  58849. * Instantiates a post process render effect.
  58850. * A post process can be used to apply a shader to a texture after it is rendered.
  58851. * @param engine The engine the effect is tied to
  58852. * @param name The name of the effect
  58853. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58854. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58855. */
  58856. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58857. /**
  58858. * Checks if all the post processes in the effect are supported.
  58859. */
  58860. readonly isSupported: boolean;
  58861. /**
  58862. * Updates the current state of the effect
  58863. * @hidden
  58864. */
  58865. _update(): void;
  58866. /**
  58867. * Attaches the effect on cameras
  58868. * @param cameras The camera to attach to.
  58869. * @hidden
  58870. */
  58871. _attachCameras(cameras: Camera): void;
  58872. /**
  58873. * Attaches the effect on cameras
  58874. * @param cameras The camera to attach to.
  58875. * @hidden
  58876. */
  58877. _attachCameras(cameras: Camera[]): void;
  58878. /**
  58879. * Detaches the effect on cameras
  58880. * @param cameras The camera to detatch from.
  58881. * @hidden
  58882. */
  58883. _detachCameras(cameras: Camera): void;
  58884. /**
  58885. * Detatches the effect on cameras
  58886. * @param cameras The camera to detatch from.
  58887. * @hidden
  58888. */
  58889. _detachCameras(cameras: Camera[]): void;
  58890. /**
  58891. * Enables the effect on given cameras
  58892. * @param cameras The camera to enable.
  58893. * @hidden
  58894. */
  58895. _enable(cameras: Camera): void;
  58896. /**
  58897. * Enables the effect on given cameras
  58898. * @param cameras The camera to enable.
  58899. * @hidden
  58900. */
  58901. _enable(cameras: Nullable<Camera[]>): void;
  58902. /**
  58903. * Disables the effect on the given cameras
  58904. * @param cameras The camera to disable.
  58905. * @hidden
  58906. */
  58907. _disable(cameras: Camera): void;
  58908. /**
  58909. * Disables the effect on the given cameras
  58910. * @param cameras The camera to disable.
  58911. * @hidden
  58912. */
  58913. _disable(cameras: Nullable<Camera[]>): void;
  58914. /**
  58915. * Gets a list of the post processes contained in the effect.
  58916. * @param camera The camera to get the post processes on.
  58917. * @returns The list of the post processes in the effect.
  58918. */
  58919. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58920. }
  58921. }
  58922. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  58923. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58924. /** @hidden */
  58925. export var extractHighlightsPixelShader: {
  58926. name: string;
  58927. shader: string;
  58928. };
  58929. }
  58930. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  58931. import { Nullable } from "babylonjs/types";
  58932. import { Camera } from "babylonjs/Cameras/camera";
  58933. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58934. import { Engine } from "babylonjs/Engines/engine";
  58935. import "babylonjs/Shaders/extractHighlights.fragment";
  58936. /**
  58937. * 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.
  58938. */
  58939. export class ExtractHighlightsPostProcess extends PostProcess {
  58940. /**
  58941. * The luminance threshold, pixels below this value will be set to black.
  58942. */
  58943. threshold: number;
  58944. /** @hidden */
  58945. _exposure: number;
  58946. /**
  58947. * Post process which has the input texture to be used when performing highlight extraction
  58948. * @hidden
  58949. */
  58950. _inputPostProcess: Nullable<PostProcess>;
  58951. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58952. }
  58953. }
  58954. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  58955. /** @hidden */
  58956. export var bloomMergePixelShader: {
  58957. name: string;
  58958. shader: string;
  58959. };
  58960. }
  58961. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  58962. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58963. import { Nullable } from "babylonjs/types";
  58964. import { Engine } from "babylonjs/Engines/engine";
  58965. import { Camera } from "babylonjs/Cameras/camera";
  58966. import "babylonjs/Shaders/bloomMerge.fragment";
  58967. /**
  58968. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58969. */
  58970. export class BloomMergePostProcess extends PostProcess {
  58971. /** Weight of the bloom to be added to the original input. */
  58972. weight: number;
  58973. /**
  58974. * Creates a new instance of @see BloomMergePostProcess
  58975. * @param name The name of the effect.
  58976. * @param originalFromInput Post process which's input will be used for the merge.
  58977. * @param blurred Blurred highlights post process which's output will be used.
  58978. * @param weight Weight of the bloom to be added to the original input.
  58979. * @param options The required width/height ratio to downsize to before computing the render pass.
  58980. * @param camera The camera to apply the render pass to.
  58981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58982. * @param engine The engine which the post process will be applied. (default: current engine)
  58983. * @param reusable If the post process can be reused on the same frame. (default: false)
  58984. * @param textureType Type of textures used when performing the post process. (default: 0)
  58985. * @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)
  58986. */
  58987. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58988. /** Weight of the bloom to be added to the original input. */
  58989. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58990. }
  58991. }
  58992. declare module "babylonjs/PostProcesses/bloomEffect" {
  58993. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58994. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58995. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  58996. import { Camera } from "babylonjs/Cameras/camera";
  58997. import { Scene } from "babylonjs/scene";
  58998. /**
  58999. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59000. */
  59001. export class BloomEffect extends PostProcessRenderEffect {
  59002. private bloomScale;
  59003. /**
  59004. * @hidden Internal
  59005. */
  59006. _effects: Array<PostProcess>;
  59007. /**
  59008. * @hidden Internal
  59009. */
  59010. _downscale: ExtractHighlightsPostProcess;
  59011. private _blurX;
  59012. private _blurY;
  59013. private _merge;
  59014. /**
  59015. * The luminance threshold to find bright areas of the image to bloom.
  59016. */
  59017. threshold: number;
  59018. /**
  59019. * The strength of the bloom.
  59020. */
  59021. weight: number;
  59022. /**
  59023. * Specifies the size of the bloom blur kernel, relative to the final output size
  59024. */
  59025. kernel: number;
  59026. /**
  59027. * Creates a new instance of @see BloomEffect
  59028. * @param scene The scene the effect belongs to.
  59029. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59030. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59031. * @param bloomWeight The the strength of bloom.
  59032. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59033. * @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)
  59034. */
  59035. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59036. /**
  59037. * Disposes each of the internal effects for a given camera.
  59038. * @param camera The camera to dispose the effect on.
  59039. */
  59040. disposeEffects(camera: Camera): void;
  59041. /**
  59042. * @hidden Internal
  59043. */
  59044. _updateEffects(): void;
  59045. /**
  59046. * Internal
  59047. * @returns if all the contained post processes are ready.
  59048. * @hidden
  59049. */
  59050. _isReady(): boolean;
  59051. }
  59052. }
  59053. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59054. /** @hidden */
  59055. export var chromaticAberrationPixelShader: {
  59056. name: string;
  59057. shader: string;
  59058. };
  59059. }
  59060. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59061. import { Vector2 } from "babylonjs/Maths/math.vector";
  59062. import { Nullable } from "babylonjs/types";
  59063. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59064. import { Camera } from "babylonjs/Cameras/camera";
  59065. import { Engine } from "babylonjs/Engines/engine";
  59066. import "babylonjs/Shaders/chromaticAberration.fragment";
  59067. /**
  59068. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59069. */
  59070. export class ChromaticAberrationPostProcess extends PostProcess {
  59071. /**
  59072. * The amount of seperation of rgb channels (default: 30)
  59073. */
  59074. aberrationAmount: number;
  59075. /**
  59076. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59077. */
  59078. radialIntensity: number;
  59079. /**
  59080. * 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))
  59081. */
  59082. direction: Vector2;
  59083. /**
  59084. * 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))
  59085. */
  59086. centerPosition: Vector2;
  59087. /**
  59088. * Creates a new instance ChromaticAberrationPostProcess
  59089. * @param name The name of the effect.
  59090. * @param screenWidth The width of the screen to apply the effect on.
  59091. * @param screenHeight The height of the screen to apply the effect on.
  59092. * @param options The required width/height ratio to downsize to before computing the render pass.
  59093. * @param camera The camera to apply the render pass to.
  59094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59095. * @param engine The engine which the post process will be applied. (default: current engine)
  59096. * @param reusable If the post process can be reused on the same frame. (default: false)
  59097. * @param textureType Type of textures used when performing the post process. (default: 0)
  59098. * @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)
  59099. */
  59100. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59101. }
  59102. }
  59103. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59104. /** @hidden */
  59105. export var circleOfConfusionPixelShader: {
  59106. name: string;
  59107. shader: string;
  59108. };
  59109. }
  59110. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59111. import { Nullable } from "babylonjs/types";
  59112. import { Engine } from "babylonjs/Engines/engine";
  59113. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59114. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59115. import { Camera } from "babylonjs/Cameras/camera";
  59116. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59117. /**
  59118. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59119. */
  59120. export class CircleOfConfusionPostProcess extends PostProcess {
  59121. /**
  59122. * 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.
  59123. */
  59124. lensSize: number;
  59125. /**
  59126. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59127. */
  59128. fStop: number;
  59129. /**
  59130. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59131. */
  59132. focusDistance: number;
  59133. /**
  59134. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59135. */
  59136. focalLength: number;
  59137. private _depthTexture;
  59138. /**
  59139. * Creates a new instance CircleOfConfusionPostProcess
  59140. * @param name The name of the effect.
  59141. * @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.
  59142. * @param options The required width/height ratio to downsize to before computing the render pass.
  59143. * @param camera The camera to apply the render pass to.
  59144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59145. * @param engine The engine which the post process will be applied. (default: current engine)
  59146. * @param reusable If the post process can be reused on the same frame. (default: false)
  59147. * @param textureType Type of textures used when performing the post process. (default: 0)
  59148. * @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)
  59149. */
  59150. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59151. /**
  59152. * 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.
  59153. */
  59154. depthTexture: RenderTargetTexture;
  59155. }
  59156. }
  59157. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59158. /** @hidden */
  59159. export var colorCorrectionPixelShader: {
  59160. name: string;
  59161. shader: string;
  59162. };
  59163. }
  59164. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59166. import { Engine } from "babylonjs/Engines/engine";
  59167. import { Camera } from "babylonjs/Cameras/camera";
  59168. import "babylonjs/Shaders/colorCorrection.fragment";
  59169. /**
  59170. *
  59171. * This post-process allows the modification of rendered colors by using
  59172. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59173. *
  59174. * The object needs to be provided an url to a texture containing the color
  59175. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59176. * Use an image editing software to tweak the LUT to match your needs.
  59177. *
  59178. * For an example of a color LUT, see here:
  59179. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59180. * For explanations on color grading, see here:
  59181. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59182. *
  59183. */
  59184. export class ColorCorrectionPostProcess extends PostProcess {
  59185. private _colorTableTexture;
  59186. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59187. }
  59188. }
  59189. declare module "babylonjs/Shaders/convolution.fragment" {
  59190. /** @hidden */
  59191. export var convolutionPixelShader: {
  59192. name: string;
  59193. shader: string;
  59194. };
  59195. }
  59196. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59197. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59198. import { Nullable } from "babylonjs/types";
  59199. import { Camera } from "babylonjs/Cameras/camera";
  59200. import { Engine } from "babylonjs/Engines/engine";
  59201. import "babylonjs/Shaders/convolution.fragment";
  59202. /**
  59203. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59204. * input texture to perform effects such as edge detection or sharpening
  59205. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59206. */
  59207. export class ConvolutionPostProcess extends PostProcess {
  59208. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59209. kernel: number[];
  59210. /**
  59211. * Creates a new instance ConvolutionPostProcess
  59212. * @param name The name of the effect.
  59213. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59214. * @param options The required width/height ratio to downsize to before computing the render pass.
  59215. * @param camera The camera to apply the render pass to.
  59216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59217. * @param engine The engine which the post process will be applied. (default: current engine)
  59218. * @param reusable If the post process can be reused on the same frame. (default: false)
  59219. * @param textureType Type of textures used when performing the post process. (default: 0)
  59220. */
  59221. constructor(name: string,
  59222. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59223. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59224. /**
  59225. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59226. */
  59227. static EdgeDetect0Kernel: number[];
  59228. /**
  59229. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59230. */
  59231. static EdgeDetect1Kernel: number[];
  59232. /**
  59233. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59234. */
  59235. static EdgeDetect2Kernel: number[];
  59236. /**
  59237. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59238. */
  59239. static SharpenKernel: number[];
  59240. /**
  59241. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59242. */
  59243. static EmbossKernel: number[];
  59244. /**
  59245. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59246. */
  59247. static GaussianKernel: number[];
  59248. }
  59249. }
  59250. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  59251. import { Nullable } from "babylonjs/types";
  59252. import { Vector2 } from "babylonjs/Maths/math.vector";
  59253. import { Camera } from "babylonjs/Cameras/camera";
  59254. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59255. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59256. import { Engine } from "babylonjs/Engines/engine";
  59257. import { Scene } from "babylonjs/scene";
  59258. /**
  59259. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59260. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59261. * based on samples that have a large difference in distance than the center pixel.
  59262. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59263. */
  59264. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59265. direction: Vector2;
  59266. /**
  59267. * Creates a new instance CircleOfConfusionPostProcess
  59268. * @param name The name of the effect.
  59269. * @param scene The scene the effect belongs to.
  59270. * @param direction The direction the blur should be applied.
  59271. * @param kernel The size of the kernel used to blur.
  59272. * @param options The required width/height ratio to downsize to before computing the render pass.
  59273. * @param camera The camera to apply the render pass to.
  59274. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59275. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59277. * @param engine The engine which the post process will be applied. (default: current engine)
  59278. * @param reusable If the post process can be reused on the same frame. (default: false)
  59279. * @param textureType Type of textures used when performing the post process. (default: 0)
  59280. * @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)
  59281. */
  59282. 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);
  59283. }
  59284. }
  59285. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  59286. /** @hidden */
  59287. export var depthOfFieldMergePixelShader: {
  59288. name: string;
  59289. shader: string;
  59290. };
  59291. }
  59292. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  59293. import { Nullable } from "babylonjs/types";
  59294. import { Camera } from "babylonjs/Cameras/camera";
  59295. import { Effect } from "babylonjs/Materials/effect";
  59296. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59297. import { Engine } from "babylonjs/Engines/engine";
  59298. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  59299. /**
  59300. * Options to be set when merging outputs from the default pipeline.
  59301. */
  59302. export class DepthOfFieldMergePostProcessOptions {
  59303. /**
  59304. * The original image to merge on top of
  59305. */
  59306. originalFromInput: PostProcess;
  59307. /**
  59308. * Parameters to perform the merge of the depth of field effect
  59309. */
  59310. depthOfField?: {
  59311. circleOfConfusion: PostProcess;
  59312. blurSteps: Array<PostProcess>;
  59313. };
  59314. /**
  59315. * Parameters to perform the merge of bloom effect
  59316. */
  59317. bloom?: {
  59318. blurred: PostProcess;
  59319. weight: number;
  59320. };
  59321. }
  59322. /**
  59323. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59324. */
  59325. export class DepthOfFieldMergePostProcess extends PostProcess {
  59326. private blurSteps;
  59327. /**
  59328. * Creates a new instance of DepthOfFieldMergePostProcess
  59329. * @param name The name of the effect.
  59330. * @param originalFromInput Post process which's input will be used for the merge.
  59331. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59332. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59333. * @param options The required width/height ratio to downsize to before computing the render pass.
  59334. * @param camera The camera to apply the render pass to.
  59335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59336. * @param engine The engine which the post process will be applied. (default: current engine)
  59337. * @param reusable If the post process can be reused on the same frame. (default: false)
  59338. * @param textureType Type of textures used when performing the post process. (default: 0)
  59339. * @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)
  59340. */
  59341. 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);
  59342. /**
  59343. * Updates the effect with the current post process compile time values and recompiles the shader.
  59344. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59345. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59346. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59347. * @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
  59348. * @param onCompiled Called when the shader has been compiled.
  59349. * @param onError Called if there is an error when compiling a shader.
  59350. */
  59351. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59352. }
  59353. }
  59354. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  59355. import { Nullable } from "babylonjs/types";
  59356. import { Camera } from "babylonjs/Cameras/camera";
  59357. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59358. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59359. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59360. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59361. import { Scene } from "babylonjs/scene";
  59362. /**
  59363. * Specifies the level of max blur that should be applied when using the depth of field effect
  59364. */
  59365. export enum DepthOfFieldEffectBlurLevel {
  59366. /**
  59367. * Subtle blur
  59368. */
  59369. Low = 0,
  59370. /**
  59371. * Medium blur
  59372. */
  59373. Medium = 1,
  59374. /**
  59375. * Large blur
  59376. */
  59377. High = 2
  59378. }
  59379. /**
  59380. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59381. */
  59382. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59383. private _circleOfConfusion;
  59384. /**
  59385. * @hidden Internal, blurs from high to low
  59386. */
  59387. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59388. private _depthOfFieldBlurY;
  59389. private _dofMerge;
  59390. /**
  59391. * @hidden Internal post processes in depth of field effect
  59392. */
  59393. _effects: Array<PostProcess>;
  59394. /**
  59395. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59396. */
  59397. focalLength: number;
  59398. /**
  59399. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59400. */
  59401. fStop: number;
  59402. /**
  59403. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59404. */
  59405. focusDistance: number;
  59406. /**
  59407. * 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.
  59408. */
  59409. lensSize: number;
  59410. /**
  59411. * Creates a new instance DepthOfFieldEffect
  59412. * @param scene The scene the effect belongs to.
  59413. * @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.
  59414. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59415. * @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)
  59416. */
  59417. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59418. /**
  59419. * Get the current class name of the current effet
  59420. * @returns "DepthOfFieldEffect"
  59421. */
  59422. getClassName(): string;
  59423. /**
  59424. * 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.
  59425. */
  59426. depthTexture: RenderTargetTexture;
  59427. /**
  59428. * Disposes each of the internal effects for a given camera.
  59429. * @param camera The camera to dispose the effect on.
  59430. */
  59431. disposeEffects(camera: Camera): void;
  59432. /**
  59433. * @hidden Internal
  59434. */
  59435. _updateEffects(): void;
  59436. /**
  59437. * Internal
  59438. * @returns if all the contained post processes are ready.
  59439. * @hidden
  59440. */
  59441. _isReady(): boolean;
  59442. }
  59443. }
  59444. declare module "babylonjs/Shaders/displayPass.fragment" {
  59445. /** @hidden */
  59446. export var displayPassPixelShader: {
  59447. name: string;
  59448. shader: string;
  59449. };
  59450. }
  59451. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  59452. import { Nullable } from "babylonjs/types";
  59453. import { Camera } from "babylonjs/Cameras/camera";
  59454. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59455. import { Engine } from "babylonjs/Engines/engine";
  59456. import "babylonjs/Shaders/displayPass.fragment";
  59457. /**
  59458. * DisplayPassPostProcess which produces an output the same as it's input
  59459. */
  59460. export class DisplayPassPostProcess extends PostProcess {
  59461. /**
  59462. * Creates the DisplayPassPostProcess
  59463. * @param name The name of the effect.
  59464. * @param options The required width/height ratio to downsize to before computing the render pass.
  59465. * @param camera The camera to apply the render pass to.
  59466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59467. * @param engine The engine which the post process will be applied. (default: current engine)
  59468. * @param reusable If the post process can be reused on the same frame. (default: false)
  59469. */
  59470. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59471. }
  59472. }
  59473. declare module "babylonjs/Shaders/filter.fragment" {
  59474. /** @hidden */
  59475. export var filterPixelShader: {
  59476. name: string;
  59477. shader: string;
  59478. };
  59479. }
  59480. declare module "babylonjs/PostProcesses/filterPostProcess" {
  59481. import { Nullable } from "babylonjs/types";
  59482. import { Matrix } from "babylonjs/Maths/math.vector";
  59483. import { Camera } from "babylonjs/Cameras/camera";
  59484. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59485. import { Engine } from "babylonjs/Engines/engine";
  59486. import "babylonjs/Shaders/filter.fragment";
  59487. /**
  59488. * Applies a kernel filter to the image
  59489. */
  59490. export class FilterPostProcess extends PostProcess {
  59491. /** The matrix to be applied to the image */
  59492. kernelMatrix: Matrix;
  59493. /**
  59494. *
  59495. * @param name The name of the effect.
  59496. * @param kernelMatrix The matrix to be applied to the image
  59497. * @param options The required width/height ratio to downsize to before computing the render pass.
  59498. * @param camera The camera to apply the render pass to.
  59499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59500. * @param engine The engine which the post process will be applied. (default: current engine)
  59501. * @param reusable If the post process can be reused on the same frame. (default: false)
  59502. */
  59503. constructor(name: string,
  59504. /** The matrix to be applied to the image */
  59505. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59506. }
  59507. }
  59508. declare module "babylonjs/Shaders/fxaa.fragment" {
  59509. /** @hidden */
  59510. export var fxaaPixelShader: {
  59511. name: string;
  59512. shader: string;
  59513. };
  59514. }
  59515. declare module "babylonjs/Shaders/fxaa.vertex" {
  59516. /** @hidden */
  59517. export var fxaaVertexShader: {
  59518. name: string;
  59519. shader: string;
  59520. };
  59521. }
  59522. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  59523. import { Nullable } from "babylonjs/types";
  59524. import { Camera } from "babylonjs/Cameras/camera";
  59525. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59526. import { Engine } from "babylonjs/Engines/engine";
  59527. import "babylonjs/Shaders/fxaa.fragment";
  59528. import "babylonjs/Shaders/fxaa.vertex";
  59529. /**
  59530. * Fxaa post process
  59531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59532. */
  59533. export class FxaaPostProcess extends PostProcess {
  59534. /** @hidden */
  59535. texelWidth: number;
  59536. /** @hidden */
  59537. texelHeight: number;
  59538. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59539. private _getDefines;
  59540. }
  59541. }
  59542. declare module "babylonjs/Shaders/grain.fragment" {
  59543. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59544. /** @hidden */
  59545. export var grainPixelShader: {
  59546. name: string;
  59547. shader: string;
  59548. };
  59549. }
  59550. declare module "babylonjs/PostProcesses/grainPostProcess" {
  59551. import { Nullable } from "babylonjs/types";
  59552. import { Camera } from "babylonjs/Cameras/camera";
  59553. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59554. import { Engine } from "babylonjs/Engines/engine";
  59555. import "babylonjs/Shaders/grain.fragment";
  59556. /**
  59557. * The GrainPostProcess adds noise to the image at mid luminance levels
  59558. */
  59559. export class GrainPostProcess extends PostProcess {
  59560. /**
  59561. * The intensity of the grain added (default: 30)
  59562. */
  59563. intensity: number;
  59564. /**
  59565. * If the grain should be randomized on every frame
  59566. */
  59567. animated: boolean;
  59568. /**
  59569. * Creates a new instance of @see GrainPostProcess
  59570. * @param name The name of the effect.
  59571. * @param options The required width/height ratio to downsize to before computing the render pass.
  59572. * @param camera The camera to apply the render pass to.
  59573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59574. * @param engine The engine which the post process will be applied. (default: current engine)
  59575. * @param reusable If the post process can be reused on the same frame. (default: false)
  59576. * @param textureType Type of textures used when performing the post process. (default: 0)
  59577. * @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)
  59578. */
  59579. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59580. }
  59581. }
  59582. declare module "babylonjs/Shaders/highlights.fragment" {
  59583. /** @hidden */
  59584. export var highlightsPixelShader: {
  59585. name: string;
  59586. shader: string;
  59587. };
  59588. }
  59589. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  59590. import { Nullable } from "babylonjs/types";
  59591. import { Camera } from "babylonjs/Cameras/camera";
  59592. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59593. import { Engine } from "babylonjs/Engines/engine";
  59594. import "babylonjs/Shaders/highlights.fragment";
  59595. /**
  59596. * Extracts highlights from the image
  59597. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59598. */
  59599. export class HighlightsPostProcess extends PostProcess {
  59600. /**
  59601. * Extracts highlights from the image
  59602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59603. * @param name The name of the effect.
  59604. * @param options The required width/height ratio to downsize to before computing the render pass.
  59605. * @param camera The camera to apply the render pass to.
  59606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59607. * @param engine The engine which the post process will be applied. (default: current engine)
  59608. * @param reusable If the post process can be reused on the same frame. (default: false)
  59609. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59610. */
  59611. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59612. }
  59613. }
  59614. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  59615. /** @hidden */
  59616. export var mrtFragmentDeclaration: {
  59617. name: string;
  59618. shader: string;
  59619. };
  59620. }
  59621. declare module "babylonjs/Shaders/geometry.fragment" {
  59622. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  59623. /** @hidden */
  59624. export var geometryPixelShader: {
  59625. name: string;
  59626. shader: string;
  59627. };
  59628. }
  59629. declare module "babylonjs/Shaders/geometry.vertex" {
  59630. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59632. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59633. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59634. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59635. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59636. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59637. /** @hidden */
  59638. export var geometryVertexShader: {
  59639. name: string;
  59640. shader: string;
  59641. };
  59642. }
  59643. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  59644. import { Matrix } from "babylonjs/Maths/math.vector";
  59645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59646. import { Mesh } from "babylonjs/Meshes/mesh";
  59647. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  59648. import { Effect } from "babylonjs/Materials/effect";
  59649. import { Scene } from "babylonjs/scene";
  59650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59651. import "babylonjs/Shaders/geometry.fragment";
  59652. import "babylonjs/Shaders/geometry.vertex";
  59653. /** @hidden */
  59654. interface ISavedTransformationMatrix {
  59655. world: Matrix;
  59656. viewProjection: Matrix;
  59657. }
  59658. /**
  59659. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59660. */
  59661. export class GeometryBufferRenderer {
  59662. /**
  59663. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59664. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59665. */
  59666. static readonly POSITION_TEXTURE_TYPE: number;
  59667. /**
  59668. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59669. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59670. */
  59671. static readonly VELOCITY_TEXTURE_TYPE: number;
  59672. /**
  59673. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59674. * in order to compute objects velocities when enableVelocity is set to "true"
  59675. * @hidden
  59676. */
  59677. _previousTransformationMatrices: {
  59678. [index: number]: ISavedTransformationMatrix;
  59679. };
  59680. /**
  59681. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59682. * in order to compute objects velocities when enableVelocity is set to "true"
  59683. * @hidden
  59684. */
  59685. _previousBonesTransformationMatrices: {
  59686. [index: number]: Float32Array;
  59687. };
  59688. /**
  59689. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59690. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59691. */
  59692. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59693. private _scene;
  59694. private _multiRenderTarget;
  59695. private _ratio;
  59696. private _enablePosition;
  59697. private _enableVelocity;
  59698. private _positionIndex;
  59699. private _velocityIndex;
  59700. protected _effect: Effect;
  59701. protected _cachedDefines: string;
  59702. /**
  59703. * Set the render list (meshes to be rendered) used in the G buffer.
  59704. */
  59705. renderList: Mesh[];
  59706. /**
  59707. * Gets wether or not G buffer are supported by the running hardware.
  59708. * This requires draw buffer supports
  59709. */
  59710. readonly isSupported: boolean;
  59711. /**
  59712. * Returns the index of the given texture type in the G-Buffer textures array
  59713. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59714. * @returns the index of the given texture type in the G-Buffer textures array
  59715. */
  59716. getTextureIndex(textureType: number): number;
  59717. /**
  59718. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59719. */
  59720. /**
  59721. * Sets whether or not objects positions are enabled for the G buffer.
  59722. */
  59723. enablePosition: boolean;
  59724. /**
  59725. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59726. */
  59727. /**
  59728. * Sets wether or not objects velocities are enabled for the G buffer.
  59729. */
  59730. enableVelocity: boolean;
  59731. /**
  59732. * Gets the scene associated with the buffer.
  59733. */
  59734. readonly scene: Scene;
  59735. /**
  59736. * Gets the ratio used by the buffer during its creation.
  59737. * How big is the buffer related to the main canvas.
  59738. */
  59739. readonly ratio: number;
  59740. /** @hidden */
  59741. static _SceneComponentInitialization: (scene: Scene) => void;
  59742. /**
  59743. * Creates a new G Buffer for the scene
  59744. * @param scene The scene the buffer belongs to
  59745. * @param ratio How big is the buffer related to the main canvas.
  59746. */
  59747. constructor(scene: Scene, ratio?: number);
  59748. /**
  59749. * Checks wether everything is ready to render a submesh to the G buffer.
  59750. * @param subMesh the submesh to check readiness for
  59751. * @param useInstances is the mesh drawn using instance or not
  59752. * @returns true if ready otherwise false
  59753. */
  59754. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59755. /**
  59756. * Gets the current underlying G Buffer.
  59757. * @returns the buffer
  59758. */
  59759. getGBuffer(): MultiRenderTarget;
  59760. /**
  59761. * Gets the number of samples used to render the buffer (anti aliasing).
  59762. */
  59763. /**
  59764. * Sets the number of samples used to render the buffer (anti aliasing).
  59765. */
  59766. samples: number;
  59767. /**
  59768. * Disposes the renderer and frees up associated resources.
  59769. */
  59770. dispose(): void;
  59771. protected _createRenderTargets(): void;
  59772. private _copyBonesTransformationMatrices;
  59773. }
  59774. }
  59775. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  59776. import { Nullable } from "babylonjs/types";
  59777. import { Scene } from "babylonjs/scene";
  59778. import { ISceneComponent } from "babylonjs/sceneComponent";
  59779. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  59780. module "babylonjs/scene" {
  59781. interface Scene {
  59782. /** @hidden (Backing field) */
  59783. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59784. /**
  59785. * Gets or Sets the current geometry buffer associated to the scene.
  59786. */
  59787. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59788. /**
  59789. * Enables a GeometryBufferRender and associates it with the scene
  59790. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59791. * @returns the GeometryBufferRenderer
  59792. */
  59793. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59794. /**
  59795. * Disables the GeometryBufferRender associated with the scene
  59796. */
  59797. disableGeometryBufferRenderer(): void;
  59798. }
  59799. }
  59800. /**
  59801. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59802. * in several rendering techniques.
  59803. */
  59804. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59805. /**
  59806. * The component name helpful to identify the component in the list of scene components.
  59807. */
  59808. readonly name: string;
  59809. /**
  59810. * The scene the component belongs to.
  59811. */
  59812. scene: Scene;
  59813. /**
  59814. * Creates a new instance of the component for the given scene
  59815. * @param scene Defines the scene to register the component in
  59816. */
  59817. constructor(scene: Scene);
  59818. /**
  59819. * Registers the component in a given scene
  59820. */
  59821. register(): void;
  59822. /**
  59823. * Rebuilds the elements related to this component in case of
  59824. * context lost for instance.
  59825. */
  59826. rebuild(): void;
  59827. /**
  59828. * Disposes the component and the associated ressources
  59829. */
  59830. dispose(): void;
  59831. private _gatherRenderTargets;
  59832. }
  59833. }
  59834. declare module "babylonjs/Shaders/motionBlur.fragment" {
  59835. /** @hidden */
  59836. export var motionBlurPixelShader: {
  59837. name: string;
  59838. shader: string;
  59839. };
  59840. }
  59841. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  59842. import { Nullable } from "babylonjs/types";
  59843. import { Camera } from "babylonjs/Cameras/camera";
  59844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59845. import { Scene } from "babylonjs/scene";
  59846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59847. import "babylonjs/Animations/animatable";
  59848. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  59849. import "babylonjs/Shaders/motionBlur.fragment";
  59850. import { Engine } from "babylonjs/Engines/engine";
  59851. /**
  59852. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59853. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59854. * As an example, all you have to do is to create the post-process:
  59855. * var mb = new BABYLON.MotionBlurPostProcess(
  59856. * 'mb', // The name of the effect.
  59857. * scene, // The scene containing the objects to blur according to their velocity.
  59858. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59859. * camera // The camera to apply the render pass to.
  59860. * );
  59861. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59862. */
  59863. export class MotionBlurPostProcess extends PostProcess {
  59864. /**
  59865. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59866. */
  59867. motionStrength: number;
  59868. /**
  59869. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59870. */
  59871. /**
  59872. * Sets the number of iterations to be used for motion blur quality
  59873. */
  59874. motionBlurSamples: number;
  59875. private _motionBlurSamples;
  59876. private _geometryBufferRenderer;
  59877. /**
  59878. * Creates a new instance MotionBlurPostProcess
  59879. * @param name The name of the effect.
  59880. * @param scene The scene containing the objects to blur according to their velocity.
  59881. * @param options The required width/height ratio to downsize to before computing the render pass.
  59882. * @param camera The camera to apply the render pass to.
  59883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59884. * @param engine The engine which the post process will be applied. (default: current engine)
  59885. * @param reusable If the post process can be reused on the same frame. (default: false)
  59886. * @param textureType Type of textures used when performing the post process. (default: 0)
  59887. * @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)
  59888. */
  59889. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59890. /**
  59891. * Excludes the given skinned mesh from computing bones velocities.
  59892. * 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.
  59893. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59894. */
  59895. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59896. /**
  59897. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59898. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59899. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59900. */
  59901. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59902. /**
  59903. * Disposes the post process.
  59904. * @param camera The camera to dispose the post process on.
  59905. */
  59906. dispose(camera?: Camera): void;
  59907. }
  59908. }
  59909. declare module "babylonjs/Shaders/refraction.fragment" {
  59910. /** @hidden */
  59911. export var refractionPixelShader: {
  59912. name: string;
  59913. shader: string;
  59914. };
  59915. }
  59916. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  59917. import { Color3 } from "babylonjs/Maths/math.color";
  59918. import { Camera } from "babylonjs/Cameras/camera";
  59919. import { Texture } from "babylonjs/Materials/Textures/texture";
  59920. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59921. import { Engine } from "babylonjs/Engines/engine";
  59922. import "babylonjs/Shaders/refraction.fragment";
  59923. /**
  59924. * Post process which applies a refractin texture
  59925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59926. */
  59927. export class RefractionPostProcess extends PostProcess {
  59928. /** the base color of the refraction (used to taint the rendering) */
  59929. color: Color3;
  59930. /** simulated refraction depth */
  59931. depth: number;
  59932. /** the coefficient of the base color (0 to remove base color tainting) */
  59933. colorLevel: number;
  59934. private _refTexture;
  59935. private _ownRefractionTexture;
  59936. /**
  59937. * Gets or sets the refraction texture
  59938. * Please note that you are responsible for disposing the texture if you set it manually
  59939. */
  59940. refractionTexture: Texture;
  59941. /**
  59942. * Initializes the RefractionPostProcess
  59943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59944. * @param name The name of the effect.
  59945. * @param refractionTextureUrl Url of the refraction texture to use
  59946. * @param color the base color of the refraction (used to taint the rendering)
  59947. * @param depth simulated refraction depth
  59948. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59949. * @param camera The camera to apply the render pass to.
  59950. * @param options The required width/height ratio to downsize to before computing the render pass.
  59951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59952. * @param engine The engine which the post process will be applied. (default: current engine)
  59953. * @param reusable If the post process can be reused on the same frame. (default: false)
  59954. */
  59955. constructor(name: string, refractionTextureUrl: string,
  59956. /** the base color of the refraction (used to taint the rendering) */
  59957. color: Color3,
  59958. /** simulated refraction depth */
  59959. depth: number,
  59960. /** the coefficient of the base color (0 to remove base color tainting) */
  59961. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59962. /**
  59963. * Disposes of the post process
  59964. * @param camera Camera to dispose post process on
  59965. */
  59966. dispose(camera: Camera): void;
  59967. }
  59968. }
  59969. declare module "babylonjs/Shaders/sharpen.fragment" {
  59970. /** @hidden */
  59971. export var sharpenPixelShader: {
  59972. name: string;
  59973. shader: string;
  59974. };
  59975. }
  59976. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  59977. import { Nullable } from "babylonjs/types";
  59978. import { Camera } from "babylonjs/Cameras/camera";
  59979. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59980. import "babylonjs/Shaders/sharpen.fragment";
  59981. import { Engine } from "babylonjs/Engines/engine";
  59982. /**
  59983. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59984. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59985. */
  59986. export class SharpenPostProcess extends PostProcess {
  59987. /**
  59988. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59989. */
  59990. colorAmount: number;
  59991. /**
  59992. * How much sharpness should be applied (default: 0.3)
  59993. */
  59994. edgeAmount: number;
  59995. /**
  59996. * Creates a new instance ConvolutionPostProcess
  59997. * @param name The name of the effect.
  59998. * @param options The required width/height ratio to downsize to before computing the render pass.
  59999. * @param camera The camera to apply the render pass to.
  60000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60001. * @param engine The engine which the post process will be applied. (default: current engine)
  60002. * @param reusable If the post process can be reused on the same frame. (default: false)
  60003. * @param textureType Type of textures used when performing the post process. (default: 0)
  60004. * @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)
  60005. */
  60006. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60007. }
  60008. }
  60009. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60010. import { Nullable } from "babylonjs/types";
  60011. import { Camera } from "babylonjs/Cameras/camera";
  60012. import { Engine } from "babylonjs/Engines/engine";
  60013. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60014. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60015. /**
  60016. * PostProcessRenderPipeline
  60017. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60018. */
  60019. export class PostProcessRenderPipeline {
  60020. private engine;
  60021. private _renderEffects;
  60022. private _renderEffectsForIsolatedPass;
  60023. /**
  60024. * List of inspectable custom properties (used by the Inspector)
  60025. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60026. */
  60027. inspectableCustomProperties: IInspectable[];
  60028. /**
  60029. * @hidden
  60030. */
  60031. protected _cameras: Camera[];
  60032. /** @hidden */
  60033. _name: string;
  60034. /**
  60035. * Gets pipeline name
  60036. */
  60037. readonly name: string;
  60038. /**
  60039. * Initializes a PostProcessRenderPipeline
  60040. * @param engine engine to add the pipeline to
  60041. * @param name name of the pipeline
  60042. */
  60043. constructor(engine: Engine, name: string);
  60044. /**
  60045. * Gets the class name
  60046. * @returns "PostProcessRenderPipeline"
  60047. */
  60048. getClassName(): string;
  60049. /**
  60050. * If all the render effects in the pipeline are supported
  60051. */
  60052. readonly isSupported: boolean;
  60053. /**
  60054. * Adds an effect to the pipeline
  60055. * @param renderEffect the effect to add
  60056. */
  60057. addEffect(renderEffect: PostProcessRenderEffect): void;
  60058. /** @hidden */
  60059. _rebuild(): void;
  60060. /** @hidden */
  60061. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60062. /** @hidden */
  60063. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60064. /** @hidden */
  60065. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60066. /** @hidden */
  60067. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60068. /** @hidden */
  60069. _attachCameras(cameras: Camera, unique: boolean): void;
  60070. /** @hidden */
  60071. _attachCameras(cameras: Camera[], unique: boolean): void;
  60072. /** @hidden */
  60073. _detachCameras(cameras: Camera): void;
  60074. /** @hidden */
  60075. _detachCameras(cameras: Nullable<Camera[]>): void;
  60076. /** @hidden */
  60077. _update(): void;
  60078. /** @hidden */
  60079. _reset(): void;
  60080. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60081. /**
  60082. * Disposes of the pipeline
  60083. */
  60084. dispose(): void;
  60085. }
  60086. }
  60087. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60088. import { Camera } from "babylonjs/Cameras/camera";
  60089. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60090. /**
  60091. * PostProcessRenderPipelineManager class
  60092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60093. */
  60094. export class PostProcessRenderPipelineManager {
  60095. private _renderPipelines;
  60096. /**
  60097. * Initializes a PostProcessRenderPipelineManager
  60098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60099. */
  60100. constructor();
  60101. /**
  60102. * Gets the list of supported render pipelines
  60103. */
  60104. readonly supportedPipelines: PostProcessRenderPipeline[];
  60105. /**
  60106. * Adds a pipeline to the manager
  60107. * @param renderPipeline The pipeline to add
  60108. */
  60109. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60110. /**
  60111. * Attaches a camera to the pipeline
  60112. * @param renderPipelineName The name of the pipeline to attach to
  60113. * @param cameras the camera to attach
  60114. * @param unique if the camera can be attached multiple times to the pipeline
  60115. */
  60116. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60117. /**
  60118. * Detaches a camera from the pipeline
  60119. * @param renderPipelineName The name of the pipeline to detach from
  60120. * @param cameras the camera to detach
  60121. */
  60122. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60123. /**
  60124. * Enables an effect by name on a pipeline
  60125. * @param renderPipelineName the name of the pipeline to enable the effect in
  60126. * @param renderEffectName the name of the effect to enable
  60127. * @param cameras the cameras that the effect should be enabled on
  60128. */
  60129. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60130. /**
  60131. * Disables an effect by name on a pipeline
  60132. * @param renderPipelineName the name of the pipeline to disable the effect in
  60133. * @param renderEffectName the name of the effect to disable
  60134. * @param cameras the cameras that the effect should be disabled on
  60135. */
  60136. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60137. /**
  60138. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60139. */
  60140. update(): void;
  60141. /** @hidden */
  60142. _rebuild(): void;
  60143. /**
  60144. * Disposes of the manager and pipelines
  60145. */
  60146. dispose(): void;
  60147. }
  60148. }
  60149. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60150. import { ISceneComponent } from "babylonjs/sceneComponent";
  60151. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60152. import { Scene } from "babylonjs/scene";
  60153. module "babylonjs/scene" {
  60154. interface Scene {
  60155. /** @hidden (Backing field) */
  60156. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60157. /**
  60158. * Gets the postprocess render pipeline manager
  60159. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60160. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60161. */
  60162. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60163. }
  60164. }
  60165. /**
  60166. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60167. */
  60168. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60169. /**
  60170. * The component name helpfull to identify the component in the list of scene components.
  60171. */
  60172. readonly name: string;
  60173. /**
  60174. * The scene the component belongs to.
  60175. */
  60176. scene: Scene;
  60177. /**
  60178. * Creates a new instance of the component for the given scene
  60179. * @param scene Defines the scene to register the component in
  60180. */
  60181. constructor(scene: Scene);
  60182. /**
  60183. * Registers the component in a given scene
  60184. */
  60185. register(): void;
  60186. /**
  60187. * Rebuilds the elements related to this component in case of
  60188. * context lost for instance.
  60189. */
  60190. rebuild(): void;
  60191. /**
  60192. * Disposes the component and the associated ressources
  60193. */
  60194. dispose(): void;
  60195. private _gatherRenderTargets;
  60196. }
  60197. }
  60198. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60199. import { Nullable } from "babylonjs/types";
  60200. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60201. import { Camera } from "babylonjs/Cameras/camera";
  60202. import { IDisposable } from "babylonjs/scene";
  60203. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60204. import { Scene } from "babylonjs/scene";
  60205. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60206. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60207. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60208. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60209. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60210. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60211. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60212. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60213. import { Animation } from "babylonjs/Animations/animation";
  60214. /**
  60215. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60216. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60217. */
  60218. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60219. private _scene;
  60220. private _camerasToBeAttached;
  60221. /**
  60222. * ID of the sharpen post process,
  60223. */
  60224. private readonly SharpenPostProcessId;
  60225. /**
  60226. * @ignore
  60227. * ID of the image processing post process;
  60228. */
  60229. readonly ImageProcessingPostProcessId: string;
  60230. /**
  60231. * @ignore
  60232. * ID of the Fast Approximate Anti-Aliasing post process;
  60233. */
  60234. readonly FxaaPostProcessId: string;
  60235. /**
  60236. * ID of the chromatic aberration post process,
  60237. */
  60238. private readonly ChromaticAberrationPostProcessId;
  60239. /**
  60240. * ID of the grain post process
  60241. */
  60242. private readonly GrainPostProcessId;
  60243. /**
  60244. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60245. */
  60246. sharpen: SharpenPostProcess;
  60247. private _sharpenEffect;
  60248. private bloom;
  60249. /**
  60250. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60251. */
  60252. depthOfField: DepthOfFieldEffect;
  60253. /**
  60254. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60255. */
  60256. fxaa: FxaaPostProcess;
  60257. /**
  60258. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60259. */
  60260. imageProcessing: ImageProcessingPostProcess;
  60261. /**
  60262. * Chromatic aberration post process which will shift rgb colors in the image
  60263. */
  60264. chromaticAberration: ChromaticAberrationPostProcess;
  60265. private _chromaticAberrationEffect;
  60266. /**
  60267. * Grain post process which add noise to the image
  60268. */
  60269. grain: GrainPostProcess;
  60270. private _grainEffect;
  60271. /**
  60272. * Glow post process which adds a glow to emissive areas of the image
  60273. */
  60274. private _glowLayer;
  60275. /**
  60276. * Animations which can be used to tweak settings over a period of time
  60277. */
  60278. animations: Animation[];
  60279. private _imageProcessingConfigurationObserver;
  60280. private _sharpenEnabled;
  60281. private _bloomEnabled;
  60282. private _depthOfFieldEnabled;
  60283. private _depthOfFieldBlurLevel;
  60284. private _fxaaEnabled;
  60285. private _imageProcessingEnabled;
  60286. private _defaultPipelineTextureType;
  60287. private _bloomScale;
  60288. private _chromaticAberrationEnabled;
  60289. private _grainEnabled;
  60290. private _buildAllowed;
  60291. /**
  60292. * Gets active scene
  60293. */
  60294. readonly scene: Scene;
  60295. /**
  60296. * Enable or disable the sharpen process from the pipeline
  60297. */
  60298. sharpenEnabled: boolean;
  60299. private _resizeObserver;
  60300. private _hardwareScaleLevel;
  60301. private _bloomKernel;
  60302. /**
  60303. * Specifies the size of the bloom blur kernel, relative to the final output size
  60304. */
  60305. bloomKernel: number;
  60306. /**
  60307. * Specifies the weight of the bloom in the final rendering
  60308. */
  60309. private _bloomWeight;
  60310. /**
  60311. * Specifies the luma threshold for the area that will be blurred by the bloom
  60312. */
  60313. private _bloomThreshold;
  60314. private _hdr;
  60315. /**
  60316. * The strength of the bloom.
  60317. */
  60318. bloomWeight: number;
  60319. /**
  60320. * The strength of the bloom.
  60321. */
  60322. bloomThreshold: number;
  60323. /**
  60324. * The scale of the bloom, lower value will provide better performance.
  60325. */
  60326. bloomScale: number;
  60327. /**
  60328. * Enable or disable the bloom from the pipeline
  60329. */
  60330. bloomEnabled: boolean;
  60331. private _rebuildBloom;
  60332. /**
  60333. * If the depth of field is enabled.
  60334. */
  60335. depthOfFieldEnabled: boolean;
  60336. /**
  60337. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60338. */
  60339. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60340. /**
  60341. * If the anti aliasing is enabled.
  60342. */
  60343. fxaaEnabled: boolean;
  60344. private _samples;
  60345. /**
  60346. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60347. */
  60348. samples: number;
  60349. /**
  60350. * If image processing is enabled.
  60351. */
  60352. imageProcessingEnabled: boolean;
  60353. /**
  60354. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60355. */
  60356. glowLayerEnabled: boolean;
  60357. /**
  60358. * Gets the glow layer (or null if not defined)
  60359. */
  60360. readonly glowLayer: Nullable<GlowLayer>;
  60361. /**
  60362. * Enable or disable the chromaticAberration process from the pipeline
  60363. */
  60364. chromaticAberrationEnabled: boolean;
  60365. /**
  60366. * Enable or disable the grain process from the pipeline
  60367. */
  60368. grainEnabled: boolean;
  60369. /**
  60370. * @constructor
  60371. * @param name - The rendering pipeline name (default: "")
  60372. * @param hdr - If high dynamic range textures should be used (default: true)
  60373. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60374. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60375. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60376. */
  60377. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60378. /**
  60379. * Get the class name
  60380. * @returns "DefaultRenderingPipeline"
  60381. */
  60382. getClassName(): string;
  60383. /**
  60384. * Force the compilation of the entire pipeline.
  60385. */
  60386. prepare(): void;
  60387. private _hasCleared;
  60388. private _prevPostProcess;
  60389. private _prevPrevPostProcess;
  60390. private _setAutoClearAndTextureSharing;
  60391. private _depthOfFieldSceneObserver;
  60392. private _buildPipeline;
  60393. private _disposePostProcesses;
  60394. /**
  60395. * Adds a camera to the pipeline
  60396. * @param camera the camera to be added
  60397. */
  60398. addCamera(camera: Camera): void;
  60399. /**
  60400. * Removes a camera from the pipeline
  60401. * @param camera the camera to remove
  60402. */
  60403. removeCamera(camera: Camera): void;
  60404. /**
  60405. * Dispose of the pipeline and stop all post processes
  60406. */
  60407. dispose(): void;
  60408. /**
  60409. * Serialize the rendering pipeline (Used when exporting)
  60410. * @returns the serialized object
  60411. */
  60412. serialize(): any;
  60413. /**
  60414. * Parse the serialized pipeline
  60415. * @param source Source pipeline.
  60416. * @param scene The scene to load the pipeline to.
  60417. * @param rootUrl The URL of the serialized pipeline.
  60418. * @returns An instantiated pipeline from the serialized object.
  60419. */
  60420. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60421. }
  60422. }
  60423. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  60424. /** @hidden */
  60425. export var lensHighlightsPixelShader: {
  60426. name: string;
  60427. shader: string;
  60428. };
  60429. }
  60430. declare module "babylonjs/Shaders/depthOfField.fragment" {
  60431. /** @hidden */
  60432. export var depthOfFieldPixelShader: {
  60433. name: string;
  60434. shader: string;
  60435. };
  60436. }
  60437. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  60438. import { Camera } from "babylonjs/Cameras/camera";
  60439. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60440. import { Scene } from "babylonjs/scene";
  60441. import "babylonjs/Shaders/chromaticAberration.fragment";
  60442. import "babylonjs/Shaders/lensHighlights.fragment";
  60443. import "babylonjs/Shaders/depthOfField.fragment";
  60444. /**
  60445. * BABYLON.JS Chromatic Aberration GLSL Shader
  60446. * Author: Olivier Guyot
  60447. * Separates very slightly R, G and B colors on the edges of the screen
  60448. * Inspired by Francois Tarlier & Martins Upitis
  60449. */
  60450. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60451. /**
  60452. * @ignore
  60453. * The chromatic aberration PostProcess id in the pipeline
  60454. */
  60455. LensChromaticAberrationEffect: string;
  60456. /**
  60457. * @ignore
  60458. * The highlights enhancing PostProcess id in the pipeline
  60459. */
  60460. HighlightsEnhancingEffect: string;
  60461. /**
  60462. * @ignore
  60463. * The depth-of-field PostProcess id in the pipeline
  60464. */
  60465. LensDepthOfFieldEffect: string;
  60466. private _scene;
  60467. private _depthTexture;
  60468. private _grainTexture;
  60469. private _chromaticAberrationPostProcess;
  60470. private _highlightsPostProcess;
  60471. private _depthOfFieldPostProcess;
  60472. private _edgeBlur;
  60473. private _grainAmount;
  60474. private _chromaticAberration;
  60475. private _distortion;
  60476. private _highlightsGain;
  60477. private _highlightsThreshold;
  60478. private _dofDistance;
  60479. private _dofAperture;
  60480. private _dofDarken;
  60481. private _dofPentagon;
  60482. private _blurNoise;
  60483. /**
  60484. * @constructor
  60485. *
  60486. * Effect parameters are as follow:
  60487. * {
  60488. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60489. * edge_blur: number; // from 0 to x (1 for realism)
  60490. * distortion: number; // from 0 to x (1 for realism)
  60491. * grain_amount: number; // from 0 to 1
  60492. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60493. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60494. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60495. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60496. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60497. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60498. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60499. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60500. * }
  60501. * Note: if an effect parameter is unset, effect is disabled
  60502. *
  60503. * @param name The rendering pipeline name
  60504. * @param parameters - An object containing all parameters (see above)
  60505. * @param scene The scene linked to this pipeline
  60506. * @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)
  60507. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60508. */
  60509. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60510. /**
  60511. * Get the class name
  60512. * @returns "LensRenderingPipeline"
  60513. */
  60514. getClassName(): string;
  60515. /**
  60516. * Gets associated scene
  60517. */
  60518. readonly scene: Scene;
  60519. /**
  60520. * Gets or sets the edge blur
  60521. */
  60522. edgeBlur: number;
  60523. /**
  60524. * Gets or sets the grain amount
  60525. */
  60526. grainAmount: number;
  60527. /**
  60528. * Gets or sets the chromatic aberration amount
  60529. */
  60530. chromaticAberration: number;
  60531. /**
  60532. * Gets or sets the depth of field aperture
  60533. */
  60534. dofAperture: number;
  60535. /**
  60536. * Gets or sets the edge distortion
  60537. */
  60538. edgeDistortion: number;
  60539. /**
  60540. * Gets or sets the depth of field distortion
  60541. */
  60542. dofDistortion: number;
  60543. /**
  60544. * Gets or sets the darken out of focus amount
  60545. */
  60546. darkenOutOfFocus: number;
  60547. /**
  60548. * Gets or sets a boolean indicating if blur noise is enabled
  60549. */
  60550. blurNoise: boolean;
  60551. /**
  60552. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60553. */
  60554. pentagonBokeh: boolean;
  60555. /**
  60556. * Gets or sets the highlight grain amount
  60557. */
  60558. highlightsGain: number;
  60559. /**
  60560. * Gets or sets the highlight threshold
  60561. */
  60562. highlightsThreshold: number;
  60563. /**
  60564. * Sets the amount of blur at the edges
  60565. * @param amount blur amount
  60566. */
  60567. setEdgeBlur(amount: number): void;
  60568. /**
  60569. * Sets edge blur to 0
  60570. */
  60571. disableEdgeBlur(): void;
  60572. /**
  60573. * Sets the amout of grain
  60574. * @param amount Amount of grain
  60575. */
  60576. setGrainAmount(amount: number): void;
  60577. /**
  60578. * Set grain amount to 0
  60579. */
  60580. disableGrain(): void;
  60581. /**
  60582. * Sets the chromatic aberration amount
  60583. * @param amount amount of chromatic aberration
  60584. */
  60585. setChromaticAberration(amount: number): void;
  60586. /**
  60587. * Sets chromatic aberration amount to 0
  60588. */
  60589. disableChromaticAberration(): void;
  60590. /**
  60591. * Sets the EdgeDistortion amount
  60592. * @param amount amount of EdgeDistortion
  60593. */
  60594. setEdgeDistortion(amount: number): void;
  60595. /**
  60596. * Sets edge distortion to 0
  60597. */
  60598. disableEdgeDistortion(): void;
  60599. /**
  60600. * Sets the FocusDistance amount
  60601. * @param amount amount of FocusDistance
  60602. */
  60603. setFocusDistance(amount: number): void;
  60604. /**
  60605. * Disables depth of field
  60606. */
  60607. disableDepthOfField(): void;
  60608. /**
  60609. * Sets the Aperture amount
  60610. * @param amount amount of Aperture
  60611. */
  60612. setAperture(amount: number): void;
  60613. /**
  60614. * Sets the DarkenOutOfFocus amount
  60615. * @param amount amount of DarkenOutOfFocus
  60616. */
  60617. setDarkenOutOfFocus(amount: number): void;
  60618. private _pentagonBokehIsEnabled;
  60619. /**
  60620. * Creates a pentagon bokeh effect
  60621. */
  60622. enablePentagonBokeh(): void;
  60623. /**
  60624. * Disables the pentagon bokeh effect
  60625. */
  60626. disablePentagonBokeh(): void;
  60627. /**
  60628. * Enables noise blur
  60629. */
  60630. enableNoiseBlur(): void;
  60631. /**
  60632. * Disables noise blur
  60633. */
  60634. disableNoiseBlur(): void;
  60635. /**
  60636. * Sets the HighlightsGain amount
  60637. * @param amount amount of HighlightsGain
  60638. */
  60639. setHighlightsGain(amount: number): void;
  60640. /**
  60641. * Sets the HighlightsThreshold amount
  60642. * @param amount amount of HighlightsThreshold
  60643. */
  60644. setHighlightsThreshold(amount: number): void;
  60645. /**
  60646. * Disables highlights
  60647. */
  60648. disableHighlights(): void;
  60649. /**
  60650. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60651. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60652. */
  60653. dispose(disableDepthRender?: boolean): void;
  60654. private _createChromaticAberrationPostProcess;
  60655. private _createHighlightsPostProcess;
  60656. private _createDepthOfFieldPostProcess;
  60657. private _createGrainTexture;
  60658. }
  60659. }
  60660. declare module "babylonjs/Shaders/ssao2.fragment" {
  60661. /** @hidden */
  60662. export var ssao2PixelShader: {
  60663. name: string;
  60664. shader: string;
  60665. };
  60666. }
  60667. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  60668. /** @hidden */
  60669. export var ssaoCombinePixelShader: {
  60670. name: string;
  60671. shader: string;
  60672. };
  60673. }
  60674. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  60675. import { Camera } from "babylonjs/Cameras/camera";
  60676. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60677. import { Scene } from "babylonjs/scene";
  60678. import "babylonjs/Shaders/ssao2.fragment";
  60679. import "babylonjs/Shaders/ssaoCombine.fragment";
  60680. /**
  60681. * Render pipeline to produce ssao effect
  60682. */
  60683. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60684. /**
  60685. * @ignore
  60686. * The PassPostProcess id in the pipeline that contains the original scene color
  60687. */
  60688. SSAOOriginalSceneColorEffect: string;
  60689. /**
  60690. * @ignore
  60691. * The SSAO PostProcess id in the pipeline
  60692. */
  60693. SSAORenderEffect: string;
  60694. /**
  60695. * @ignore
  60696. * The horizontal blur PostProcess id in the pipeline
  60697. */
  60698. SSAOBlurHRenderEffect: string;
  60699. /**
  60700. * @ignore
  60701. * The vertical blur PostProcess id in the pipeline
  60702. */
  60703. SSAOBlurVRenderEffect: string;
  60704. /**
  60705. * @ignore
  60706. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60707. */
  60708. SSAOCombineRenderEffect: string;
  60709. /**
  60710. * The output strength of the SSAO post-process. Default value is 1.0.
  60711. */
  60712. totalStrength: number;
  60713. /**
  60714. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60715. */
  60716. maxZ: number;
  60717. /**
  60718. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60719. */
  60720. minZAspect: number;
  60721. private _samples;
  60722. /**
  60723. * Number of samples used for the SSAO calculations. Default value is 8
  60724. */
  60725. samples: number;
  60726. private _textureSamples;
  60727. /**
  60728. * Number of samples to use for antialiasing
  60729. */
  60730. textureSamples: number;
  60731. /**
  60732. * Ratio object used for SSAO ratio and blur ratio
  60733. */
  60734. private _ratio;
  60735. /**
  60736. * Dynamically generated sphere sampler.
  60737. */
  60738. private _sampleSphere;
  60739. /**
  60740. * Blur filter offsets
  60741. */
  60742. private _samplerOffsets;
  60743. private _expensiveBlur;
  60744. /**
  60745. * If bilateral blur should be used
  60746. */
  60747. expensiveBlur: boolean;
  60748. /**
  60749. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60750. */
  60751. radius: number;
  60752. /**
  60753. * The base color of the SSAO post-process
  60754. * The final result is "base + ssao" between [0, 1]
  60755. */
  60756. base: number;
  60757. /**
  60758. * Support test.
  60759. */
  60760. static readonly IsSupported: boolean;
  60761. private _scene;
  60762. private _depthTexture;
  60763. private _normalTexture;
  60764. private _randomTexture;
  60765. private _originalColorPostProcess;
  60766. private _ssaoPostProcess;
  60767. private _blurHPostProcess;
  60768. private _blurVPostProcess;
  60769. private _ssaoCombinePostProcess;
  60770. private _firstUpdate;
  60771. /**
  60772. * Gets active scene
  60773. */
  60774. readonly scene: Scene;
  60775. /**
  60776. * @constructor
  60777. * @param name The rendering pipeline name
  60778. * @param scene The scene linked to this pipeline
  60779. * @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 }
  60780. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60781. */
  60782. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60783. /**
  60784. * Get the class name
  60785. * @returns "SSAO2RenderingPipeline"
  60786. */
  60787. getClassName(): string;
  60788. /**
  60789. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60790. */
  60791. dispose(disableGeometryBufferRenderer?: boolean): void;
  60792. private _createBlurPostProcess;
  60793. /** @hidden */
  60794. _rebuild(): void;
  60795. private _bits;
  60796. private _radicalInverse_VdC;
  60797. private _hammersley;
  60798. private _hemisphereSample_uniform;
  60799. private _generateHemisphere;
  60800. private _createSSAOPostProcess;
  60801. private _createSSAOCombinePostProcess;
  60802. private _createRandomTexture;
  60803. /**
  60804. * Serialize the rendering pipeline (Used when exporting)
  60805. * @returns the serialized object
  60806. */
  60807. serialize(): any;
  60808. /**
  60809. * Parse the serialized pipeline
  60810. * @param source Source pipeline.
  60811. * @param scene The scene to load the pipeline to.
  60812. * @param rootUrl The URL of the serialized pipeline.
  60813. * @returns An instantiated pipeline from the serialized object.
  60814. */
  60815. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60816. }
  60817. }
  60818. declare module "babylonjs/Shaders/ssao.fragment" {
  60819. /** @hidden */
  60820. export var ssaoPixelShader: {
  60821. name: string;
  60822. shader: string;
  60823. };
  60824. }
  60825. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  60826. import { Camera } from "babylonjs/Cameras/camera";
  60827. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60828. import { Scene } from "babylonjs/scene";
  60829. import "babylonjs/Shaders/ssao.fragment";
  60830. import "babylonjs/Shaders/ssaoCombine.fragment";
  60831. /**
  60832. * Render pipeline to produce ssao effect
  60833. */
  60834. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60835. /**
  60836. * @ignore
  60837. * The PassPostProcess id in the pipeline that contains the original scene color
  60838. */
  60839. SSAOOriginalSceneColorEffect: string;
  60840. /**
  60841. * @ignore
  60842. * The SSAO PostProcess id in the pipeline
  60843. */
  60844. SSAORenderEffect: string;
  60845. /**
  60846. * @ignore
  60847. * The horizontal blur PostProcess id in the pipeline
  60848. */
  60849. SSAOBlurHRenderEffect: string;
  60850. /**
  60851. * @ignore
  60852. * The vertical blur PostProcess id in the pipeline
  60853. */
  60854. SSAOBlurVRenderEffect: string;
  60855. /**
  60856. * @ignore
  60857. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60858. */
  60859. SSAOCombineRenderEffect: string;
  60860. /**
  60861. * The output strength of the SSAO post-process. Default value is 1.0.
  60862. */
  60863. totalStrength: number;
  60864. /**
  60865. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60866. */
  60867. radius: number;
  60868. /**
  60869. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60870. * Must not be equal to fallOff and superior to fallOff.
  60871. * Default value is 0.0075
  60872. */
  60873. area: number;
  60874. /**
  60875. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60876. * Must not be equal to area and inferior to area.
  60877. * Default value is 0.000001
  60878. */
  60879. fallOff: number;
  60880. /**
  60881. * The base color of the SSAO post-process
  60882. * The final result is "base + ssao" between [0, 1]
  60883. */
  60884. base: number;
  60885. private _scene;
  60886. private _depthTexture;
  60887. private _randomTexture;
  60888. private _originalColorPostProcess;
  60889. private _ssaoPostProcess;
  60890. private _blurHPostProcess;
  60891. private _blurVPostProcess;
  60892. private _ssaoCombinePostProcess;
  60893. private _firstUpdate;
  60894. /**
  60895. * Gets active scene
  60896. */
  60897. readonly scene: Scene;
  60898. /**
  60899. * @constructor
  60900. * @param name - The rendering pipeline name
  60901. * @param scene - The scene linked to this pipeline
  60902. * @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 }
  60903. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60904. */
  60905. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60906. /**
  60907. * Get the class name
  60908. * @returns "SSAORenderingPipeline"
  60909. */
  60910. getClassName(): string;
  60911. /**
  60912. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60913. */
  60914. dispose(disableDepthRender?: boolean): void;
  60915. private _createBlurPostProcess;
  60916. /** @hidden */
  60917. _rebuild(): void;
  60918. private _createSSAOPostProcess;
  60919. private _createSSAOCombinePostProcess;
  60920. private _createRandomTexture;
  60921. }
  60922. }
  60923. declare module "babylonjs/Shaders/standard.fragment" {
  60924. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60925. /** @hidden */
  60926. export var standardPixelShader: {
  60927. name: string;
  60928. shader: string;
  60929. };
  60930. }
  60931. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  60932. import { Nullable } from "babylonjs/types";
  60933. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60934. import { Camera } from "babylonjs/Cameras/camera";
  60935. import { Texture } from "babylonjs/Materials/Textures/texture";
  60936. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60937. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60938. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60939. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60940. import { IDisposable } from "babylonjs/scene";
  60941. import { SpotLight } from "babylonjs/Lights/spotLight";
  60942. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60943. import { Scene } from "babylonjs/scene";
  60944. import { Animation } from "babylonjs/Animations/animation";
  60945. import "babylonjs/Shaders/standard.fragment";
  60946. /**
  60947. * Standard rendering pipeline
  60948. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60949. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60950. */
  60951. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60952. /**
  60953. * Public members
  60954. */
  60955. /**
  60956. * Post-process which contains the original scene color before the pipeline applies all the effects
  60957. */
  60958. originalPostProcess: Nullable<PostProcess>;
  60959. /**
  60960. * Post-process used to down scale an image x4
  60961. */
  60962. downSampleX4PostProcess: Nullable<PostProcess>;
  60963. /**
  60964. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60965. */
  60966. brightPassPostProcess: Nullable<PostProcess>;
  60967. /**
  60968. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60969. */
  60970. blurHPostProcesses: PostProcess[];
  60971. /**
  60972. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60973. */
  60974. blurVPostProcesses: PostProcess[];
  60975. /**
  60976. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60977. */
  60978. textureAdderPostProcess: Nullable<PostProcess>;
  60979. /**
  60980. * Post-process used to create volumetric lighting effect
  60981. */
  60982. volumetricLightPostProcess: Nullable<PostProcess>;
  60983. /**
  60984. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60985. */
  60986. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60987. /**
  60988. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60989. */
  60990. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60991. /**
  60992. * Post-process used to merge the volumetric light effect and the real scene color
  60993. */
  60994. volumetricLightMergePostProces: Nullable<PostProcess>;
  60995. /**
  60996. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60997. */
  60998. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60999. /**
  61000. * Base post-process used to calculate the average luminance of the final image for HDR
  61001. */
  61002. luminancePostProcess: Nullable<PostProcess>;
  61003. /**
  61004. * Post-processes used to create down sample post-processes in order to get
  61005. * the average luminance of the final image for HDR
  61006. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61007. */
  61008. luminanceDownSamplePostProcesses: PostProcess[];
  61009. /**
  61010. * Post-process used to create a HDR effect (light adaptation)
  61011. */
  61012. hdrPostProcess: Nullable<PostProcess>;
  61013. /**
  61014. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61015. */
  61016. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61017. /**
  61018. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61019. */
  61020. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61021. /**
  61022. * Post-process used to merge the final HDR post-process and the real scene color
  61023. */
  61024. hdrFinalPostProcess: Nullable<PostProcess>;
  61025. /**
  61026. * Post-process used to create a lens flare effect
  61027. */
  61028. lensFlarePostProcess: Nullable<PostProcess>;
  61029. /**
  61030. * Post-process that merges the result of the lens flare post-process and the real scene color
  61031. */
  61032. lensFlareComposePostProcess: Nullable<PostProcess>;
  61033. /**
  61034. * Post-process used to create a motion blur effect
  61035. */
  61036. motionBlurPostProcess: Nullable<PostProcess>;
  61037. /**
  61038. * Post-process used to create a depth of field effect
  61039. */
  61040. depthOfFieldPostProcess: Nullable<PostProcess>;
  61041. /**
  61042. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61043. */
  61044. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61045. /**
  61046. * Represents the brightness threshold in order to configure the illuminated surfaces
  61047. */
  61048. brightThreshold: number;
  61049. /**
  61050. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61051. */
  61052. blurWidth: number;
  61053. /**
  61054. * Sets if the blur for highlighted surfaces must be only horizontal
  61055. */
  61056. horizontalBlur: boolean;
  61057. /**
  61058. * Gets the overall exposure used by the pipeline
  61059. */
  61060. /**
  61061. * Sets the overall exposure used by the pipeline
  61062. */
  61063. exposure: number;
  61064. /**
  61065. * Texture used typically to simulate "dirty" on camera lens
  61066. */
  61067. lensTexture: Nullable<Texture>;
  61068. /**
  61069. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61070. */
  61071. volumetricLightCoefficient: number;
  61072. /**
  61073. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61074. */
  61075. volumetricLightPower: number;
  61076. /**
  61077. * Used the set the blur intensity to smooth the volumetric lights
  61078. */
  61079. volumetricLightBlurScale: number;
  61080. /**
  61081. * Light (spot or directional) used to generate the volumetric lights rays
  61082. * The source light must have a shadow generate so the pipeline can get its
  61083. * depth map
  61084. */
  61085. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61086. /**
  61087. * For eye adaptation, represents the minimum luminance the eye can see
  61088. */
  61089. hdrMinimumLuminance: number;
  61090. /**
  61091. * For eye adaptation, represents the decrease luminance speed
  61092. */
  61093. hdrDecreaseRate: number;
  61094. /**
  61095. * For eye adaptation, represents the increase luminance speed
  61096. */
  61097. hdrIncreaseRate: number;
  61098. /**
  61099. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61100. */
  61101. /**
  61102. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61103. */
  61104. hdrAutoExposure: boolean;
  61105. /**
  61106. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61107. */
  61108. lensColorTexture: Nullable<Texture>;
  61109. /**
  61110. * The overall strengh for the lens flare effect
  61111. */
  61112. lensFlareStrength: number;
  61113. /**
  61114. * Dispersion coefficient for lens flare ghosts
  61115. */
  61116. lensFlareGhostDispersal: number;
  61117. /**
  61118. * Main lens flare halo width
  61119. */
  61120. lensFlareHaloWidth: number;
  61121. /**
  61122. * Based on the lens distortion effect, defines how much the lens flare result
  61123. * is distorted
  61124. */
  61125. lensFlareDistortionStrength: number;
  61126. /**
  61127. * Lens star texture must be used to simulate rays on the flares and is available
  61128. * in the documentation
  61129. */
  61130. lensStarTexture: Nullable<Texture>;
  61131. /**
  61132. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61133. * flare effect by taking account of the dirt texture
  61134. */
  61135. lensFlareDirtTexture: Nullable<Texture>;
  61136. /**
  61137. * Represents the focal length for the depth of field effect
  61138. */
  61139. depthOfFieldDistance: number;
  61140. /**
  61141. * Represents the blur intensity for the blurred part of the depth of field effect
  61142. */
  61143. depthOfFieldBlurWidth: number;
  61144. /**
  61145. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61146. */
  61147. /**
  61148. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61149. */
  61150. motionStrength: number;
  61151. /**
  61152. * Gets wether or not the motion blur post-process is object based or screen based.
  61153. */
  61154. /**
  61155. * Sets wether or not the motion blur post-process should be object based or screen based
  61156. */
  61157. objectBasedMotionBlur: boolean;
  61158. /**
  61159. * List of animations for the pipeline (IAnimatable implementation)
  61160. */
  61161. animations: Animation[];
  61162. /**
  61163. * Private members
  61164. */
  61165. private _scene;
  61166. private _currentDepthOfFieldSource;
  61167. private _basePostProcess;
  61168. private _fixedExposure;
  61169. private _currentExposure;
  61170. private _hdrAutoExposure;
  61171. private _hdrCurrentLuminance;
  61172. private _motionStrength;
  61173. private _isObjectBasedMotionBlur;
  61174. private _floatTextureType;
  61175. private _ratio;
  61176. private _bloomEnabled;
  61177. private _depthOfFieldEnabled;
  61178. private _vlsEnabled;
  61179. private _lensFlareEnabled;
  61180. private _hdrEnabled;
  61181. private _motionBlurEnabled;
  61182. private _fxaaEnabled;
  61183. private _motionBlurSamples;
  61184. private _volumetricLightStepsCount;
  61185. private _samples;
  61186. /**
  61187. * @ignore
  61188. * Specifies if the bloom pipeline is enabled
  61189. */
  61190. BloomEnabled: boolean;
  61191. /**
  61192. * @ignore
  61193. * Specifies if the depth of field pipeline is enabed
  61194. */
  61195. DepthOfFieldEnabled: boolean;
  61196. /**
  61197. * @ignore
  61198. * Specifies if the lens flare pipeline is enabed
  61199. */
  61200. LensFlareEnabled: boolean;
  61201. /**
  61202. * @ignore
  61203. * Specifies if the HDR pipeline is enabled
  61204. */
  61205. HDREnabled: boolean;
  61206. /**
  61207. * @ignore
  61208. * Specifies if the volumetric lights scattering effect is enabled
  61209. */
  61210. VLSEnabled: boolean;
  61211. /**
  61212. * @ignore
  61213. * Specifies if the motion blur effect is enabled
  61214. */
  61215. MotionBlurEnabled: boolean;
  61216. /**
  61217. * Specifies if anti-aliasing is enabled
  61218. */
  61219. fxaaEnabled: boolean;
  61220. /**
  61221. * Specifies the number of steps used to calculate the volumetric lights
  61222. * Typically in interval [50, 200]
  61223. */
  61224. volumetricLightStepsCount: number;
  61225. /**
  61226. * Specifies the number of samples used for the motion blur effect
  61227. * Typically in interval [16, 64]
  61228. */
  61229. motionBlurSamples: number;
  61230. /**
  61231. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61232. */
  61233. samples: number;
  61234. /**
  61235. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61236. * @constructor
  61237. * @param name The rendering pipeline name
  61238. * @param scene The scene linked to this pipeline
  61239. * @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)
  61240. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61241. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61242. */
  61243. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61244. private _buildPipeline;
  61245. private _createDownSampleX4PostProcess;
  61246. private _createBrightPassPostProcess;
  61247. private _createBlurPostProcesses;
  61248. private _createTextureAdderPostProcess;
  61249. private _createVolumetricLightPostProcess;
  61250. private _createLuminancePostProcesses;
  61251. private _createHdrPostProcess;
  61252. private _createLensFlarePostProcess;
  61253. private _createDepthOfFieldPostProcess;
  61254. private _createMotionBlurPostProcess;
  61255. private _getDepthTexture;
  61256. private _disposePostProcesses;
  61257. /**
  61258. * Dispose of the pipeline and stop all post processes
  61259. */
  61260. dispose(): void;
  61261. /**
  61262. * Serialize the rendering pipeline (Used when exporting)
  61263. * @returns the serialized object
  61264. */
  61265. serialize(): any;
  61266. /**
  61267. * Parse the serialized pipeline
  61268. * @param source Source pipeline.
  61269. * @param scene The scene to load the pipeline to.
  61270. * @param rootUrl The URL of the serialized pipeline.
  61271. * @returns An instantiated pipeline from the serialized object.
  61272. */
  61273. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61274. /**
  61275. * Luminance steps
  61276. */
  61277. static LuminanceSteps: number;
  61278. }
  61279. }
  61280. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  61281. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  61282. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  61283. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  61284. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  61285. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  61286. }
  61287. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  61288. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  61289. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61290. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61291. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61292. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61293. }
  61294. declare module "babylonjs/Shaders/tonemap.fragment" {
  61295. /** @hidden */
  61296. export var tonemapPixelShader: {
  61297. name: string;
  61298. shader: string;
  61299. };
  61300. }
  61301. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  61302. import { Camera } from "babylonjs/Cameras/camera";
  61303. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61304. import "babylonjs/Shaders/tonemap.fragment";
  61305. import { Engine } from "babylonjs/Engines/engine";
  61306. /** Defines operator used for tonemapping */
  61307. export enum TonemappingOperator {
  61308. /** Hable */
  61309. Hable = 0,
  61310. /** Reinhard */
  61311. Reinhard = 1,
  61312. /** HejiDawson */
  61313. HejiDawson = 2,
  61314. /** Photographic */
  61315. Photographic = 3
  61316. }
  61317. /**
  61318. * Defines a post process to apply tone mapping
  61319. */
  61320. export class TonemapPostProcess extends PostProcess {
  61321. private _operator;
  61322. /** Defines the required exposure adjustement */
  61323. exposureAdjustment: number;
  61324. /**
  61325. * Creates a new TonemapPostProcess
  61326. * @param name defines the name of the postprocess
  61327. * @param _operator defines the operator to use
  61328. * @param exposureAdjustment defines the required exposure adjustement
  61329. * @param camera defines the camera to use (can be null)
  61330. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61331. * @param engine defines the hosting engine (can be ignore if camera is set)
  61332. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61333. */
  61334. constructor(name: string, _operator: TonemappingOperator,
  61335. /** Defines the required exposure adjustement */
  61336. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61337. }
  61338. }
  61339. declare module "babylonjs/Shaders/depth.vertex" {
  61340. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61341. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61343. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61344. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61345. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61346. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61347. /** @hidden */
  61348. export var depthVertexShader: {
  61349. name: string;
  61350. shader: string;
  61351. };
  61352. }
  61353. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  61354. /** @hidden */
  61355. export var volumetricLightScatteringPixelShader: {
  61356. name: string;
  61357. shader: string;
  61358. };
  61359. }
  61360. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  61361. /** @hidden */
  61362. export var volumetricLightScatteringPassPixelShader: {
  61363. name: string;
  61364. shader: string;
  61365. };
  61366. }
  61367. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  61368. import { Vector3 } from "babylonjs/Maths/math.vector";
  61369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61370. import { Mesh } from "babylonjs/Meshes/mesh";
  61371. import { Camera } from "babylonjs/Cameras/camera";
  61372. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61373. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61374. import { Scene } from "babylonjs/scene";
  61375. import "babylonjs/Meshes/Builders/planeBuilder";
  61376. import "babylonjs/Shaders/depth.vertex";
  61377. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  61378. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  61379. import { Engine } from "babylonjs/Engines/engine";
  61380. /**
  61381. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61382. */
  61383. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61384. private _volumetricLightScatteringPass;
  61385. private _volumetricLightScatteringRTT;
  61386. private _viewPort;
  61387. private _screenCoordinates;
  61388. private _cachedDefines;
  61389. /**
  61390. * If not undefined, the mesh position is computed from the attached node position
  61391. */
  61392. attachedNode: {
  61393. position: Vector3;
  61394. };
  61395. /**
  61396. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61397. */
  61398. customMeshPosition: Vector3;
  61399. /**
  61400. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61401. */
  61402. useCustomMeshPosition: boolean;
  61403. /**
  61404. * If the post-process should inverse the light scattering direction
  61405. */
  61406. invert: boolean;
  61407. /**
  61408. * The internal mesh used by the post-process
  61409. */
  61410. mesh: Mesh;
  61411. /**
  61412. * @hidden
  61413. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61414. */
  61415. useDiffuseColor: boolean;
  61416. /**
  61417. * Array containing the excluded meshes not rendered in the internal pass
  61418. */
  61419. excludedMeshes: AbstractMesh[];
  61420. /**
  61421. * Controls the overall intensity of the post-process
  61422. */
  61423. exposure: number;
  61424. /**
  61425. * Dissipates each sample's contribution in range [0, 1]
  61426. */
  61427. decay: number;
  61428. /**
  61429. * Controls the overall intensity of each sample
  61430. */
  61431. weight: number;
  61432. /**
  61433. * Controls the density of each sample
  61434. */
  61435. density: number;
  61436. /**
  61437. * @constructor
  61438. * @param name The post-process name
  61439. * @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)
  61440. * @param camera The camera that the post-process will be attached to
  61441. * @param mesh The mesh used to create the light scattering
  61442. * @param samples The post-process quality, default 100
  61443. * @param samplingModeThe post-process filtering mode
  61444. * @param engine The babylon engine
  61445. * @param reusable If the post-process is reusable
  61446. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61447. */
  61448. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61449. /**
  61450. * Returns the string "VolumetricLightScatteringPostProcess"
  61451. * @returns "VolumetricLightScatteringPostProcess"
  61452. */
  61453. getClassName(): string;
  61454. private _isReady;
  61455. /**
  61456. * Sets the new light position for light scattering effect
  61457. * @param position The new custom light position
  61458. */
  61459. setCustomMeshPosition(position: Vector3): void;
  61460. /**
  61461. * Returns the light position for light scattering effect
  61462. * @return Vector3 The custom light position
  61463. */
  61464. getCustomMeshPosition(): Vector3;
  61465. /**
  61466. * Disposes the internal assets and detaches the post-process from the camera
  61467. */
  61468. dispose(camera: Camera): void;
  61469. /**
  61470. * Returns the render target texture used by the post-process
  61471. * @return the render target texture used by the post-process
  61472. */
  61473. getPass(): RenderTargetTexture;
  61474. private _meshExcluded;
  61475. private _createPass;
  61476. private _updateMeshScreenCoordinates;
  61477. /**
  61478. * Creates a default mesh for the Volumeric Light Scattering post-process
  61479. * @param name The mesh name
  61480. * @param scene The scene where to create the mesh
  61481. * @return the default mesh
  61482. */
  61483. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61484. }
  61485. }
  61486. declare module "babylonjs/PostProcesses/index" {
  61487. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  61488. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  61489. export * from "babylonjs/PostProcesses/bloomEffect";
  61490. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  61491. export * from "babylonjs/PostProcesses/blurPostProcess";
  61492. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61493. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  61494. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  61495. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  61496. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61497. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  61498. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  61499. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  61500. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61501. export * from "babylonjs/PostProcesses/filterPostProcess";
  61502. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  61503. export * from "babylonjs/PostProcesses/grainPostProcess";
  61504. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  61505. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61506. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  61507. export * from "babylonjs/PostProcesses/passPostProcess";
  61508. export * from "babylonjs/PostProcesses/postProcess";
  61509. export * from "babylonjs/PostProcesses/postProcessManager";
  61510. export * from "babylonjs/PostProcesses/refractionPostProcess";
  61511. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  61512. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  61513. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  61514. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  61515. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  61516. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  61517. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  61518. }
  61519. declare module "babylonjs/Probes/index" {
  61520. export * from "babylonjs/Probes/reflectionProbe";
  61521. }
  61522. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  61523. import { Scene } from "babylonjs/scene";
  61524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61525. import { SmartArray } from "babylonjs/Misc/smartArray";
  61526. import { ISceneComponent } from "babylonjs/sceneComponent";
  61527. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  61528. import "babylonjs/Meshes/Builders/boxBuilder";
  61529. import "babylonjs/Shaders/color.fragment";
  61530. import "babylonjs/Shaders/color.vertex";
  61531. import { Color3 } from "babylonjs/Maths/math.color";
  61532. module "babylonjs/scene" {
  61533. interface Scene {
  61534. /** @hidden (Backing field) */
  61535. _boundingBoxRenderer: BoundingBoxRenderer;
  61536. /** @hidden (Backing field) */
  61537. _forceShowBoundingBoxes: boolean;
  61538. /**
  61539. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61540. */
  61541. forceShowBoundingBoxes: boolean;
  61542. /**
  61543. * Gets the bounding box renderer associated with the scene
  61544. * @returns a BoundingBoxRenderer
  61545. */
  61546. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61547. }
  61548. }
  61549. module "babylonjs/Meshes/abstractMesh" {
  61550. interface AbstractMesh {
  61551. /** @hidden (Backing field) */
  61552. _showBoundingBox: boolean;
  61553. /**
  61554. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61555. */
  61556. showBoundingBox: boolean;
  61557. }
  61558. }
  61559. /**
  61560. * Component responsible of rendering the bounding box of the meshes in a scene.
  61561. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61562. */
  61563. export class BoundingBoxRenderer implements ISceneComponent {
  61564. /**
  61565. * The component name helpfull to identify the component in the list of scene components.
  61566. */
  61567. readonly name: string;
  61568. /**
  61569. * The scene the component belongs to.
  61570. */
  61571. scene: Scene;
  61572. /**
  61573. * Color of the bounding box lines placed in front of an object
  61574. */
  61575. frontColor: Color3;
  61576. /**
  61577. * Color of the bounding box lines placed behind an object
  61578. */
  61579. backColor: Color3;
  61580. /**
  61581. * Defines if the renderer should show the back lines or not
  61582. */
  61583. showBackLines: boolean;
  61584. /**
  61585. * @hidden
  61586. */
  61587. renderList: SmartArray<BoundingBox>;
  61588. private _colorShader;
  61589. private _vertexBuffers;
  61590. private _indexBuffer;
  61591. private _fillIndexBuffer;
  61592. private _fillIndexData;
  61593. /**
  61594. * Instantiates a new bounding box renderer in a scene.
  61595. * @param scene the scene the renderer renders in
  61596. */
  61597. constructor(scene: Scene);
  61598. /**
  61599. * Registers the component in a given scene
  61600. */
  61601. register(): void;
  61602. private _evaluateSubMesh;
  61603. private _activeMesh;
  61604. private _prepareRessources;
  61605. private _createIndexBuffer;
  61606. /**
  61607. * Rebuilds the elements related to this component in case of
  61608. * context lost for instance.
  61609. */
  61610. rebuild(): void;
  61611. /**
  61612. * @hidden
  61613. */
  61614. reset(): void;
  61615. /**
  61616. * Render the bounding boxes of a specific rendering group
  61617. * @param renderingGroupId defines the rendering group to render
  61618. */
  61619. render(renderingGroupId: number): void;
  61620. /**
  61621. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61622. * @param mesh Define the mesh to render the occlusion bounding box for
  61623. */
  61624. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61625. /**
  61626. * Dispose and release the resources attached to this renderer.
  61627. */
  61628. dispose(): void;
  61629. }
  61630. }
  61631. declare module "babylonjs/Shaders/depth.fragment" {
  61632. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61633. /** @hidden */
  61634. export var depthPixelShader: {
  61635. name: string;
  61636. shader: string;
  61637. };
  61638. }
  61639. declare module "babylonjs/Rendering/depthRenderer" {
  61640. import { Nullable } from "babylonjs/types";
  61641. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61642. import { Scene } from "babylonjs/scene";
  61643. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61644. import { Camera } from "babylonjs/Cameras/camera";
  61645. import "babylonjs/Shaders/depth.fragment";
  61646. import "babylonjs/Shaders/depth.vertex";
  61647. /**
  61648. * This represents a depth renderer in Babylon.
  61649. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61650. */
  61651. export class DepthRenderer {
  61652. private _scene;
  61653. private _depthMap;
  61654. private _effect;
  61655. private readonly _storeNonLinearDepth;
  61656. private readonly _clearColor;
  61657. /** Get if the depth renderer is using packed depth or not */
  61658. readonly isPacked: boolean;
  61659. private _cachedDefines;
  61660. private _camera;
  61661. /**
  61662. * Specifiess that the depth renderer will only be used within
  61663. * the camera it is created for.
  61664. * This can help forcing its rendering during the camera processing.
  61665. */
  61666. useOnlyInActiveCamera: boolean;
  61667. /** @hidden */
  61668. static _SceneComponentInitialization: (scene: Scene) => void;
  61669. /**
  61670. * Instantiates a depth renderer
  61671. * @param scene The scene the renderer belongs to
  61672. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61673. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61674. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61675. */
  61676. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61677. /**
  61678. * Creates the depth rendering effect and checks if the effect is ready.
  61679. * @param subMesh The submesh to be used to render the depth map of
  61680. * @param useInstances If multiple world instances should be used
  61681. * @returns if the depth renderer is ready to render the depth map
  61682. */
  61683. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61684. /**
  61685. * Gets the texture which the depth map will be written to.
  61686. * @returns The depth map texture
  61687. */
  61688. getDepthMap(): RenderTargetTexture;
  61689. /**
  61690. * Disposes of the depth renderer.
  61691. */
  61692. dispose(): void;
  61693. }
  61694. }
  61695. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  61696. import { Nullable } from "babylonjs/types";
  61697. import { Scene } from "babylonjs/scene";
  61698. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61699. import { Camera } from "babylonjs/Cameras/camera";
  61700. import { ISceneComponent } from "babylonjs/sceneComponent";
  61701. module "babylonjs/scene" {
  61702. interface Scene {
  61703. /** @hidden (Backing field) */
  61704. _depthRenderer: {
  61705. [id: string]: DepthRenderer;
  61706. };
  61707. /**
  61708. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61709. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61710. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61711. * @returns the created depth renderer
  61712. */
  61713. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61714. /**
  61715. * Disables a depth renderer for a given camera
  61716. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61717. */
  61718. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61719. }
  61720. }
  61721. /**
  61722. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61723. * in several rendering techniques.
  61724. */
  61725. export class DepthRendererSceneComponent implements ISceneComponent {
  61726. /**
  61727. * The component name helpfull to identify the component in the list of scene components.
  61728. */
  61729. readonly name: string;
  61730. /**
  61731. * The scene the component belongs to.
  61732. */
  61733. scene: Scene;
  61734. /**
  61735. * Creates a new instance of the component for the given scene
  61736. * @param scene Defines the scene to register the component in
  61737. */
  61738. constructor(scene: Scene);
  61739. /**
  61740. * Registers the component in a given scene
  61741. */
  61742. register(): void;
  61743. /**
  61744. * Rebuilds the elements related to this component in case of
  61745. * context lost for instance.
  61746. */
  61747. rebuild(): void;
  61748. /**
  61749. * Disposes the component and the associated ressources
  61750. */
  61751. dispose(): void;
  61752. private _gatherRenderTargets;
  61753. private _gatherActiveCameraRenderTargets;
  61754. }
  61755. }
  61756. declare module "babylonjs/Shaders/outline.fragment" {
  61757. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61758. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  61759. /** @hidden */
  61760. export var outlinePixelShader: {
  61761. name: string;
  61762. shader: string;
  61763. };
  61764. }
  61765. declare module "babylonjs/Shaders/outline.vertex" {
  61766. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61767. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61769. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61770. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61771. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61772. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61773. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61774. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  61775. /** @hidden */
  61776. export var outlineVertexShader: {
  61777. name: string;
  61778. shader: string;
  61779. };
  61780. }
  61781. declare module "babylonjs/Rendering/outlineRenderer" {
  61782. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61783. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  61784. import { Scene } from "babylonjs/scene";
  61785. import { ISceneComponent } from "babylonjs/sceneComponent";
  61786. import "babylonjs/Shaders/outline.fragment";
  61787. import "babylonjs/Shaders/outline.vertex";
  61788. module "babylonjs/scene" {
  61789. interface Scene {
  61790. /** @hidden */
  61791. _outlineRenderer: OutlineRenderer;
  61792. /**
  61793. * Gets the outline renderer associated with the scene
  61794. * @returns a OutlineRenderer
  61795. */
  61796. getOutlineRenderer(): OutlineRenderer;
  61797. }
  61798. }
  61799. module "babylonjs/Meshes/abstractMesh" {
  61800. interface AbstractMesh {
  61801. /** @hidden (Backing field) */
  61802. _renderOutline: boolean;
  61803. /**
  61804. * Gets or sets a boolean indicating if the outline must be rendered as well
  61805. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61806. */
  61807. renderOutline: boolean;
  61808. /** @hidden (Backing field) */
  61809. _renderOverlay: boolean;
  61810. /**
  61811. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61812. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61813. */
  61814. renderOverlay: boolean;
  61815. }
  61816. }
  61817. /**
  61818. * This class is responsible to draw bothe outline/overlay of meshes.
  61819. * It should not be used directly but through the available method on mesh.
  61820. */
  61821. export class OutlineRenderer implements ISceneComponent {
  61822. /**
  61823. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61824. */
  61825. private static _StencilReference;
  61826. /**
  61827. * The name of the component. Each component must have a unique name.
  61828. */
  61829. name: string;
  61830. /**
  61831. * The scene the component belongs to.
  61832. */
  61833. scene: Scene;
  61834. /**
  61835. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61836. */
  61837. zOffset: number;
  61838. private _engine;
  61839. private _effect;
  61840. private _cachedDefines;
  61841. private _savedDepthWrite;
  61842. /**
  61843. * Instantiates a new outline renderer. (There could be only one per scene).
  61844. * @param scene Defines the scene it belongs to
  61845. */
  61846. constructor(scene: Scene);
  61847. /**
  61848. * Register the component to one instance of a scene.
  61849. */
  61850. register(): void;
  61851. /**
  61852. * Rebuilds the elements related to this component in case of
  61853. * context lost for instance.
  61854. */
  61855. rebuild(): void;
  61856. /**
  61857. * Disposes the component and the associated ressources.
  61858. */
  61859. dispose(): void;
  61860. /**
  61861. * Renders the outline in the canvas.
  61862. * @param subMesh Defines the sumesh to render
  61863. * @param batch Defines the batch of meshes in case of instances
  61864. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61865. */
  61866. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61867. /**
  61868. * Returns whether or not the outline renderer is ready for a given submesh.
  61869. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61870. * @param subMesh Defines the submesh to check readyness for
  61871. * @param useInstances Defines wheter wee are trying to render instances or not
  61872. * @returns true if ready otherwise false
  61873. */
  61874. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61875. private _beforeRenderingMesh;
  61876. private _afterRenderingMesh;
  61877. }
  61878. }
  61879. declare module "babylonjs/Rendering/index" {
  61880. export * from "babylonjs/Rendering/boundingBoxRenderer";
  61881. export * from "babylonjs/Rendering/depthRenderer";
  61882. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  61883. export * from "babylonjs/Rendering/edgesRenderer";
  61884. export * from "babylonjs/Rendering/geometryBufferRenderer";
  61885. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61886. export * from "babylonjs/Rendering/outlineRenderer";
  61887. export * from "babylonjs/Rendering/renderingGroup";
  61888. export * from "babylonjs/Rendering/renderingManager";
  61889. export * from "babylonjs/Rendering/utilityLayerRenderer";
  61890. }
  61891. declare module "babylonjs/Sprites/index" {
  61892. export * from "babylonjs/Sprites/sprite";
  61893. export * from "babylonjs/Sprites/spriteManager";
  61894. export * from "babylonjs/Sprites/spriteSceneComponent";
  61895. }
  61896. declare module "babylonjs/Misc/assetsManager" {
  61897. import { Scene } from "babylonjs/scene";
  61898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61899. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61900. import { Skeleton } from "babylonjs/Bones/skeleton";
  61901. import { Observable } from "babylonjs/Misc/observable";
  61902. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61903. import { Texture } from "babylonjs/Materials/Textures/texture";
  61904. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  61905. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  61906. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  61907. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  61908. /**
  61909. * Defines the list of states available for a task inside a AssetsManager
  61910. */
  61911. export enum AssetTaskState {
  61912. /**
  61913. * Initialization
  61914. */
  61915. INIT = 0,
  61916. /**
  61917. * Running
  61918. */
  61919. RUNNING = 1,
  61920. /**
  61921. * Done
  61922. */
  61923. DONE = 2,
  61924. /**
  61925. * Error
  61926. */
  61927. ERROR = 3
  61928. }
  61929. /**
  61930. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61931. */
  61932. export abstract class AbstractAssetTask {
  61933. /**
  61934. * Task name
  61935. */ name: string;
  61936. /**
  61937. * Callback called when the task is successful
  61938. */
  61939. onSuccess: (task: any) => void;
  61940. /**
  61941. * Callback called when the task is not successful
  61942. */
  61943. onError: (task: any, message?: string, exception?: any) => void;
  61944. /**
  61945. * Creates a new AssetsManager
  61946. * @param name defines the name of the task
  61947. */
  61948. constructor(
  61949. /**
  61950. * Task name
  61951. */ name: string);
  61952. private _isCompleted;
  61953. private _taskState;
  61954. private _errorObject;
  61955. /**
  61956. * Get if the task is completed
  61957. */
  61958. readonly isCompleted: boolean;
  61959. /**
  61960. * Gets the current state of the task
  61961. */
  61962. readonly taskState: AssetTaskState;
  61963. /**
  61964. * Gets the current error object (if task is in error)
  61965. */
  61966. readonly errorObject: {
  61967. message?: string;
  61968. exception?: any;
  61969. };
  61970. /**
  61971. * Internal only
  61972. * @hidden
  61973. */
  61974. _setErrorObject(message?: string, exception?: any): void;
  61975. /**
  61976. * Execute the current task
  61977. * @param scene defines the scene where you want your assets to be loaded
  61978. * @param onSuccess is a callback called when the task is successfully executed
  61979. * @param onError is a callback called if an error occurs
  61980. */
  61981. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61982. /**
  61983. * Execute the current task
  61984. * @param scene defines the scene where you want your assets to be loaded
  61985. * @param onSuccess is a callback called when the task is successfully executed
  61986. * @param onError is a callback called if an error occurs
  61987. */
  61988. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61989. /**
  61990. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61991. * This can be used with failed tasks that have the reason for failure fixed.
  61992. */
  61993. reset(): void;
  61994. private onErrorCallback;
  61995. private onDoneCallback;
  61996. }
  61997. /**
  61998. * Define the interface used by progress events raised during assets loading
  61999. */
  62000. export interface IAssetsProgressEvent {
  62001. /**
  62002. * Defines the number of remaining tasks to process
  62003. */
  62004. remainingCount: number;
  62005. /**
  62006. * Defines the total number of tasks
  62007. */
  62008. totalCount: number;
  62009. /**
  62010. * Defines the task that was just processed
  62011. */
  62012. task: AbstractAssetTask;
  62013. }
  62014. /**
  62015. * Class used to share progress information about assets loading
  62016. */
  62017. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62018. /**
  62019. * Defines the number of remaining tasks to process
  62020. */
  62021. remainingCount: number;
  62022. /**
  62023. * Defines the total number of tasks
  62024. */
  62025. totalCount: number;
  62026. /**
  62027. * Defines the task that was just processed
  62028. */
  62029. task: AbstractAssetTask;
  62030. /**
  62031. * Creates a AssetsProgressEvent
  62032. * @param remainingCount defines the number of remaining tasks to process
  62033. * @param totalCount defines the total number of tasks
  62034. * @param task defines the task that was just processed
  62035. */
  62036. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62037. }
  62038. /**
  62039. * Define a task used by AssetsManager to load meshes
  62040. */
  62041. export class MeshAssetTask extends AbstractAssetTask {
  62042. /**
  62043. * Defines the name of the task
  62044. */
  62045. name: string;
  62046. /**
  62047. * Defines the list of mesh's names you want to load
  62048. */
  62049. meshesNames: any;
  62050. /**
  62051. * Defines the root url to use as a base to load your meshes and associated resources
  62052. */
  62053. rootUrl: string;
  62054. /**
  62055. * Defines the filename of the scene to load from
  62056. */
  62057. sceneFilename: string;
  62058. /**
  62059. * Gets the list of loaded meshes
  62060. */
  62061. loadedMeshes: Array<AbstractMesh>;
  62062. /**
  62063. * Gets the list of loaded particle systems
  62064. */
  62065. loadedParticleSystems: Array<IParticleSystem>;
  62066. /**
  62067. * Gets the list of loaded skeletons
  62068. */
  62069. loadedSkeletons: Array<Skeleton>;
  62070. /**
  62071. * Gets the list of loaded animation groups
  62072. */
  62073. loadedAnimationGroups: Array<AnimationGroup>;
  62074. /**
  62075. * Callback called when the task is successful
  62076. */
  62077. onSuccess: (task: MeshAssetTask) => void;
  62078. /**
  62079. * Callback called when the task is successful
  62080. */
  62081. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62082. /**
  62083. * Creates a new MeshAssetTask
  62084. * @param name defines the name of the task
  62085. * @param meshesNames defines the list of mesh's names you want to load
  62086. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62087. * @param sceneFilename defines the filename of the scene to load from
  62088. */
  62089. constructor(
  62090. /**
  62091. * Defines the name of the task
  62092. */
  62093. name: string,
  62094. /**
  62095. * Defines the list of mesh's names you want to load
  62096. */
  62097. meshesNames: any,
  62098. /**
  62099. * Defines the root url to use as a base to load your meshes and associated resources
  62100. */
  62101. rootUrl: string,
  62102. /**
  62103. * Defines the filename of the scene to load from
  62104. */
  62105. sceneFilename: string);
  62106. /**
  62107. * Execute the current task
  62108. * @param scene defines the scene where you want your assets to be loaded
  62109. * @param onSuccess is a callback called when the task is successfully executed
  62110. * @param onError is a callback called if an error occurs
  62111. */
  62112. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62113. }
  62114. /**
  62115. * Define a task used by AssetsManager to load text content
  62116. */
  62117. export class TextFileAssetTask extends AbstractAssetTask {
  62118. /**
  62119. * Defines the name of the task
  62120. */
  62121. name: string;
  62122. /**
  62123. * Defines the location of the file to load
  62124. */
  62125. url: string;
  62126. /**
  62127. * Gets the loaded text string
  62128. */
  62129. text: string;
  62130. /**
  62131. * Callback called when the task is successful
  62132. */
  62133. onSuccess: (task: TextFileAssetTask) => void;
  62134. /**
  62135. * Callback called when the task is successful
  62136. */
  62137. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62138. /**
  62139. * Creates a new TextFileAssetTask object
  62140. * @param name defines the name of the task
  62141. * @param url defines the location of the file to load
  62142. */
  62143. constructor(
  62144. /**
  62145. * Defines the name of the task
  62146. */
  62147. name: string,
  62148. /**
  62149. * Defines the location of the file to load
  62150. */
  62151. url: string);
  62152. /**
  62153. * Execute the current task
  62154. * @param scene defines the scene where you want your assets to be loaded
  62155. * @param onSuccess is a callback called when the task is successfully executed
  62156. * @param onError is a callback called if an error occurs
  62157. */
  62158. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62159. }
  62160. /**
  62161. * Define a task used by AssetsManager to load binary data
  62162. */
  62163. export class BinaryFileAssetTask extends AbstractAssetTask {
  62164. /**
  62165. * Defines the name of the task
  62166. */
  62167. name: string;
  62168. /**
  62169. * Defines the location of the file to load
  62170. */
  62171. url: string;
  62172. /**
  62173. * Gets the lodaded data (as an array buffer)
  62174. */
  62175. data: ArrayBuffer;
  62176. /**
  62177. * Callback called when the task is successful
  62178. */
  62179. onSuccess: (task: BinaryFileAssetTask) => void;
  62180. /**
  62181. * Callback called when the task is successful
  62182. */
  62183. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62184. /**
  62185. * Creates a new BinaryFileAssetTask object
  62186. * @param name defines the name of the new task
  62187. * @param url defines the location of the file to load
  62188. */
  62189. constructor(
  62190. /**
  62191. * Defines the name of the task
  62192. */
  62193. name: string,
  62194. /**
  62195. * Defines the location of the file to load
  62196. */
  62197. url: string);
  62198. /**
  62199. * Execute the current task
  62200. * @param scene defines the scene where you want your assets to be loaded
  62201. * @param onSuccess is a callback called when the task is successfully executed
  62202. * @param onError is a callback called if an error occurs
  62203. */
  62204. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62205. }
  62206. /**
  62207. * Define a task used by AssetsManager to load images
  62208. */
  62209. export class ImageAssetTask extends AbstractAssetTask {
  62210. /**
  62211. * Defines the name of the task
  62212. */
  62213. name: string;
  62214. /**
  62215. * Defines the location of the image to load
  62216. */
  62217. url: string;
  62218. /**
  62219. * Gets the loaded images
  62220. */
  62221. image: HTMLImageElement;
  62222. /**
  62223. * Callback called when the task is successful
  62224. */
  62225. onSuccess: (task: ImageAssetTask) => void;
  62226. /**
  62227. * Callback called when the task is successful
  62228. */
  62229. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62230. /**
  62231. * Creates a new ImageAssetTask
  62232. * @param name defines the name of the task
  62233. * @param url defines the location of the image to load
  62234. */
  62235. constructor(
  62236. /**
  62237. * Defines the name of the task
  62238. */
  62239. name: string,
  62240. /**
  62241. * Defines the location of the image to load
  62242. */
  62243. url: string);
  62244. /**
  62245. * Execute the current task
  62246. * @param scene defines the scene where you want your assets to be loaded
  62247. * @param onSuccess is a callback called when the task is successfully executed
  62248. * @param onError is a callback called if an error occurs
  62249. */
  62250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62251. }
  62252. /**
  62253. * Defines the interface used by texture loading tasks
  62254. */
  62255. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62256. /**
  62257. * Gets the loaded texture
  62258. */
  62259. texture: TEX;
  62260. }
  62261. /**
  62262. * Define a task used by AssetsManager to load 2D textures
  62263. */
  62264. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62265. /**
  62266. * Defines the name of the task
  62267. */
  62268. name: string;
  62269. /**
  62270. * Defines the location of the file to load
  62271. */
  62272. url: string;
  62273. /**
  62274. * Defines if mipmap should not be generated (default is false)
  62275. */
  62276. noMipmap?: boolean | undefined;
  62277. /**
  62278. * Defines if texture must be inverted on Y axis (default is false)
  62279. */
  62280. invertY?: boolean | undefined;
  62281. /**
  62282. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62283. */
  62284. samplingMode: number;
  62285. /**
  62286. * Gets the loaded texture
  62287. */
  62288. texture: Texture;
  62289. /**
  62290. * Callback called when the task is successful
  62291. */
  62292. onSuccess: (task: TextureAssetTask) => void;
  62293. /**
  62294. * Callback called when the task is successful
  62295. */
  62296. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62297. /**
  62298. * Creates a new TextureAssetTask object
  62299. * @param name defines the name of the task
  62300. * @param url defines the location of the file to load
  62301. * @param noMipmap defines if mipmap should not be generated (default is false)
  62302. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62303. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62304. */
  62305. constructor(
  62306. /**
  62307. * Defines the name of the task
  62308. */
  62309. name: string,
  62310. /**
  62311. * Defines the location of the file to load
  62312. */
  62313. url: string,
  62314. /**
  62315. * Defines if mipmap should not be generated (default is false)
  62316. */
  62317. noMipmap?: boolean | undefined,
  62318. /**
  62319. * Defines if texture must be inverted on Y axis (default is false)
  62320. */
  62321. invertY?: boolean | undefined,
  62322. /**
  62323. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62324. */
  62325. samplingMode?: number);
  62326. /**
  62327. * Execute the current task
  62328. * @param scene defines the scene where you want your assets to be loaded
  62329. * @param onSuccess is a callback called when the task is successfully executed
  62330. * @param onError is a callback called if an error occurs
  62331. */
  62332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62333. }
  62334. /**
  62335. * Define a task used by AssetsManager to load cube textures
  62336. */
  62337. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62338. /**
  62339. * Defines the name of the task
  62340. */
  62341. name: string;
  62342. /**
  62343. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62344. */
  62345. url: string;
  62346. /**
  62347. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62348. */
  62349. extensions?: string[] | undefined;
  62350. /**
  62351. * Defines if mipmaps should not be generated (default is false)
  62352. */
  62353. noMipmap?: boolean | undefined;
  62354. /**
  62355. * Defines the explicit list of files (undefined by default)
  62356. */
  62357. files?: string[] | undefined;
  62358. /**
  62359. * Gets the loaded texture
  62360. */
  62361. texture: CubeTexture;
  62362. /**
  62363. * Callback called when the task is successful
  62364. */
  62365. onSuccess: (task: CubeTextureAssetTask) => void;
  62366. /**
  62367. * Callback called when the task is successful
  62368. */
  62369. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62370. /**
  62371. * Creates a new CubeTextureAssetTask
  62372. * @param name defines the name of the task
  62373. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62374. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62375. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62376. * @param files defines the explicit list of files (undefined by default)
  62377. */
  62378. constructor(
  62379. /**
  62380. * Defines the name of the task
  62381. */
  62382. name: string,
  62383. /**
  62384. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62385. */
  62386. url: string,
  62387. /**
  62388. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62389. */
  62390. extensions?: string[] | undefined,
  62391. /**
  62392. * Defines if mipmaps should not be generated (default is false)
  62393. */
  62394. noMipmap?: boolean | undefined,
  62395. /**
  62396. * Defines the explicit list of files (undefined by default)
  62397. */
  62398. files?: string[] | undefined);
  62399. /**
  62400. * Execute the current task
  62401. * @param scene defines the scene where you want your assets to be loaded
  62402. * @param onSuccess is a callback called when the task is successfully executed
  62403. * @param onError is a callback called if an error occurs
  62404. */
  62405. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62406. }
  62407. /**
  62408. * Define a task used by AssetsManager to load HDR cube textures
  62409. */
  62410. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62411. /**
  62412. * Defines the name of the task
  62413. */
  62414. name: string;
  62415. /**
  62416. * Defines the location of the file to load
  62417. */
  62418. url: string;
  62419. /**
  62420. * Defines the desired size (the more it increases the longer the generation will be)
  62421. */
  62422. size: number;
  62423. /**
  62424. * Defines if mipmaps should not be generated (default is false)
  62425. */
  62426. noMipmap: boolean;
  62427. /**
  62428. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62429. */
  62430. generateHarmonics: boolean;
  62431. /**
  62432. * 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)
  62433. */
  62434. gammaSpace: boolean;
  62435. /**
  62436. * Internal Use Only
  62437. */
  62438. reserved: boolean;
  62439. /**
  62440. * Gets the loaded texture
  62441. */
  62442. texture: HDRCubeTexture;
  62443. /**
  62444. * Callback called when the task is successful
  62445. */
  62446. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62447. /**
  62448. * Callback called when the task is successful
  62449. */
  62450. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62451. /**
  62452. * Creates a new HDRCubeTextureAssetTask object
  62453. * @param name defines the name of the task
  62454. * @param url defines the location of the file to load
  62455. * @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.
  62456. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62457. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62458. * @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)
  62459. * @param reserved Internal use only
  62460. */
  62461. constructor(
  62462. /**
  62463. * Defines the name of the task
  62464. */
  62465. name: string,
  62466. /**
  62467. * Defines the location of the file to load
  62468. */
  62469. url: string,
  62470. /**
  62471. * Defines the desired size (the more it increases the longer the generation will be)
  62472. */
  62473. size: number,
  62474. /**
  62475. * Defines if mipmaps should not be generated (default is false)
  62476. */
  62477. noMipmap?: boolean,
  62478. /**
  62479. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62480. */
  62481. generateHarmonics?: boolean,
  62482. /**
  62483. * 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)
  62484. */
  62485. gammaSpace?: boolean,
  62486. /**
  62487. * Internal Use Only
  62488. */
  62489. reserved?: boolean);
  62490. /**
  62491. * Execute the current task
  62492. * @param scene defines the scene where you want your assets to be loaded
  62493. * @param onSuccess is a callback called when the task is successfully executed
  62494. * @param onError is a callback called if an error occurs
  62495. */
  62496. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62497. }
  62498. /**
  62499. * Define a task used by AssetsManager to load Equirectangular cube textures
  62500. */
  62501. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62502. /**
  62503. * Defines the name of the task
  62504. */
  62505. name: string;
  62506. /**
  62507. * Defines the location of the file to load
  62508. */
  62509. url: string;
  62510. /**
  62511. * Defines the desired size (the more it increases the longer the generation will be)
  62512. */
  62513. size: number;
  62514. /**
  62515. * Defines if mipmaps should not be generated (default is false)
  62516. */
  62517. noMipmap: boolean;
  62518. /**
  62519. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62520. * but the standard material would require them in Gamma space) (default is true)
  62521. */
  62522. gammaSpace: boolean;
  62523. /**
  62524. * Gets the loaded texture
  62525. */
  62526. texture: EquiRectangularCubeTexture;
  62527. /**
  62528. * Callback called when the task is successful
  62529. */
  62530. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62531. /**
  62532. * Callback called when the task is successful
  62533. */
  62534. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62535. /**
  62536. * Creates a new EquiRectangularCubeTextureAssetTask object
  62537. * @param name defines the name of the task
  62538. * @param url defines the location of the file to load
  62539. * @param size defines the desired size (the more it increases the longer the generation will be)
  62540. * If the size is omitted this implies you are using a preprocessed cubemap.
  62541. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62542. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62543. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62544. * (default is true)
  62545. */
  62546. constructor(
  62547. /**
  62548. * Defines the name of the task
  62549. */
  62550. name: string,
  62551. /**
  62552. * Defines the location of the file to load
  62553. */
  62554. url: string,
  62555. /**
  62556. * Defines the desired size (the more it increases the longer the generation will be)
  62557. */
  62558. size: number,
  62559. /**
  62560. * Defines if mipmaps should not be generated (default is false)
  62561. */
  62562. noMipmap?: boolean,
  62563. /**
  62564. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62565. * but the standard material would require them in Gamma space) (default is true)
  62566. */
  62567. gammaSpace?: boolean);
  62568. /**
  62569. * Execute the current task
  62570. * @param scene defines the scene where you want your assets to be loaded
  62571. * @param onSuccess is a callback called when the task is successfully executed
  62572. * @param onError is a callback called if an error occurs
  62573. */
  62574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62575. }
  62576. /**
  62577. * This class can be used to easily import assets into a scene
  62578. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62579. */
  62580. export class AssetsManager {
  62581. private _scene;
  62582. private _isLoading;
  62583. protected _tasks: AbstractAssetTask[];
  62584. protected _waitingTasksCount: number;
  62585. protected _totalTasksCount: number;
  62586. /**
  62587. * Callback called when all tasks are processed
  62588. */
  62589. onFinish: (tasks: AbstractAssetTask[]) => void;
  62590. /**
  62591. * Callback called when a task is successful
  62592. */
  62593. onTaskSuccess: (task: AbstractAssetTask) => void;
  62594. /**
  62595. * Callback called when a task had an error
  62596. */
  62597. onTaskError: (task: AbstractAssetTask) => void;
  62598. /**
  62599. * Callback called when a task is done (whatever the result is)
  62600. */
  62601. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62602. /**
  62603. * Observable called when all tasks are processed
  62604. */
  62605. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62606. /**
  62607. * Observable called when a task had an error
  62608. */
  62609. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62610. /**
  62611. * Observable called when all tasks were executed
  62612. */
  62613. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62614. /**
  62615. * Observable called when a task is done (whatever the result is)
  62616. */
  62617. onProgressObservable: Observable<IAssetsProgressEvent>;
  62618. /**
  62619. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62620. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62621. */
  62622. useDefaultLoadingScreen: boolean;
  62623. /**
  62624. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62625. * when all assets have been downloaded.
  62626. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62627. */
  62628. autoHideLoadingUI: boolean;
  62629. /**
  62630. * Creates a new AssetsManager
  62631. * @param scene defines the scene to work on
  62632. */
  62633. constructor(scene: Scene);
  62634. /**
  62635. * Add a MeshAssetTask to the list of active tasks
  62636. * @param taskName defines the name of the new task
  62637. * @param meshesNames defines the name of meshes to load
  62638. * @param rootUrl defines the root url to use to locate files
  62639. * @param sceneFilename defines the filename of the scene file
  62640. * @returns a new MeshAssetTask object
  62641. */
  62642. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62643. /**
  62644. * Add a TextFileAssetTask to the list of active tasks
  62645. * @param taskName defines the name of the new task
  62646. * @param url defines the url of the file to load
  62647. * @returns a new TextFileAssetTask object
  62648. */
  62649. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62650. /**
  62651. * Add a BinaryFileAssetTask to the list of active tasks
  62652. * @param taskName defines the name of the new task
  62653. * @param url defines the url of the file to load
  62654. * @returns a new BinaryFileAssetTask object
  62655. */
  62656. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62657. /**
  62658. * Add a ImageAssetTask to the list of active tasks
  62659. * @param taskName defines the name of the new task
  62660. * @param url defines the url of the file to load
  62661. * @returns a new ImageAssetTask object
  62662. */
  62663. addImageTask(taskName: string, url: string): ImageAssetTask;
  62664. /**
  62665. * Add a TextureAssetTask to the list of active tasks
  62666. * @param taskName defines the name of the new task
  62667. * @param url defines the url of the file to load
  62668. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62669. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62670. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62671. * @returns a new TextureAssetTask object
  62672. */
  62673. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62674. /**
  62675. * Add a CubeTextureAssetTask to the list of active tasks
  62676. * @param taskName defines the name of the new task
  62677. * @param url defines the url of the file to load
  62678. * @param extensions defines the extension to use to load the cube map (can be null)
  62679. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62680. * @param files defines the list of files to load (can be null)
  62681. * @returns a new CubeTextureAssetTask object
  62682. */
  62683. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62684. /**
  62685. *
  62686. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62687. * @param taskName defines the name of the new task
  62688. * @param url defines the url of the file to load
  62689. * @param size defines the size you want for the cubemap (can be null)
  62690. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62691. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62692. * @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)
  62693. * @param reserved Internal use only
  62694. * @returns a new HDRCubeTextureAssetTask object
  62695. */
  62696. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62697. /**
  62698. *
  62699. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62700. * @param taskName defines the name of the new task
  62701. * @param url defines the url of the file to load
  62702. * @param size defines the size you want for the cubemap (can be null)
  62703. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62704. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62705. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62706. * @returns a new EquiRectangularCubeTextureAssetTask object
  62707. */
  62708. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62709. /**
  62710. * Remove a task from the assets manager.
  62711. * @param task the task to remove
  62712. */
  62713. removeTask(task: AbstractAssetTask): void;
  62714. private _decreaseWaitingTasksCount;
  62715. private _runTask;
  62716. /**
  62717. * Reset the AssetsManager and remove all tasks
  62718. * @return the current instance of the AssetsManager
  62719. */
  62720. reset(): AssetsManager;
  62721. /**
  62722. * Start the loading process
  62723. * @return the current instance of the AssetsManager
  62724. */
  62725. load(): AssetsManager;
  62726. /**
  62727. * Start the loading process as an async operation
  62728. * @return a promise returning the list of failed tasks
  62729. */
  62730. loadAsync(): Promise<void>;
  62731. }
  62732. }
  62733. declare module "babylonjs/Misc/deferred" {
  62734. /**
  62735. * Wrapper class for promise with external resolve and reject.
  62736. */
  62737. export class Deferred<T> {
  62738. /**
  62739. * The promise associated with this deferred object.
  62740. */
  62741. readonly promise: Promise<T>;
  62742. private _resolve;
  62743. private _reject;
  62744. /**
  62745. * The resolve method of the promise associated with this deferred object.
  62746. */
  62747. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62748. /**
  62749. * The reject method of the promise associated with this deferred object.
  62750. */
  62751. readonly reject: (reason?: any) => void;
  62752. /**
  62753. * Constructor for this deferred object.
  62754. */
  62755. constructor();
  62756. }
  62757. }
  62758. declare module "babylonjs/Misc/meshExploder" {
  62759. import { Mesh } from "babylonjs/Meshes/mesh";
  62760. /**
  62761. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62762. */
  62763. export class MeshExploder {
  62764. private _centerMesh;
  62765. private _meshes;
  62766. private _meshesOrigins;
  62767. private _toCenterVectors;
  62768. private _scaledDirection;
  62769. private _newPosition;
  62770. private _centerPosition;
  62771. /**
  62772. * Explodes meshes from a center mesh.
  62773. * @param meshes The meshes to explode.
  62774. * @param centerMesh The mesh to be center of explosion.
  62775. */
  62776. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62777. private _setCenterMesh;
  62778. /**
  62779. * Get class name
  62780. * @returns "MeshExploder"
  62781. */
  62782. getClassName(): string;
  62783. /**
  62784. * "Exploded meshes"
  62785. * @returns Array of meshes with the centerMesh at index 0.
  62786. */
  62787. getMeshes(): Array<Mesh>;
  62788. /**
  62789. * Explodes meshes giving a specific direction
  62790. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62791. */
  62792. explode(direction?: number): void;
  62793. }
  62794. }
  62795. declare module "babylonjs/Misc/filesInput" {
  62796. import { Engine } from "babylonjs/Engines/engine";
  62797. import { Scene } from "babylonjs/scene";
  62798. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  62799. /**
  62800. * Class used to help managing file picking and drag'n'drop
  62801. */
  62802. export class FilesInput {
  62803. /**
  62804. * List of files ready to be loaded
  62805. */
  62806. static readonly FilesToLoad: {
  62807. [key: string]: File;
  62808. };
  62809. /**
  62810. * Callback called when a file is processed
  62811. */
  62812. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62813. private _engine;
  62814. private _currentScene;
  62815. private _sceneLoadedCallback;
  62816. private _progressCallback;
  62817. private _additionalRenderLoopLogicCallback;
  62818. private _textureLoadingCallback;
  62819. private _startingProcessingFilesCallback;
  62820. private _onReloadCallback;
  62821. private _errorCallback;
  62822. private _elementToMonitor;
  62823. private _sceneFileToLoad;
  62824. private _filesToLoad;
  62825. /**
  62826. * Creates a new FilesInput
  62827. * @param engine defines the rendering engine
  62828. * @param scene defines the hosting scene
  62829. * @param sceneLoadedCallback callback called when scene is loaded
  62830. * @param progressCallback callback called to track progress
  62831. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62832. * @param textureLoadingCallback callback called when a texture is loading
  62833. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62834. * @param onReloadCallback callback called when a reload is requested
  62835. * @param errorCallback callback call if an error occurs
  62836. */
  62837. 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);
  62838. private _dragEnterHandler;
  62839. private _dragOverHandler;
  62840. private _dropHandler;
  62841. /**
  62842. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62843. * @param elementToMonitor defines the DOM element to track
  62844. */
  62845. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62846. /**
  62847. * Release all associated resources
  62848. */
  62849. dispose(): void;
  62850. private renderFunction;
  62851. private drag;
  62852. private drop;
  62853. private _traverseFolder;
  62854. private _processFiles;
  62855. /**
  62856. * Load files from a drop event
  62857. * @param event defines the drop event to use as source
  62858. */
  62859. loadFiles(event: any): void;
  62860. private _processReload;
  62861. /**
  62862. * Reload the current scene from the loaded files
  62863. */
  62864. reload(): void;
  62865. }
  62866. }
  62867. declare module "babylonjs/Misc/HighDynamicRange/index" {
  62868. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  62869. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  62870. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62871. }
  62872. declare module "babylonjs/Misc/sceneOptimizer" {
  62873. import { Scene, IDisposable } from "babylonjs/scene";
  62874. import { Observable } from "babylonjs/Misc/observable";
  62875. /**
  62876. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62878. */
  62879. export class SceneOptimization {
  62880. /**
  62881. * Defines the priority of this optimization (0 by default which means first in the list)
  62882. */
  62883. priority: number;
  62884. /**
  62885. * Gets a string describing the action executed by the current optimization
  62886. * @returns description string
  62887. */
  62888. getDescription(): string;
  62889. /**
  62890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62891. * @param scene defines the current scene where to apply this optimization
  62892. * @param optimizer defines the current optimizer
  62893. * @returns true if everything that can be done was applied
  62894. */
  62895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62896. /**
  62897. * Creates the SceneOptimization object
  62898. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62899. * @param desc defines the description associated with the optimization
  62900. */
  62901. constructor(
  62902. /**
  62903. * Defines the priority of this optimization (0 by default which means first in the list)
  62904. */
  62905. priority?: number);
  62906. }
  62907. /**
  62908. * Defines an optimization used to reduce the size of render target textures
  62909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62910. */
  62911. export class TextureOptimization extends SceneOptimization {
  62912. /**
  62913. * Defines the priority of this optimization (0 by default which means first in the list)
  62914. */
  62915. priority: number;
  62916. /**
  62917. * 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
  62918. */
  62919. maximumSize: number;
  62920. /**
  62921. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62922. */
  62923. step: number;
  62924. /**
  62925. * Gets a string describing the action executed by the current optimization
  62926. * @returns description string
  62927. */
  62928. getDescription(): string;
  62929. /**
  62930. * Creates the TextureOptimization object
  62931. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62932. * @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
  62933. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62934. */
  62935. constructor(
  62936. /**
  62937. * Defines the priority of this optimization (0 by default which means first in the list)
  62938. */
  62939. priority?: number,
  62940. /**
  62941. * 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
  62942. */
  62943. maximumSize?: number,
  62944. /**
  62945. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62946. */
  62947. step?: number);
  62948. /**
  62949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62950. * @param scene defines the current scene where to apply this optimization
  62951. * @param optimizer defines the current optimizer
  62952. * @returns true if everything that can be done was applied
  62953. */
  62954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62955. }
  62956. /**
  62957. * Defines an optimization used to increase or decrease the rendering resolution
  62958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62959. */
  62960. export class HardwareScalingOptimization extends SceneOptimization {
  62961. /**
  62962. * Defines the priority of this optimization (0 by default which means first in the list)
  62963. */
  62964. priority: number;
  62965. /**
  62966. * Defines the maximum scale to use (2 by default)
  62967. */
  62968. maximumScale: number;
  62969. /**
  62970. * Defines the step to use between two passes (0.5 by default)
  62971. */
  62972. step: number;
  62973. private _currentScale;
  62974. private _directionOffset;
  62975. /**
  62976. * Gets a string describing the action executed by the current optimization
  62977. * @return description string
  62978. */
  62979. getDescription(): string;
  62980. /**
  62981. * Creates the HardwareScalingOptimization object
  62982. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62983. * @param maximumScale defines the maximum scale to use (2 by default)
  62984. * @param step defines the step to use between two passes (0.5 by default)
  62985. */
  62986. constructor(
  62987. /**
  62988. * Defines the priority of this optimization (0 by default which means first in the list)
  62989. */
  62990. priority?: number,
  62991. /**
  62992. * Defines the maximum scale to use (2 by default)
  62993. */
  62994. maximumScale?: number,
  62995. /**
  62996. * Defines the step to use between two passes (0.5 by default)
  62997. */
  62998. step?: number);
  62999. /**
  63000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63001. * @param scene defines the current scene where to apply this optimization
  63002. * @param optimizer defines the current optimizer
  63003. * @returns true if everything that can be done was applied
  63004. */
  63005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63006. }
  63007. /**
  63008. * Defines an optimization used to remove shadows
  63009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63010. */
  63011. export class ShadowsOptimization extends SceneOptimization {
  63012. /**
  63013. * Gets a string describing the action executed by the current optimization
  63014. * @return description string
  63015. */
  63016. getDescription(): string;
  63017. /**
  63018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63019. * @param scene defines the current scene where to apply this optimization
  63020. * @param optimizer defines the current optimizer
  63021. * @returns true if everything that can be done was applied
  63022. */
  63023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63024. }
  63025. /**
  63026. * Defines an optimization used to turn post-processes off
  63027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63028. */
  63029. export class PostProcessesOptimization extends SceneOptimization {
  63030. /**
  63031. * Gets a string describing the action executed by the current optimization
  63032. * @return description string
  63033. */
  63034. getDescription(): string;
  63035. /**
  63036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63037. * @param scene defines the current scene where to apply this optimization
  63038. * @param optimizer defines the current optimizer
  63039. * @returns true if everything that can be done was applied
  63040. */
  63041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63042. }
  63043. /**
  63044. * Defines an optimization used to turn lens flares off
  63045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63046. */
  63047. export class LensFlaresOptimization extends SceneOptimization {
  63048. /**
  63049. * Gets a string describing the action executed by the current optimization
  63050. * @return description string
  63051. */
  63052. getDescription(): string;
  63053. /**
  63054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63055. * @param scene defines the current scene where to apply this optimization
  63056. * @param optimizer defines the current optimizer
  63057. * @returns true if everything that can be done was applied
  63058. */
  63059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63060. }
  63061. /**
  63062. * Defines an optimization based on user defined callback.
  63063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63064. */
  63065. export class CustomOptimization extends SceneOptimization {
  63066. /**
  63067. * Callback called to apply the custom optimization.
  63068. */
  63069. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63070. /**
  63071. * Callback called to get custom description
  63072. */
  63073. onGetDescription: () => string;
  63074. /**
  63075. * Gets a string describing the action executed by the current optimization
  63076. * @returns description string
  63077. */
  63078. getDescription(): string;
  63079. /**
  63080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63081. * @param scene defines the current scene where to apply this optimization
  63082. * @param optimizer defines the current optimizer
  63083. * @returns true if everything that can be done was applied
  63084. */
  63085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63086. }
  63087. /**
  63088. * Defines an optimization used to turn particles off
  63089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63090. */
  63091. export class ParticlesOptimization extends SceneOptimization {
  63092. /**
  63093. * Gets a string describing the action executed by the current optimization
  63094. * @return description string
  63095. */
  63096. getDescription(): string;
  63097. /**
  63098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63099. * @param scene defines the current scene where to apply this optimization
  63100. * @param optimizer defines the current optimizer
  63101. * @returns true if everything that can be done was applied
  63102. */
  63103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63104. }
  63105. /**
  63106. * Defines an optimization used to turn render targets off
  63107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63108. */
  63109. export class RenderTargetsOptimization extends SceneOptimization {
  63110. /**
  63111. * Gets a string describing the action executed by the current optimization
  63112. * @return description string
  63113. */
  63114. getDescription(): string;
  63115. /**
  63116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63117. * @param scene defines the current scene where to apply this optimization
  63118. * @param optimizer defines the current optimizer
  63119. * @returns true if everything that can be done was applied
  63120. */
  63121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63122. }
  63123. /**
  63124. * Defines an optimization used to merge meshes with compatible materials
  63125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63126. */
  63127. export class MergeMeshesOptimization extends SceneOptimization {
  63128. private static _UpdateSelectionTree;
  63129. /**
  63130. * Gets or sets a boolean which defines if optimization octree has to be updated
  63131. */
  63132. /**
  63133. * Gets or sets a boolean which defines if optimization octree has to be updated
  63134. */
  63135. static UpdateSelectionTree: boolean;
  63136. /**
  63137. * Gets a string describing the action executed by the current optimization
  63138. * @return description string
  63139. */
  63140. getDescription(): string;
  63141. private _canBeMerged;
  63142. /**
  63143. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63144. * @param scene defines the current scene where to apply this optimization
  63145. * @param optimizer defines the current optimizer
  63146. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63147. * @returns true if everything that can be done was applied
  63148. */
  63149. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63150. }
  63151. /**
  63152. * Defines a list of options used by SceneOptimizer
  63153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63154. */
  63155. export class SceneOptimizerOptions {
  63156. /**
  63157. * Defines the target frame rate to reach (60 by default)
  63158. */
  63159. targetFrameRate: number;
  63160. /**
  63161. * Defines the interval between two checkes (2000ms by default)
  63162. */
  63163. trackerDuration: number;
  63164. /**
  63165. * Gets the list of optimizations to apply
  63166. */
  63167. optimizations: SceneOptimization[];
  63168. /**
  63169. * Creates a new list of options used by SceneOptimizer
  63170. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63171. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63172. */
  63173. constructor(
  63174. /**
  63175. * Defines the target frame rate to reach (60 by default)
  63176. */
  63177. targetFrameRate?: number,
  63178. /**
  63179. * Defines the interval between two checkes (2000ms by default)
  63180. */
  63181. trackerDuration?: number);
  63182. /**
  63183. * Add a new optimization
  63184. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63185. * @returns the current SceneOptimizerOptions
  63186. */
  63187. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63188. /**
  63189. * Add a new custom optimization
  63190. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63191. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63192. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63193. * @returns the current SceneOptimizerOptions
  63194. */
  63195. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63196. /**
  63197. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63198. * @param targetFrameRate defines the target frame rate (60 by default)
  63199. * @returns a SceneOptimizerOptions object
  63200. */
  63201. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63202. /**
  63203. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63204. * @param targetFrameRate defines the target frame rate (60 by default)
  63205. * @returns a SceneOptimizerOptions object
  63206. */
  63207. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63208. /**
  63209. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63210. * @param targetFrameRate defines the target frame rate (60 by default)
  63211. * @returns a SceneOptimizerOptions object
  63212. */
  63213. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63214. }
  63215. /**
  63216. * Class used to run optimizations in order to reach a target frame rate
  63217. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63218. */
  63219. export class SceneOptimizer implements IDisposable {
  63220. private _isRunning;
  63221. private _options;
  63222. private _scene;
  63223. private _currentPriorityLevel;
  63224. private _targetFrameRate;
  63225. private _trackerDuration;
  63226. private _currentFrameRate;
  63227. private _sceneDisposeObserver;
  63228. private _improvementMode;
  63229. /**
  63230. * Defines an observable called when the optimizer reaches the target frame rate
  63231. */
  63232. onSuccessObservable: Observable<SceneOptimizer>;
  63233. /**
  63234. * Defines an observable called when the optimizer enables an optimization
  63235. */
  63236. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63237. /**
  63238. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63239. */
  63240. onFailureObservable: Observable<SceneOptimizer>;
  63241. /**
  63242. * Gets a boolean indicating if the optimizer is in improvement mode
  63243. */
  63244. readonly isInImprovementMode: boolean;
  63245. /**
  63246. * Gets the current priority level (0 at start)
  63247. */
  63248. readonly currentPriorityLevel: number;
  63249. /**
  63250. * Gets the current frame rate checked by the SceneOptimizer
  63251. */
  63252. readonly currentFrameRate: number;
  63253. /**
  63254. * Gets or sets the current target frame rate (60 by default)
  63255. */
  63256. /**
  63257. * Gets or sets the current target frame rate (60 by default)
  63258. */
  63259. targetFrameRate: number;
  63260. /**
  63261. * Gets or sets the current interval between two checks (every 2000ms by default)
  63262. */
  63263. /**
  63264. * Gets or sets the current interval between two checks (every 2000ms by default)
  63265. */
  63266. trackerDuration: number;
  63267. /**
  63268. * Gets the list of active optimizations
  63269. */
  63270. readonly optimizations: SceneOptimization[];
  63271. /**
  63272. * Creates a new SceneOptimizer
  63273. * @param scene defines the scene to work on
  63274. * @param options defines the options to use with the SceneOptimizer
  63275. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63276. * @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)
  63277. */
  63278. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63279. /**
  63280. * Stops the current optimizer
  63281. */
  63282. stop(): void;
  63283. /**
  63284. * Reset the optimizer to initial step (current priority level = 0)
  63285. */
  63286. reset(): void;
  63287. /**
  63288. * Start the optimizer. By default it will try to reach a specific framerate
  63289. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63290. */
  63291. start(): void;
  63292. private _checkCurrentState;
  63293. /**
  63294. * Release all resources
  63295. */
  63296. dispose(): void;
  63297. /**
  63298. * Helper function to create a SceneOptimizer with one single line of code
  63299. * @param scene defines the scene to work on
  63300. * @param options defines the options to use with the SceneOptimizer
  63301. * @param onSuccess defines a callback to call on success
  63302. * @param onFailure defines a callback to call on failure
  63303. * @returns the new SceneOptimizer object
  63304. */
  63305. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63306. }
  63307. }
  63308. declare module "babylonjs/Misc/sceneSerializer" {
  63309. import { Scene } from "babylonjs/scene";
  63310. /**
  63311. * Class used to serialize a scene into a string
  63312. */
  63313. export class SceneSerializer {
  63314. /**
  63315. * Clear cache used by a previous serialization
  63316. */
  63317. static ClearCache(): void;
  63318. /**
  63319. * Serialize a scene into a JSON compatible object
  63320. * @param scene defines the scene to serialize
  63321. * @returns a JSON compatible object
  63322. */
  63323. static Serialize(scene: Scene): any;
  63324. /**
  63325. * Serialize a mesh into a JSON compatible object
  63326. * @param toSerialize defines the mesh to serialize
  63327. * @param withParents defines if parents must be serialized as well
  63328. * @param withChildren defines if children must be serialized as well
  63329. * @returns a JSON compatible object
  63330. */
  63331. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63332. }
  63333. }
  63334. declare module "babylonjs/Misc/textureTools" {
  63335. import { Texture } from "babylonjs/Materials/Textures/texture";
  63336. /**
  63337. * Class used to host texture specific utilities
  63338. */
  63339. export class TextureTools {
  63340. /**
  63341. * Uses the GPU to create a copy texture rescaled at a given size
  63342. * @param texture Texture to copy from
  63343. * @param width defines the desired width
  63344. * @param height defines the desired height
  63345. * @param useBilinearMode defines if bilinear mode has to be used
  63346. * @return the generated texture
  63347. */
  63348. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63349. }
  63350. }
  63351. declare module "babylonjs/Misc/videoRecorder" {
  63352. import { Nullable } from "babylonjs/types";
  63353. import { Engine } from "babylonjs/Engines/engine";
  63354. /**
  63355. * This represents the different options available for the video capture.
  63356. */
  63357. export interface VideoRecorderOptions {
  63358. /** Defines the mime type of the video. */
  63359. mimeType: string;
  63360. /** Defines the FPS the video should be recorded at. */
  63361. fps: number;
  63362. /** Defines the chunk size for the recording data. */
  63363. recordChunckSize: number;
  63364. /** The audio tracks to attach to the recording. */
  63365. audioTracks?: MediaStreamTrack[];
  63366. }
  63367. /**
  63368. * This can help with recording videos from BabylonJS.
  63369. * This is based on the available WebRTC functionalities of the browser.
  63370. *
  63371. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63372. */
  63373. export class VideoRecorder {
  63374. private static readonly _defaultOptions;
  63375. /**
  63376. * Returns whether or not the VideoRecorder is available in your browser.
  63377. * @param engine Defines the Babylon Engine.
  63378. * @returns true if supported otherwise false.
  63379. */
  63380. static IsSupported(engine: Engine): boolean;
  63381. private readonly _options;
  63382. private _canvas;
  63383. private _mediaRecorder;
  63384. private _recordedChunks;
  63385. private _fileName;
  63386. private _resolve;
  63387. private _reject;
  63388. /**
  63389. * True when a recording is already in progress.
  63390. */
  63391. readonly isRecording: boolean;
  63392. /**
  63393. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63394. * @param engine Defines the BabylonJS Engine you wish to record.
  63395. * @param options Defines options that can be used to customize the capture.
  63396. */
  63397. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63398. /**
  63399. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63400. */
  63401. stopRecording(): void;
  63402. /**
  63403. * Starts recording the canvas for a max duration specified in parameters.
  63404. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63405. * If null no automatic download will start and you can rely on the promise to get the data back.
  63406. * @param maxDuration Defines the maximum recording time in seconds.
  63407. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63408. * @return A promise callback at the end of the recording with the video data in Blob.
  63409. */
  63410. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63411. /**
  63412. * Releases internal resources used during the recording.
  63413. */
  63414. dispose(): void;
  63415. private _handleDataAvailable;
  63416. private _handleError;
  63417. private _handleStop;
  63418. }
  63419. }
  63420. declare module "babylonjs/Misc/screenshotTools" {
  63421. import { Camera } from "babylonjs/Cameras/camera";
  63422. import { Engine } from "babylonjs/Engines/engine";
  63423. /**
  63424. * Class containing a set of static utilities functions for screenshots
  63425. */
  63426. export class ScreenshotTools {
  63427. /**
  63428. * Captures a screenshot of the current rendering
  63429. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63430. * @param engine defines the rendering engine
  63431. * @param camera defines the source camera
  63432. * @param size This parameter can be set to a single number or to an object with the
  63433. * following (optional) properties: precision, width, height. If a single number is passed,
  63434. * it will be used for both width and height. If an object is passed, the screenshot size
  63435. * will be derived from the parameters. The precision property is a multiplier allowing
  63436. * rendering at a higher or lower resolution
  63437. * @param successCallback defines the callback receives a single parameter which contains the
  63438. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63439. * src parameter of an <img> to display it
  63440. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63441. * Check your browser for supported MIME types
  63442. */
  63443. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  63444. /**
  63445. * Generates an image screenshot from the specified camera.
  63446. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63447. * @param engine The engine to use for rendering
  63448. * @param camera The camera to use for rendering
  63449. * @param size This parameter can be set to a single number or to an object with the
  63450. * following (optional) properties: precision, width, height. If a single number is passed,
  63451. * it will be used for both width and height. If an object is passed, the screenshot size
  63452. * will be derived from the parameters. The precision property is a multiplier allowing
  63453. * rendering at a higher or lower resolution
  63454. * @param successCallback The callback receives a single parameter which contains the
  63455. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63456. * src parameter of an <img> to display it
  63457. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63458. * Check your browser for supported MIME types
  63459. * @param samples Texture samples (default: 1)
  63460. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63461. * @param fileName A name for for the downloaded file.
  63462. */
  63463. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63464. }
  63465. }
  63466. declare module "babylonjs/Misc/index" {
  63467. export * from "babylonjs/Misc/andOrNotEvaluator";
  63468. export * from "babylonjs/Misc/assetsManager";
  63469. export * from "babylonjs/Misc/dds";
  63470. export * from "babylonjs/Misc/decorators";
  63471. export * from "babylonjs/Misc/deferred";
  63472. export * from "babylonjs/Misc/environmentTextureTools";
  63473. export * from "babylonjs/Misc/meshExploder";
  63474. export * from "babylonjs/Misc/filesInput";
  63475. export * from "babylonjs/Misc/HighDynamicRange/index";
  63476. export * from "babylonjs/Misc/khronosTextureContainer";
  63477. export * from "babylonjs/Misc/observable";
  63478. export * from "babylonjs/Misc/performanceMonitor";
  63479. export * from "babylonjs/Misc/promise";
  63480. export * from "babylonjs/Misc/sceneOptimizer";
  63481. export * from "babylonjs/Misc/sceneSerializer";
  63482. export * from "babylonjs/Misc/smartArray";
  63483. export * from "babylonjs/Misc/stringDictionary";
  63484. export * from "babylonjs/Misc/tags";
  63485. export * from "babylonjs/Misc/textureTools";
  63486. export * from "babylonjs/Misc/tga";
  63487. export * from "babylonjs/Misc/tools";
  63488. export * from "babylonjs/Misc/videoRecorder";
  63489. export * from "babylonjs/Misc/virtualJoystick";
  63490. export * from "babylonjs/Misc/workerPool";
  63491. export * from "babylonjs/Misc/logger";
  63492. export * from "babylonjs/Misc/typeStore";
  63493. export * from "babylonjs/Misc/filesInputStore";
  63494. export * from "babylonjs/Misc/deepCopier";
  63495. export * from "babylonjs/Misc/pivotTools";
  63496. export * from "babylonjs/Misc/precisionDate";
  63497. export * from "babylonjs/Misc/screenshotTools";
  63498. export * from "babylonjs/Misc/typeStore";
  63499. export * from "babylonjs/Misc/webRequest";
  63500. export * from "babylonjs/Misc/iInspectable";
  63501. export * from "babylonjs/Misc/brdfTextureTools";
  63502. export * from "babylonjs/Misc/gradients";
  63503. export * from "babylonjs/Misc/perfCounter";
  63504. export * from "babylonjs/Misc/fileRequest";
  63505. export * from "babylonjs/Misc/customAnimationFrameRequester";
  63506. export * from "babylonjs/Misc/retryStrategy";
  63507. export * from "babylonjs/Misc/loadFileError";
  63508. }
  63509. declare module "babylonjs/index" {
  63510. export * from "babylonjs/abstractScene";
  63511. export * from "babylonjs/Actions/index";
  63512. export * from "babylonjs/Animations/index";
  63513. export * from "babylonjs/assetContainer";
  63514. export * from "babylonjs/Audio/index";
  63515. export * from "babylonjs/Behaviors/index";
  63516. export * from "babylonjs/Bones/index";
  63517. export * from "babylonjs/Cameras/index";
  63518. export * from "babylonjs/Collisions/index";
  63519. export * from "babylonjs/Culling/index";
  63520. export * from "babylonjs/Debug/index";
  63521. export * from "babylonjs/Engines/index";
  63522. export * from "babylonjs/Events/index";
  63523. export * from "babylonjs/Gamepads/index";
  63524. export * from "babylonjs/Gizmos/index";
  63525. export * from "babylonjs/Helpers/index";
  63526. export * from "babylonjs/Instrumentation/index";
  63527. export * from "babylonjs/Layers/index";
  63528. export * from "babylonjs/LensFlares/index";
  63529. export * from "babylonjs/Lights/index";
  63530. export * from "babylonjs/Loading/index";
  63531. export * from "babylonjs/Materials/index";
  63532. export * from "babylonjs/Maths/index";
  63533. export * from "babylonjs/Meshes/index";
  63534. export * from "babylonjs/Morph/index";
  63535. export * from "babylonjs/Navigation/index";
  63536. export * from "babylonjs/node";
  63537. export * from "babylonjs/Offline/index";
  63538. export * from "babylonjs/Particles/index";
  63539. export * from "babylonjs/Physics/index";
  63540. export * from "babylonjs/PostProcesses/index";
  63541. export * from "babylonjs/Probes/index";
  63542. export * from "babylonjs/Rendering/index";
  63543. export * from "babylonjs/scene";
  63544. export * from "babylonjs/sceneComponent";
  63545. export * from "babylonjs/Sprites/index";
  63546. export * from "babylonjs/States/index";
  63547. export * from "babylonjs/Misc/index";
  63548. export * from "babylonjs/types";
  63549. }
  63550. declare module "babylonjs/Animations/pathCursor" {
  63551. import { Vector3 } from "babylonjs/Maths/math.vector";
  63552. import { Path2 } from "babylonjs/Maths/math.path";
  63553. /**
  63554. * A cursor which tracks a point on a path
  63555. */
  63556. export class PathCursor {
  63557. private path;
  63558. /**
  63559. * Stores path cursor callbacks for when an onchange event is triggered
  63560. */
  63561. private _onchange;
  63562. /**
  63563. * The value of the path cursor
  63564. */
  63565. value: number;
  63566. /**
  63567. * The animation array of the path cursor
  63568. */
  63569. animations: Animation[];
  63570. /**
  63571. * Initializes the path cursor
  63572. * @param path The path to track
  63573. */
  63574. constructor(path: Path2);
  63575. /**
  63576. * Gets the cursor point on the path
  63577. * @returns A point on the path cursor at the cursor location
  63578. */
  63579. getPoint(): Vector3;
  63580. /**
  63581. * Moves the cursor ahead by the step amount
  63582. * @param step The amount to move the cursor forward
  63583. * @returns This path cursor
  63584. */
  63585. moveAhead(step?: number): PathCursor;
  63586. /**
  63587. * Moves the cursor behind by the step amount
  63588. * @param step The amount to move the cursor back
  63589. * @returns This path cursor
  63590. */
  63591. moveBack(step?: number): PathCursor;
  63592. /**
  63593. * Moves the cursor by the step amount
  63594. * If the step amount is greater than one, an exception is thrown
  63595. * @param step The amount to move the cursor
  63596. * @returns This path cursor
  63597. */
  63598. move(step: number): PathCursor;
  63599. /**
  63600. * Ensures that the value is limited between zero and one
  63601. * @returns This path cursor
  63602. */
  63603. private ensureLimits;
  63604. /**
  63605. * Runs onchange callbacks on change (used by the animation engine)
  63606. * @returns This path cursor
  63607. */
  63608. private raiseOnChange;
  63609. /**
  63610. * Executes a function on change
  63611. * @param f A path cursor onchange callback
  63612. * @returns This path cursor
  63613. */
  63614. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63615. }
  63616. }
  63617. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  63618. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  63619. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  63620. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  63621. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  63622. }
  63623. declare module "babylonjs/Engines/Processors/Expressions/index" {
  63624. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  63625. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  63626. }
  63627. declare module "babylonjs/Engines/Processors/index" {
  63628. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  63629. export * from "babylonjs/Engines/Processors/Expressions/index";
  63630. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  63631. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  63632. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  63633. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  63634. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  63635. export * from "babylonjs/Engines/Processors/shaderProcessor";
  63636. }
  63637. declare module "babylonjs/Legacy/legacy" {
  63638. import * as Babylon from "babylonjs/index";
  63639. export * from "babylonjs/index";
  63640. }
  63641. declare module "babylonjs/Shaders/blur.fragment" {
  63642. /** @hidden */
  63643. export var blurPixelShader: {
  63644. name: string;
  63645. shader: string;
  63646. };
  63647. }
  63648. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  63649. /** @hidden */
  63650. export var pointCloudVertexDeclaration: {
  63651. name: string;
  63652. shader: string;
  63653. };
  63654. }
  63655. declare module "babylonjs" {
  63656. export * from "babylonjs/Legacy/legacy";
  63657. }
  63658. declare module BABYLON {
  63659. /** Alias type for value that can be null */
  63660. export type Nullable<T> = T | null;
  63661. /**
  63662. * Alias type for number that are floats
  63663. * @ignorenaming
  63664. */
  63665. export type float = number;
  63666. /**
  63667. * Alias type for number that are doubles.
  63668. * @ignorenaming
  63669. */
  63670. export type double = number;
  63671. /**
  63672. * Alias type for number that are integer
  63673. * @ignorenaming
  63674. */
  63675. export type int = number;
  63676. /** Alias type for number array or Float32Array */
  63677. export type FloatArray = number[] | Float32Array;
  63678. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  63679. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  63680. /**
  63681. * Alias for types that can be used by a Buffer or VertexBuffer.
  63682. */
  63683. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  63684. /**
  63685. * Alias type for primitive types
  63686. * @ignorenaming
  63687. */
  63688. type Primitive = undefined | null | boolean | string | number | Function;
  63689. /**
  63690. * Type modifier to make all the properties of an object Readonly
  63691. */
  63692. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  63693. /**
  63694. * Type modifier to make all the properties of an object Readonly recursively
  63695. */
  63696. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  63697. /** @hidden */
  63698. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  63699. }
  63700. /** @hidden */
  63701. /** @hidden */
  63702. type DeepImmutableObject<T> = {
  63703. readonly [K in keyof T]: DeepImmutable<T[K]>;
  63704. };
  63705. }
  63706. declare module BABYLON {
  63707. /**
  63708. * A class serves as a medium between the observable and its observers
  63709. */
  63710. export class EventState {
  63711. /**
  63712. * Create a new EventState
  63713. * @param mask defines the mask associated with this state
  63714. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63715. * @param target defines the original target of the state
  63716. * @param currentTarget defines the current target of the state
  63717. */
  63718. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63719. /**
  63720. * Initialize the current event state
  63721. * @param mask defines the mask associated with this state
  63722. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63723. * @param target defines the original target of the state
  63724. * @param currentTarget defines the current target of the state
  63725. * @returns the current event state
  63726. */
  63727. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63728. /**
  63729. * An Observer can set this property to true to prevent subsequent observers of being notified
  63730. */
  63731. skipNextObservers: boolean;
  63732. /**
  63733. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63734. */
  63735. mask: number;
  63736. /**
  63737. * The object that originally notified the event
  63738. */
  63739. target?: any;
  63740. /**
  63741. * The current object in the bubbling phase
  63742. */
  63743. currentTarget?: any;
  63744. /**
  63745. * This will be populated with the return value of the last function that was executed.
  63746. * If it is the first function in the callback chain it will be the event data.
  63747. */
  63748. lastReturnValue?: any;
  63749. }
  63750. /**
  63751. * Represent an Observer registered to a given Observable object.
  63752. */
  63753. export class Observer<T> {
  63754. /**
  63755. * Defines the callback to call when the observer is notified
  63756. */
  63757. callback: (eventData: T, eventState: EventState) => void;
  63758. /**
  63759. * Defines the mask of the observer (used to filter notifications)
  63760. */
  63761. mask: number;
  63762. /**
  63763. * Defines the current scope used to restore the JS context
  63764. */
  63765. scope: any;
  63766. /** @hidden */
  63767. _willBeUnregistered: boolean;
  63768. /**
  63769. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63770. */
  63771. unregisterOnNextCall: boolean;
  63772. /**
  63773. * Creates a new observer
  63774. * @param callback defines the callback to call when the observer is notified
  63775. * @param mask defines the mask of the observer (used to filter notifications)
  63776. * @param scope defines the current scope used to restore the JS context
  63777. */
  63778. constructor(
  63779. /**
  63780. * Defines the callback to call when the observer is notified
  63781. */
  63782. callback: (eventData: T, eventState: EventState) => void,
  63783. /**
  63784. * Defines the mask of the observer (used to filter notifications)
  63785. */
  63786. mask: number,
  63787. /**
  63788. * Defines the current scope used to restore the JS context
  63789. */
  63790. scope?: any);
  63791. }
  63792. /**
  63793. * Represent a list of observers registered to multiple Observables object.
  63794. */
  63795. export class MultiObserver<T> {
  63796. private _observers;
  63797. private _observables;
  63798. /**
  63799. * Release associated resources
  63800. */
  63801. dispose(): void;
  63802. /**
  63803. * Raise a callback when one of the observable will notify
  63804. * @param observables defines a list of observables to watch
  63805. * @param callback defines the callback to call on notification
  63806. * @param mask defines the mask used to filter notifications
  63807. * @param scope defines the current scope used to restore the JS context
  63808. * @returns the new MultiObserver
  63809. */
  63810. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63811. }
  63812. /**
  63813. * The Observable class is a simple implementation of the Observable pattern.
  63814. *
  63815. * 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.
  63816. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63817. * 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).
  63818. * 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.
  63819. */
  63820. export class Observable<T> {
  63821. private _observers;
  63822. private _eventState;
  63823. private _onObserverAdded;
  63824. /**
  63825. * Gets the list of observers
  63826. */
  63827. readonly observers: Array<Observer<T>>;
  63828. /**
  63829. * Creates a new observable
  63830. * @param onObserverAdded defines a callback to call when a new observer is added
  63831. */
  63832. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63833. /**
  63834. * Create a new Observer with the specified callback
  63835. * @param callback the callback that will be executed for that Observer
  63836. * @param mask the mask used to filter observers
  63837. * @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.
  63838. * @param scope optional scope for the callback to be called from
  63839. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63840. * @returns the new observer created for the callback
  63841. */
  63842. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63843. /**
  63844. * Create a new Observer with the specified callback and unregisters after the next notification
  63845. * @param callback the callback that will be executed for that Observer
  63846. * @returns the new observer created for the callback
  63847. */
  63848. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63849. /**
  63850. * Remove an Observer from the Observable object
  63851. * @param observer the instance of the Observer to remove
  63852. * @returns false if it doesn't belong to this Observable
  63853. */
  63854. remove(observer: Nullable<Observer<T>>): boolean;
  63855. /**
  63856. * Remove a callback from the Observable object
  63857. * @param callback the callback to remove
  63858. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63859. * @returns false if it doesn't belong to this Observable
  63860. */
  63861. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63862. private _deferUnregister;
  63863. private _remove;
  63864. /**
  63865. * Moves the observable to the top of the observer list making it get called first when notified
  63866. * @param observer the observer to move
  63867. */
  63868. makeObserverTopPriority(observer: Observer<T>): void;
  63869. /**
  63870. * Moves the observable to the bottom of the observer list making it get called last when notified
  63871. * @param observer the observer to move
  63872. */
  63873. makeObserverBottomPriority(observer: Observer<T>): void;
  63874. /**
  63875. * Notify all Observers by calling their respective callback with the given data
  63876. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63877. * @param eventData defines the data to send to all observers
  63878. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63879. * @param target defines the original target of the state
  63880. * @param currentTarget defines the current target of the state
  63881. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63882. */
  63883. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63884. /**
  63885. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63886. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63887. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63888. * and it is crucial that all callbacks will be executed.
  63889. * The order of the callbacks is kept, callbacks are not executed parallel.
  63890. *
  63891. * @param eventData The data to be sent to each callback
  63892. * @param mask is used to filter observers defaults to -1
  63893. * @param target defines the callback target (see EventState)
  63894. * @param currentTarget defines he current object in the bubbling phase
  63895. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63896. */
  63897. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63898. /**
  63899. * Notify a specific observer
  63900. * @param observer defines the observer to notify
  63901. * @param eventData defines the data to be sent to each callback
  63902. * @param mask is used to filter observers defaults to -1
  63903. */
  63904. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63905. /**
  63906. * Gets a boolean indicating if the observable has at least one observer
  63907. * @returns true is the Observable has at least one Observer registered
  63908. */
  63909. hasObservers(): boolean;
  63910. /**
  63911. * Clear the list of observers
  63912. */
  63913. clear(): void;
  63914. /**
  63915. * Clone the current observable
  63916. * @returns a new observable
  63917. */
  63918. clone(): Observable<T>;
  63919. /**
  63920. * Does this observable handles observer registered with a given mask
  63921. * @param mask defines the mask to be tested
  63922. * @return whether or not one observer registered with the given mask is handeled
  63923. **/
  63924. hasSpecificMask(mask?: number): boolean;
  63925. }
  63926. }
  63927. declare module BABYLON {
  63928. /**
  63929. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63930. * Babylon.js
  63931. */
  63932. export class DomManagement {
  63933. /**
  63934. * Checks if the window object exists
  63935. * @returns true if the window object exists
  63936. */
  63937. static IsWindowObjectExist(): boolean;
  63938. /**
  63939. * Extracts text content from a DOM element hierarchy
  63940. * @param element defines the root element
  63941. * @returns a string
  63942. */
  63943. static GetDOMTextContent(element: HTMLElement): string;
  63944. }
  63945. }
  63946. declare module BABYLON {
  63947. /**
  63948. * Logger used througouht the application to allow configuration of
  63949. * the log level required for the messages.
  63950. */
  63951. export class Logger {
  63952. /**
  63953. * No log
  63954. */
  63955. static readonly NoneLogLevel: number;
  63956. /**
  63957. * Only message logs
  63958. */
  63959. static readonly MessageLogLevel: number;
  63960. /**
  63961. * Only warning logs
  63962. */
  63963. static readonly WarningLogLevel: number;
  63964. /**
  63965. * Only error logs
  63966. */
  63967. static readonly ErrorLogLevel: number;
  63968. /**
  63969. * All logs
  63970. */
  63971. static readonly AllLogLevel: number;
  63972. private static _LogCache;
  63973. /**
  63974. * Gets a value indicating the number of loading errors
  63975. * @ignorenaming
  63976. */
  63977. static errorsCount: number;
  63978. /**
  63979. * Callback called when a new log is added
  63980. */
  63981. static OnNewCacheEntry: (entry: string) => void;
  63982. private static _AddLogEntry;
  63983. private static _FormatMessage;
  63984. private static _LogDisabled;
  63985. private static _LogEnabled;
  63986. private static _WarnDisabled;
  63987. private static _WarnEnabled;
  63988. private static _ErrorDisabled;
  63989. private static _ErrorEnabled;
  63990. /**
  63991. * Log a message to the console
  63992. */
  63993. static Log: (message: string) => void;
  63994. /**
  63995. * Write a warning message to the console
  63996. */
  63997. static Warn: (message: string) => void;
  63998. /**
  63999. * Write an error message to the console
  64000. */
  64001. static Error: (message: string) => void;
  64002. /**
  64003. * Gets current log cache (list of logs)
  64004. */
  64005. static readonly LogCache: string;
  64006. /**
  64007. * Clears the log cache
  64008. */
  64009. static ClearLogCache(): void;
  64010. /**
  64011. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64012. */
  64013. static LogLevels: number;
  64014. }
  64015. }
  64016. declare module BABYLON {
  64017. /** @hidden */
  64018. export class _TypeStore {
  64019. /** @hidden */
  64020. static RegisteredTypes: {
  64021. [key: string]: Object;
  64022. };
  64023. /** @hidden */
  64024. static GetClass(fqdn: string): any;
  64025. }
  64026. }
  64027. declare module BABYLON {
  64028. /**
  64029. * Class containing a set of static utilities functions for deep copy.
  64030. */
  64031. export class DeepCopier {
  64032. /**
  64033. * Tries to copy an object by duplicating every property
  64034. * @param source defines the source object
  64035. * @param destination defines the target object
  64036. * @param doNotCopyList defines a list of properties to avoid
  64037. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64038. */
  64039. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64040. }
  64041. }
  64042. declare module BABYLON {
  64043. /**
  64044. * Class containing a set of static utilities functions for precision date
  64045. */
  64046. export class PrecisionDate {
  64047. /**
  64048. * Gets either window.performance.now() if supported or Date.now() else
  64049. */
  64050. static readonly Now: number;
  64051. }
  64052. }
  64053. declare module BABYLON {
  64054. /** @hidden */
  64055. export class _DevTools {
  64056. static WarnImport(name: string): string;
  64057. }
  64058. }
  64059. declare module BABYLON {
  64060. /**
  64061. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64062. */
  64063. export class WebRequest {
  64064. private _xhr;
  64065. /**
  64066. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64067. * i.e. when loading files, where the server/service expects an Authorization header
  64068. */
  64069. static CustomRequestHeaders: {
  64070. [key: string]: string;
  64071. };
  64072. /**
  64073. * Add callback functions in this array to update all the requests before they get sent to the network
  64074. */
  64075. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64076. private _injectCustomRequestHeaders;
  64077. /**
  64078. * Gets or sets a function to be called when loading progress changes
  64079. */
  64080. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64081. /**
  64082. * Returns client's state
  64083. */
  64084. readonly readyState: number;
  64085. /**
  64086. * Returns client's status
  64087. */
  64088. readonly status: number;
  64089. /**
  64090. * Returns client's status as a text
  64091. */
  64092. readonly statusText: string;
  64093. /**
  64094. * Returns client's response
  64095. */
  64096. readonly response: any;
  64097. /**
  64098. * Returns client's response url
  64099. */
  64100. readonly responseURL: string;
  64101. /**
  64102. * Returns client's response as text
  64103. */
  64104. readonly responseText: string;
  64105. /**
  64106. * Gets or sets the expected response type
  64107. */
  64108. responseType: XMLHttpRequestResponseType;
  64109. /** @hidden */
  64110. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64111. /** @hidden */
  64112. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64113. /**
  64114. * Cancels any network activity
  64115. */
  64116. abort(): void;
  64117. /**
  64118. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64119. * @param body defines an optional request body
  64120. */
  64121. send(body?: Document | BodyInit | null): void;
  64122. /**
  64123. * Sets the request method, request URL
  64124. * @param method defines the method to use (GET, POST, etc..)
  64125. * @param url defines the url to connect with
  64126. */
  64127. open(method: string, url: string): void;
  64128. }
  64129. }
  64130. declare module BABYLON {
  64131. /**
  64132. * File request interface
  64133. */
  64134. export interface IFileRequest {
  64135. /**
  64136. * Raised when the request is complete (success or error).
  64137. */
  64138. onCompleteObservable: Observable<IFileRequest>;
  64139. /**
  64140. * Aborts the request for a file.
  64141. */
  64142. abort: () => void;
  64143. }
  64144. }
  64145. declare module BABYLON {
  64146. /**
  64147. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64148. */
  64149. export class PerformanceMonitor {
  64150. private _enabled;
  64151. private _rollingFrameTime;
  64152. private _lastFrameTimeMs;
  64153. /**
  64154. * constructor
  64155. * @param frameSampleSize The number of samples required to saturate the sliding window
  64156. */
  64157. constructor(frameSampleSize?: number);
  64158. /**
  64159. * Samples current frame
  64160. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64161. */
  64162. sampleFrame(timeMs?: number): void;
  64163. /**
  64164. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64165. */
  64166. readonly averageFrameTime: number;
  64167. /**
  64168. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64169. */
  64170. readonly averageFrameTimeVariance: number;
  64171. /**
  64172. * Returns the frame time of the most recent frame
  64173. */
  64174. readonly instantaneousFrameTime: number;
  64175. /**
  64176. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64177. */
  64178. readonly averageFPS: number;
  64179. /**
  64180. * Returns the average framerate in frames per second using the most recent frame time
  64181. */
  64182. readonly instantaneousFPS: number;
  64183. /**
  64184. * Returns true if enough samples have been taken to completely fill the sliding window
  64185. */
  64186. readonly isSaturated: boolean;
  64187. /**
  64188. * Enables contributions to the sliding window sample set
  64189. */
  64190. enable(): void;
  64191. /**
  64192. * Disables contributions to the sliding window sample set
  64193. * Samples will not be interpolated over the disabled period
  64194. */
  64195. disable(): void;
  64196. /**
  64197. * Returns true if sampling is enabled
  64198. */
  64199. readonly isEnabled: boolean;
  64200. /**
  64201. * Resets performance monitor
  64202. */
  64203. reset(): void;
  64204. }
  64205. /**
  64206. * RollingAverage
  64207. *
  64208. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64209. */
  64210. export class RollingAverage {
  64211. /**
  64212. * Current average
  64213. */
  64214. average: number;
  64215. /**
  64216. * Current variance
  64217. */
  64218. variance: number;
  64219. protected _samples: Array<number>;
  64220. protected _sampleCount: number;
  64221. protected _pos: number;
  64222. protected _m2: number;
  64223. /**
  64224. * constructor
  64225. * @param length The number of samples required to saturate the sliding window
  64226. */
  64227. constructor(length: number);
  64228. /**
  64229. * Adds a sample to the sample set
  64230. * @param v The sample value
  64231. */
  64232. add(v: number): void;
  64233. /**
  64234. * Returns previously added values or null if outside of history or outside the sliding window domain
  64235. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64236. * @return Value previously recorded with add() or null if outside of range
  64237. */
  64238. history(i: number): number;
  64239. /**
  64240. * Returns true if enough samples have been taken to completely fill the sliding window
  64241. * @return true if sample-set saturated
  64242. */
  64243. isSaturated(): boolean;
  64244. /**
  64245. * Resets the rolling average (equivalent to 0 samples taken so far)
  64246. */
  64247. reset(): void;
  64248. /**
  64249. * Wraps a value around the sample range boundaries
  64250. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64251. * @return Wrapped position in sample range
  64252. */
  64253. protected _wrapPosition(i: number): number;
  64254. }
  64255. }
  64256. declare module BABYLON {
  64257. /**
  64258. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64259. * The underlying implementation relies on an associative array to ensure the best performances.
  64260. * The value can be anything including 'null' but except 'undefined'
  64261. */
  64262. export class StringDictionary<T> {
  64263. /**
  64264. * This will clear this dictionary and copy the content from the 'source' one.
  64265. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64266. * @param source the dictionary to take the content from and copy to this dictionary
  64267. */
  64268. copyFrom(source: StringDictionary<T>): void;
  64269. /**
  64270. * Get a value based from its key
  64271. * @param key the given key to get the matching value from
  64272. * @return the value if found, otherwise undefined is returned
  64273. */
  64274. get(key: string): T | undefined;
  64275. /**
  64276. * Get a value from its key or add it if it doesn't exist.
  64277. * This method will ensure you that a given key/data will be present in the dictionary.
  64278. * @param key the given key to get the matching value from
  64279. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64280. * The factory will only be invoked if there's no data for the given key.
  64281. * @return the value corresponding to the key.
  64282. */
  64283. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64284. /**
  64285. * Get a value from its key if present in the dictionary otherwise add it
  64286. * @param key the key to get the value from
  64287. * @param val if there's no such key/value pair in the dictionary add it with this value
  64288. * @return the value corresponding to the key
  64289. */
  64290. getOrAdd(key: string, val: T): T;
  64291. /**
  64292. * Check if there's a given key in the dictionary
  64293. * @param key the key to check for
  64294. * @return true if the key is present, false otherwise
  64295. */
  64296. contains(key: string): boolean;
  64297. /**
  64298. * Add a new key and its corresponding value
  64299. * @param key the key to add
  64300. * @param value the value corresponding to the key
  64301. * @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
  64302. */
  64303. add(key: string, value: T): boolean;
  64304. /**
  64305. * Update a specific value associated to a key
  64306. * @param key defines the key to use
  64307. * @param value defines the value to store
  64308. * @returns true if the value was updated (or false if the key was not found)
  64309. */
  64310. set(key: string, value: T): boolean;
  64311. /**
  64312. * Get the element of the given key and remove it from the dictionary
  64313. * @param key defines the key to search
  64314. * @returns the value associated with the key or null if not found
  64315. */
  64316. getAndRemove(key: string): Nullable<T>;
  64317. /**
  64318. * Remove a key/value from the dictionary.
  64319. * @param key the key to remove
  64320. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64321. */
  64322. remove(key: string): boolean;
  64323. /**
  64324. * Clear the whole content of the dictionary
  64325. */
  64326. clear(): void;
  64327. /**
  64328. * Gets the current count
  64329. */
  64330. readonly count: number;
  64331. /**
  64332. * Execute a callback on each key/val of the dictionary.
  64333. * Note that you can remove any element in this dictionary in the callback implementation
  64334. * @param callback the callback to execute on a given key/value pair
  64335. */
  64336. forEach(callback: (key: string, val: T) => void): void;
  64337. /**
  64338. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64339. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64340. * Note that you can remove any element in this dictionary in the callback implementation
  64341. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64342. * @returns the first item
  64343. */
  64344. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64345. private _count;
  64346. private _data;
  64347. }
  64348. }
  64349. declare module BABYLON {
  64350. /**
  64351. * Class used to store gfx data (like WebGLBuffer)
  64352. */
  64353. export class DataBuffer {
  64354. /**
  64355. * Gets or sets the number of objects referencing this buffer
  64356. */
  64357. references: number;
  64358. /** Gets or sets the size of the underlying buffer */
  64359. capacity: number;
  64360. /**
  64361. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  64362. */
  64363. is32Bits: boolean;
  64364. /**
  64365. * Gets the underlying buffer
  64366. */
  64367. readonly underlyingResource: any;
  64368. }
  64369. }
  64370. declare module BABYLON {
  64371. /**
  64372. * Class used to store data that will be store in GPU memory
  64373. */
  64374. export class Buffer {
  64375. private _engine;
  64376. private _buffer;
  64377. /** @hidden */
  64378. _data: Nullable<DataArray>;
  64379. private _updatable;
  64380. private _instanced;
  64381. /**
  64382. * Gets the byte stride.
  64383. */
  64384. readonly byteStride: number;
  64385. /**
  64386. * Constructor
  64387. * @param engine the engine
  64388. * @param data the data to use for this buffer
  64389. * @param updatable whether the data is updatable
  64390. * @param stride the stride (optional)
  64391. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64392. * @param instanced whether the buffer is instanced (optional)
  64393. * @param useBytes set to true if the stride in in bytes (optional)
  64394. */
  64395. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64396. /**
  64397. * Create a new VertexBuffer based on the current buffer
  64398. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64399. * @param offset defines offset in the buffer (0 by default)
  64400. * @param size defines the size in floats of attributes (position is 3 for instance)
  64401. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64402. * @param instanced defines if the vertex buffer contains indexed data
  64403. * @param useBytes defines if the offset and stride are in bytes
  64404. * @returns the new vertex buffer
  64405. */
  64406. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64407. /**
  64408. * Gets a boolean indicating if the Buffer is updatable?
  64409. * @returns true if the buffer is updatable
  64410. */
  64411. isUpdatable(): boolean;
  64412. /**
  64413. * Gets current buffer's data
  64414. * @returns a DataArray or null
  64415. */
  64416. getData(): Nullable<DataArray>;
  64417. /**
  64418. * Gets underlying native buffer
  64419. * @returns underlying native buffer
  64420. */
  64421. getBuffer(): Nullable<DataBuffer>;
  64422. /**
  64423. * Gets the stride in float32 units (i.e. byte stride / 4).
  64424. * May not be an integer if the byte stride is not divisible by 4.
  64425. * DEPRECATED. Use byteStride instead.
  64426. * @returns the stride in float32 units
  64427. */
  64428. getStrideSize(): number;
  64429. /**
  64430. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64431. * @param data defines the data to store
  64432. */
  64433. create(data?: Nullable<DataArray>): void;
  64434. /** @hidden */
  64435. _rebuild(): void;
  64436. /**
  64437. * Update current buffer data
  64438. * @param data defines the data to store
  64439. */
  64440. update(data: DataArray): void;
  64441. /**
  64442. * Updates the data directly.
  64443. * @param data the new data
  64444. * @param offset the new offset
  64445. * @param vertexCount the vertex count (optional)
  64446. * @param useBytes set to true if the offset is in bytes
  64447. */
  64448. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64449. /**
  64450. * Release all resources
  64451. */
  64452. dispose(): void;
  64453. }
  64454. /**
  64455. * Specialized buffer used to store vertex data
  64456. */
  64457. export class VertexBuffer {
  64458. /** @hidden */
  64459. _buffer: Buffer;
  64460. private _kind;
  64461. private _size;
  64462. private _ownsBuffer;
  64463. private _instanced;
  64464. private _instanceDivisor;
  64465. /**
  64466. * The byte type.
  64467. */
  64468. static readonly BYTE: number;
  64469. /**
  64470. * The unsigned byte type.
  64471. */
  64472. static readonly UNSIGNED_BYTE: number;
  64473. /**
  64474. * The short type.
  64475. */
  64476. static readonly SHORT: number;
  64477. /**
  64478. * The unsigned short type.
  64479. */
  64480. static readonly UNSIGNED_SHORT: number;
  64481. /**
  64482. * The integer type.
  64483. */
  64484. static readonly INT: number;
  64485. /**
  64486. * The unsigned integer type.
  64487. */
  64488. static readonly UNSIGNED_INT: number;
  64489. /**
  64490. * The float type.
  64491. */
  64492. static readonly FLOAT: number;
  64493. /**
  64494. * Gets or sets the instance divisor when in instanced mode
  64495. */
  64496. instanceDivisor: number;
  64497. /**
  64498. * Gets the byte stride.
  64499. */
  64500. readonly byteStride: number;
  64501. /**
  64502. * Gets the byte offset.
  64503. */
  64504. readonly byteOffset: number;
  64505. /**
  64506. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64507. */
  64508. readonly normalized: boolean;
  64509. /**
  64510. * Gets the data type of each component in the array.
  64511. */
  64512. readonly type: number;
  64513. /**
  64514. * Constructor
  64515. * @param engine the engine
  64516. * @param data the data to use for this vertex buffer
  64517. * @param kind the vertex buffer kind
  64518. * @param updatable whether the data is updatable
  64519. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64520. * @param stride the stride (optional)
  64521. * @param instanced whether the buffer is instanced (optional)
  64522. * @param offset the offset of the data (optional)
  64523. * @param size the number of components (optional)
  64524. * @param type the type of the component (optional)
  64525. * @param normalized whether the data contains normalized data (optional)
  64526. * @param useBytes set to true if stride and offset are in bytes (optional)
  64527. */
  64528. 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);
  64529. /** @hidden */
  64530. _rebuild(): void;
  64531. /**
  64532. * Returns the kind of the VertexBuffer (string)
  64533. * @returns a string
  64534. */
  64535. getKind(): string;
  64536. /**
  64537. * Gets a boolean indicating if the VertexBuffer is updatable?
  64538. * @returns true if the buffer is updatable
  64539. */
  64540. isUpdatable(): boolean;
  64541. /**
  64542. * Gets current buffer's data
  64543. * @returns a DataArray or null
  64544. */
  64545. getData(): Nullable<DataArray>;
  64546. /**
  64547. * Gets underlying native buffer
  64548. * @returns underlying native buffer
  64549. */
  64550. getBuffer(): Nullable<DataBuffer>;
  64551. /**
  64552. * Gets the stride in float32 units (i.e. byte stride / 4).
  64553. * May not be an integer if the byte stride is not divisible by 4.
  64554. * DEPRECATED. Use byteStride instead.
  64555. * @returns the stride in float32 units
  64556. */
  64557. getStrideSize(): number;
  64558. /**
  64559. * Returns the offset as a multiple of the type byte length.
  64560. * DEPRECATED. Use byteOffset instead.
  64561. * @returns the offset in bytes
  64562. */
  64563. getOffset(): number;
  64564. /**
  64565. * Returns the number of components per vertex attribute (integer)
  64566. * @returns the size in float
  64567. */
  64568. getSize(): number;
  64569. /**
  64570. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64571. * @returns true if this buffer is instanced
  64572. */
  64573. getIsInstanced(): boolean;
  64574. /**
  64575. * Returns the instancing divisor, zero for non-instanced (integer).
  64576. * @returns a number
  64577. */
  64578. getInstanceDivisor(): number;
  64579. /**
  64580. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64581. * @param data defines the data to store
  64582. */
  64583. create(data?: DataArray): void;
  64584. /**
  64585. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64586. * This function will create a new buffer if the current one is not updatable
  64587. * @param data defines the data to store
  64588. */
  64589. update(data: DataArray): void;
  64590. /**
  64591. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64592. * Returns the directly updated WebGLBuffer.
  64593. * @param data the new data
  64594. * @param offset the new offset
  64595. * @param useBytes set to true if the offset is in bytes
  64596. */
  64597. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64598. /**
  64599. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64600. */
  64601. dispose(): void;
  64602. /**
  64603. * Enumerates each value of this vertex buffer as numbers.
  64604. * @param count the number of values to enumerate
  64605. * @param callback the callback function called for each value
  64606. */
  64607. forEach(count: number, callback: (value: number, index: number) => void): void;
  64608. /**
  64609. * Positions
  64610. */
  64611. static readonly PositionKind: string;
  64612. /**
  64613. * Normals
  64614. */
  64615. static readonly NormalKind: string;
  64616. /**
  64617. * Tangents
  64618. */
  64619. static readonly TangentKind: string;
  64620. /**
  64621. * Texture coordinates
  64622. */
  64623. static readonly UVKind: string;
  64624. /**
  64625. * Texture coordinates 2
  64626. */
  64627. static readonly UV2Kind: string;
  64628. /**
  64629. * Texture coordinates 3
  64630. */
  64631. static readonly UV3Kind: string;
  64632. /**
  64633. * Texture coordinates 4
  64634. */
  64635. static readonly UV4Kind: string;
  64636. /**
  64637. * Texture coordinates 5
  64638. */
  64639. static readonly UV5Kind: string;
  64640. /**
  64641. * Texture coordinates 6
  64642. */
  64643. static readonly UV6Kind: string;
  64644. /**
  64645. * Colors
  64646. */
  64647. static readonly ColorKind: string;
  64648. /**
  64649. * Matrix indices (for bones)
  64650. */
  64651. static readonly MatricesIndicesKind: string;
  64652. /**
  64653. * Matrix weights (for bones)
  64654. */
  64655. static readonly MatricesWeightsKind: string;
  64656. /**
  64657. * Additional matrix indices (for bones)
  64658. */
  64659. static readonly MatricesIndicesExtraKind: string;
  64660. /**
  64661. * Additional matrix weights (for bones)
  64662. */
  64663. static readonly MatricesWeightsExtraKind: string;
  64664. /**
  64665. * Deduces the stride given a kind.
  64666. * @param kind The kind string to deduce
  64667. * @returns The deduced stride
  64668. */
  64669. static DeduceStride(kind: string): number;
  64670. /**
  64671. * Gets the byte length of the given type.
  64672. * @param type the type
  64673. * @returns the number of bytes
  64674. */
  64675. static GetTypeByteLength(type: number): number;
  64676. /**
  64677. * Enumerates each value of the given parameters as numbers.
  64678. * @param data the data to enumerate
  64679. * @param byteOffset the byte offset of the data
  64680. * @param byteStride the byte stride of the data
  64681. * @param componentCount the number of components per element
  64682. * @param componentType the type of the component
  64683. * @param count the number of values to enumerate
  64684. * @param normalized whether the data is normalized
  64685. * @param callback the callback function called for each value
  64686. */
  64687. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64688. private static _GetFloatValue;
  64689. }
  64690. }
  64691. declare module BABYLON {
  64692. /**
  64693. * Scalar computation library
  64694. */
  64695. export class Scalar {
  64696. /**
  64697. * Two pi constants convenient for computation.
  64698. */
  64699. static TwoPi: number;
  64700. /**
  64701. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64702. * @param a number
  64703. * @param b number
  64704. * @param epsilon (default = 1.401298E-45)
  64705. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64706. */
  64707. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  64708. /**
  64709. * Returns a string : the upper case translation of the number i to hexadecimal.
  64710. * @param i number
  64711. * @returns the upper case translation of the number i to hexadecimal.
  64712. */
  64713. static ToHex(i: number): string;
  64714. /**
  64715. * Returns -1 if value is negative and +1 is value is positive.
  64716. * @param value the value
  64717. * @returns the value itself if it's equal to zero.
  64718. */
  64719. static Sign(value: number): number;
  64720. /**
  64721. * Returns the value itself if it's between min and max.
  64722. * Returns min if the value is lower than min.
  64723. * Returns max if the value is greater than max.
  64724. * @param value the value to clmap
  64725. * @param min the min value to clamp to (default: 0)
  64726. * @param max the max value to clamp to (default: 1)
  64727. * @returns the clamped value
  64728. */
  64729. static Clamp(value: number, min?: number, max?: number): number;
  64730. /**
  64731. * the log2 of value.
  64732. * @param value the value to compute log2 of
  64733. * @returns the log2 of value.
  64734. */
  64735. static Log2(value: number): number;
  64736. /**
  64737. * Loops the value, so that it is never larger than length and never smaller than 0.
  64738. *
  64739. * This is similar to the modulo operator but it works with floating point numbers.
  64740. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  64741. * With t = 5 and length = 2.5, the result would be 0.0.
  64742. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  64743. * @param value the value
  64744. * @param length the length
  64745. * @returns the looped value
  64746. */
  64747. static Repeat(value: number, length: number): number;
  64748. /**
  64749. * Normalize the value between 0.0 and 1.0 using min and max values
  64750. * @param value value to normalize
  64751. * @param min max to normalize between
  64752. * @param max min to normalize between
  64753. * @returns the normalized value
  64754. */
  64755. static Normalize(value: number, min: number, max: number): number;
  64756. /**
  64757. * Denormalize the value from 0.0 and 1.0 using min and max values
  64758. * @param normalized value to denormalize
  64759. * @param min max to denormalize between
  64760. * @param max min to denormalize between
  64761. * @returns the denormalized value
  64762. */
  64763. static Denormalize(normalized: number, min: number, max: number): number;
  64764. /**
  64765. * Calculates the shortest difference between two given angles given in degrees.
  64766. * @param current current angle in degrees
  64767. * @param target target angle in degrees
  64768. * @returns the delta
  64769. */
  64770. static DeltaAngle(current: number, target: number): number;
  64771. /**
  64772. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  64773. * @param tx value
  64774. * @param length length
  64775. * @returns The returned value will move back and forth between 0 and length
  64776. */
  64777. static PingPong(tx: number, length: number): number;
  64778. /**
  64779. * Interpolates between min and max with smoothing at the limits.
  64780. *
  64781. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  64782. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  64783. * @param from from
  64784. * @param to to
  64785. * @param tx value
  64786. * @returns the smooth stepped value
  64787. */
  64788. static SmoothStep(from: number, to: number, tx: number): number;
  64789. /**
  64790. * Moves a value current towards target.
  64791. *
  64792. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  64793. * Negative values of maxDelta pushes the value away from target.
  64794. * @param current current value
  64795. * @param target target value
  64796. * @param maxDelta max distance to move
  64797. * @returns resulting value
  64798. */
  64799. static MoveTowards(current: number, target: number, maxDelta: number): number;
  64800. /**
  64801. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  64802. *
  64803. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  64804. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  64805. * @param current current value
  64806. * @param target target value
  64807. * @param maxDelta max distance to move
  64808. * @returns resulting angle
  64809. */
  64810. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  64811. /**
  64812. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  64813. * @param start start value
  64814. * @param end target value
  64815. * @param amount amount to lerp between
  64816. * @returns the lerped value
  64817. */
  64818. static Lerp(start: number, end: number, amount: number): number;
  64819. /**
  64820. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  64821. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  64822. * @param start start value
  64823. * @param end target value
  64824. * @param amount amount to lerp between
  64825. * @returns the lerped value
  64826. */
  64827. static LerpAngle(start: number, end: number, amount: number): number;
  64828. /**
  64829. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  64830. * @param a start value
  64831. * @param b target value
  64832. * @param value value between a and b
  64833. * @returns the inverseLerp value
  64834. */
  64835. static InverseLerp(a: number, b: number, value: number): number;
  64836. /**
  64837. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  64838. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  64839. * @param value1 spline value
  64840. * @param tangent1 spline value
  64841. * @param value2 spline value
  64842. * @param tangent2 spline value
  64843. * @param amount input value
  64844. * @returns hermite result
  64845. */
  64846. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  64847. /**
  64848. * Returns a random float number between and min and max values
  64849. * @param min min value of random
  64850. * @param max max value of random
  64851. * @returns random value
  64852. */
  64853. static RandomRange(min: number, max: number): number;
  64854. /**
  64855. * This function returns percentage of a number in a given range.
  64856. *
  64857. * RangeToPercent(40,20,60) will return 0.5 (50%)
  64858. * RangeToPercent(34,0,100) will return 0.34 (34%)
  64859. * @param number to convert to percentage
  64860. * @param min min range
  64861. * @param max max range
  64862. * @returns the percentage
  64863. */
  64864. static RangeToPercent(number: number, min: number, max: number): number;
  64865. /**
  64866. * This function returns number that corresponds to the percentage in a given range.
  64867. *
  64868. * PercentToRange(0.34,0,100) will return 34.
  64869. * @param percent to convert to number
  64870. * @param min min range
  64871. * @param max max range
  64872. * @returns the number
  64873. */
  64874. static PercentToRange(percent: number, min: number, max: number): number;
  64875. /**
  64876. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  64877. * @param angle The angle to normalize in radian.
  64878. * @return The converted angle.
  64879. */
  64880. static NormalizeRadians(angle: number): number;
  64881. }
  64882. }
  64883. declare module BABYLON {
  64884. /**
  64885. * Constant used to convert a value to gamma space
  64886. * @ignorenaming
  64887. */
  64888. export const ToGammaSpace: number;
  64889. /**
  64890. * Constant used to convert a value to linear space
  64891. * @ignorenaming
  64892. */
  64893. export const ToLinearSpace = 2.2;
  64894. /**
  64895. * Constant used to define the minimal number value in Babylon.js
  64896. * @ignorenaming
  64897. */
  64898. let Epsilon: number;
  64899. }
  64900. declare module BABYLON {
  64901. /**
  64902. * Class used to represent a viewport on screen
  64903. */
  64904. export class Viewport {
  64905. /** viewport left coordinate */
  64906. x: number;
  64907. /** viewport top coordinate */
  64908. y: number;
  64909. /**viewport width */
  64910. width: number;
  64911. /** viewport height */
  64912. height: number;
  64913. /**
  64914. * Creates a Viewport object located at (x, y) and sized (width, height)
  64915. * @param x defines viewport left coordinate
  64916. * @param y defines viewport top coordinate
  64917. * @param width defines the viewport width
  64918. * @param height defines the viewport height
  64919. */
  64920. constructor(
  64921. /** viewport left coordinate */
  64922. x: number,
  64923. /** viewport top coordinate */
  64924. y: number,
  64925. /**viewport width */
  64926. width: number,
  64927. /** viewport height */
  64928. height: number);
  64929. /**
  64930. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  64931. * @param renderWidth defines the rendering width
  64932. * @param renderHeight defines the rendering height
  64933. * @returns a new Viewport
  64934. */
  64935. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  64936. /**
  64937. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  64938. * @param renderWidth defines the rendering width
  64939. * @param renderHeight defines the rendering height
  64940. * @param ref defines the target viewport
  64941. * @returns the current viewport
  64942. */
  64943. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  64944. /**
  64945. * Returns a new Viewport copied from the current one
  64946. * @returns a new Viewport
  64947. */
  64948. clone(): Viewport;
  64949. }
  64950. }
  64951. declare module BABYLON {
  64952. /**
  64953. * Class containing a set of static utilities functions for arrays.
  64954. */
  64955. export class ArrayTools {
  64956. /**
  64957. * Returns an array of the given size filled with element built from the given constructor and the paramters
  64958. * @param size the number of element to construct and put in the array
  64959. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  64960. * @returns a new array filled with new objects
  64961. */
  64962. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  64963. }
  64964. }
  64965. declare module BABYLON {
  64966. /**
  64967. * @hidden
  64968. */
  64969. export interface IColor4Like {
  64970. r: float;
  64971. g: float;
  64972. b: float;
  64973. a: float;
  64974. }
  64975. /**
  64976. * @hidden
  64977. */
  64978. export interface IColor3Like {
  64979. r: float;
  64980. g: float;
  64981. b: float;
  64982. }
  64983. /**
  64984. * @hidden
  64985. */
  64986. export interface IVector4Like {
  64987. x: float;
  64988. y: float;
  64989. z: float;
  64990. w: float;
  64991. }
  64992. /**
  64993. * @hidden
  64994. */
  64995. export interface IVector3Like {
  64996. x: float;
  64997. y: float;
  64998. z: float;
  64999. }
  65000. /**
  65001. * @hidden
  65002. */
  65003. export interface IVector2Like {
  65004. x: float;
  65005. y: float;
  65006. }
  65007. /**
  65008. * @hidden
  65009. */
  65010. export interface IMatrixLike {
  65011. toArray(): DeepImmutable<Float32Array>;
  65012. updateFlag: int;
  65013. }
  65014. /**
  65015. * @hidden
  65016. */
  65017. export interface IViewportLike {
  65018. x: float;
  65019. y: float;
  65020. width: float;
  65021. height: float;
  65022. }
  65023. /**
  65024. * @hidden
  65025. */
  65026. export interface IPlaneLike {
  65027. normal: IVector3Like;
  65028. d: float;
  65029. normalize(): void;
  65030. }
  65031. }
  65032. declare module BABYLON {
  65033. /**
  65034. * Class representing a vector containing 2 coordinates
  65035. */
  65036. export class Vector2 {
  65037. /** defines the first coordinate */
  65038. x: number;
  65039. /** defines the second coordinate */
  65040. y: number;
  65041. /**
  65042. * Creates a new Vector2 from the given x and y coordinates
  65043. * @param x defines the first coordinate
  65044. * @param y defines the second coordinate
  65045. */
  65046. constructor(
  65047. /** defines the first coordinate */
  65048. x?: number,
  65049. /** defines the second coordinate */
  65050. y?: number);
  65051. /**
  65052. * Gets a string with the Vector2 coordinates
  65053. * @returns a string with the Vector2 coordinates
  65054. */
  65055. toString(): string;
  65056. /**
  65057. * Gets class name
  65058. * @returns the string "Vector2"
  65059. */
  65060. getClassName(): string;
  65061. /**
  65062. * Gets current vector hash code
  65063. * @returns the Vector2 hash code as a number
  65064. */
  65065. getHashCode(): number;
  65066. /**
  65067. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65068. * @param array defines the source array
  65069. * @param index defines the offset in source array
  65070. * @returns the current Vector2
  65071. */
  65072. toArray(array: FloatArray, index?: number): Vector2;
  65073. /**
  65074. * Copy the current vector to an array
  65075. * @returns a new array with 2 elements: the Vector2 coordinates.
  65076. */
  65077. asArray(): number[];
  65078. /**
  65079. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65080. * @param source defines the source Vector2
  65081. * @returns the current updated Vector2
  65082. */
  65083. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65084. /**
  65085. * Sets the Vector2 coordinates with the given floats
  65086. * @param x defines the first coordinate
  65087. * @param y defines the second coordinate
  65088. * @returns the current updated Vector2
  65089. */
  65090. copyFromFloats(x: number, y: number): Vector2;
  65091. /**
  65092. * Sets the Vector2 coordinates with the given floats
  65093. * @param x defines the first coordinate
  65094. * @param y defines the second coordinate
  65095. * @returns the current updated Vector2
  65096. */
  65097. set(x: number, y: number): Vector2;
  65098. /**
  65099. * Add another vector with the current one
  65100. * @param otherVector defines the other vector
  65101. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65102. */
  65103. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65104. /**
  65105. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65106. * @param otherVector defines the other vector
  65107. * @param result defines the target vector
  65108. * @returns the unmodified current Vector2
  65109. */
  65110. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65111. /**
  65112. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65113. * @param otherVector defines the other vector
  65114. * @returns the current updated Vector2
  65115. */
  65116. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65117. /**
  65118. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65119. * @param otherVector defines the other vector
  65120. * @returns a new Vector2
  65121. */
  65122. addVector3(otherVector: Vector3): Vector2;
  65123. /**
  65124. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65125. * @param otherVector defines the other vector
  65126. * @returns a new Vector2
  65127. */
  65128. subtract(otherVector: Vector2): Vector2;
  65129. /**
  65130. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  65131. * @param otherVector defines the other vector
  65132. * @param result defines the target vector
  65133. * @returns the unmodified current Vector2
  65134. */
  65135. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65136. /**
  65137. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  65138. * @param otherVector defines the other vector
  65139. * @returns the current updated Vector2
  65140. */
  65141. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65142. /**
  65143. * Multiplies in place the current Vector2 coordinates by the given ones
  65144. * @param otherVector defines the other vector
  65145. * @returns the current updated Vector2
  65146. */
  65147. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65148. /**
  65149. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  65150. * @param otherVector defines the other vector
  65151. * @returns a new Vector2
  65152. */
  65153. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  65154. /**
  65155. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  65156. * @param otherVector defines the other vector
  65157. * @param result defines the target vector
  65158. * @returns the unmodified current Vector2
  65159. */
  65160. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65161. /**
  65162. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  65163. * @param x defines the first coordinate
  65164. * @param y defines the second coordinate
  65165. * @returns a new Vector2
  65166. */
  65167. multiplyByFloats(x: number, y: number): Vector2;
  65168. /**
  65169. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  65170. * @param otherVector defines the other vector
  65171. * @returns a new Vector2
  65172. */
  65173. divide(otherVector: Vector2): Vector2;
  65174. /**
  65175. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  65176. * @param otherVector defines the other vector
  65177. * @param result defines the target vector
  65178. * @returns the unmodified current Vector2
  65179. */
  65180. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65181. /**
  65182. * Divides the current Vector2 coordinates by the given ones
  65183. * @param otherVector defines the other vector
  65184. * @returns the current updated Vector2
  65185. */
  65186. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65187. /**
  65188. * Gets a new Vector2 with current Vector2 negated coordinates
  65189. * @returns a new Vector2
  65190. */
  65191. negate(): Vector2;
  65192. /**
  65193. * Multiply the Vector2 coordinates by scale
  65194. * @param scale defines the scaling factor
  65195. * @returns the current updated Vector2
  65196. */
  65197. scaleInPlace(scale: number): Vector2;
  65198. /**
  65199. * Returns a new Vector2 scaled by "scale" from the current Vector2
  65200. * @param scale defines the scaling factor
  65201. * @returns a new Vector2
  65202. */
  65203. scale(scale: number): Vector2;
  65204. /**
  65205. * Scale the current Vector2 values by a factor to a given Vector2
  65206. * @param scale defines the scale factor
  65207. * @param result defines the Vector2 object where to store the result
  65208. * @returns the unmodified current Vector2
  65209. */
  65210. scaleToRef(scale: number, result: Vector2): Vector2;
  65211. /**
  65212. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  65213. * @param scale defines the scale factor
  65214. * @param result defines the Vector2 object where to store the result
  65215. * @returns the unmodified current Vector2
  65216. */
  65217. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  65218. /**
  65219. * Gets a boolean if two vectors are equals
  65220. * @param otherVector defines the other vector
  65221. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  65222. */
  65223. equals(otherVector: DeepImmutable<Vector2>): boolean;
  65224. /**
  65225. * Gets a boolean if two vectors are equals (using an epsilon value)
  65226. * @param otherVector defines the other vector
  65227. * @param epsilon defines the minimal distance to consider equality
  65228. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  65229. */
  65230. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  65231. /**
  65232. * Gets a new Vector2 from current Vector2 floored values
  65233. * @returns a new Vector2
  65234. */
  65235. floor(): Vector2;
  65236. /**
  65237. * Gets a new Vector2 from current Vector2 floored values
  65238. * @returns a new Vector2
  65239. */
  65240. fract(): Vector2;
  65241. /**
  65242. * Gets the length of the vector
  65243. * @returns the vector length (float)
  65244. */
  65245. length(): number;
  65246. /**
  65247. * Gets the vector squared length
  65248. * @returns the vector squared length (float)
  65249. */
  65250. lengthSquared(): number;
  65251. /**
  65252. * Normalize the vector
  65253. * @returns the current updated Vector2
  65254. */
  65255. normalize(): Vector2;
  65256. /**
  65257. * Gets a new Vector2 copied from the Vector2
  65258. * @returns a new Vector2
  65259. */
  65260. clone(): Vector2;
  65261. /**
  65262. * Gets a new Vector2(0, 0)
  65263. * @returns a new Vector2
  65264. */
  65265. static Zero(): Vector2;
  65266. /**
  65267. * Gets a new Vector2(1, 1)
  65268. * @returns a new Vector2
  65269. */
  65270. static One(): Vector2;
  65271. /**
  65272. * Gets a new Vector2 set from the given index element of the given array
  65273. * @param array defines the data source
  65274. * @param offset defines the offset in the data source
  65275. * @returns a new Vector2
  65276. */
  65277. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  65278. /**
  65279. * Sets "result" from the given index element of the given array
  65280. * @param array defines the data source
  65281. * @param offset defines the offset in the data source
  65282. * @param result defines the target vector
  65283. */
  65284. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  65285. /**
  65286. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  65287. * @param value1 defines 1st point of control
  65288. * @param value2 defines 2nd point of control
  65289. * @param value3 defines 3rd point of control
  65290. * @param value4 defines 4th point of control
  65291. * @param amount defines the interpolation factor
  65292. * @returns a new Vector2
  65293. */
  65294. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  65295. /**
  65296. * 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".
  65297. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  65298. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  65299. * @param value defines the value to clamp
  65300. * @param min defines the lower limit
  65301. * @param max defines the upper limit
  65302. * @returns a new Vector2
  65303. */
  65304. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  65305. /**
  65306. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  65307. * @param value1 defines the 1st control point
  65308. * @param tangent1 defines the outgoing tangent
  65309. * @param value2 defines the 2nd control point
  65310. * @param tangent2 defines the incoming tangent
  65311. * @param amount defines the interpolation factor
  65312. * @returns a new Vector2
  65313. */
  65314. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  65315. /**
  65316. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  65317. * @param start defines the start vector
  65318. * @param end defines the end vector
  65319. * @param amount defines the interpolation factor
  65320. * @returns a new Vector2
  65321. */
  65322. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  65323. /**
  65324. * Gets the dot product of the vector "left" and the vector "right"
  65325. * @param left defines first vector
  65326. * @param right defines second vector
  65327. * @returns the dot product (float)
  65328. */
  65329. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  65330. /**
  65331. * Returns a new Vector2 equal to the normalized given vector
  65332. * @param vector defines the vector to normalize
  65333. * @returns a new Vector2
  65334. */
  65335. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  65336. /**
  65337. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  65338. * @param left defines 1st vector
  65339. * @param right defines 2nd vector
  65340. * @returns a new Vector2
  65341. */
  65342. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65343. /**
  65344. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  65345. * @param left defines 1st vector
  65346. * @param right defines 2nd vector
  65347. * @returns a new Vector2
  65348. */
  65349. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65350. /**
  65351. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  65352. * @param vector defines the vector to transform
  65353. * @param transformation defines the matrix to apply
  65354. * @returns a new Vector2
  65355. */
  65356. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  65357. /**
  65358. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  65359. * @param vector defines the vector to transform
  65360. * @param transformation defines the matrix to apply
  65361. * @param result defines the target vector
  65362. */
  65363. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  65364. /**
  65365. * Determines if a given vector is included in a triangle
  65366. * @param p defines the vector to test
  65367. * @param p0 defines 1st triangle point
  65368. * @param p1 defines 2nd triangle point
  65369. * @param p2 defines 3rd triangle point
  65370. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  65371. */
  65372. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  65373. /**
  65374. * Gets the distance between the vectors "value1" and "value2"
  65375. * @param value1 defines first vector
  65376. * @param value2 defines second vector
  65377. * @returns the distance between vectors
  65378. */
  65379. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65380. /**
  65381. * Returns the squared distance between the vectors "value1" and "value2"
  65382. * @param value1 defines first vector
  65383. * @param value2 defines second vector
  65384. * @returns the squared distance between vectors
  65385. */
  65386. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65387. /**
  65388. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  65389. * @param value1 defines first vector
  65390. * @param value2 defines second vector
  65391. * @returns a new Vector2
  65392. */
  65393. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  65394. /**
  65395. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  65396. * @param p defines the middle point
  65397. * @param segA defines one point of the segment
  65398. * @param segB defines the other point of the segment
  65399. * @returns the shortest distance
  65400. */
  65401. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  65402. }
  65403. /**
  65404. * Classed used to store (x,y,z) vector representation
  65405. * A Vector3 is the main object used in 3D geometry
  65406. * It can represent etiher the coordinates of a point the space, either a direction
  65407. * Reminder: js uses a left handed forward facing system
  65408. */
  65409. export class Vector3 {
  65410. /**
  65411. * Defines the first coordinates (on X axis)
  65412. */
  65413. x: number;
  65414. /**
  65415. * Defines the second coordinates (on Y axis)
  65416. */
  65417. y: number;
  65418. /**
  65419. * Defines the third coordinates (on Z axis)
  65420. */
  65421. z: number;
  65422. private static _UpReadOnly;
  65423. private static _ZeroReadOnly;
  65424. /**
  65425. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  65426. * @param x defines the first coordinates (on X axis)
  65427. * @param y defines the second coordinates (on Y axis)
  65428. * @param z defines the third coordinates (on Z axis)
  65429. */
  65430. constructor(
  65431. /**
  65432. * Defines the first coordinates (on X axis)
  65433. */
  65434. x?: number,
  65435. /**
  65436. * Defines the second coordinates (on Y axis)
  65437. */
  65438. y?: number,
  65439. /**
  65440. * Defines the third coordinates (on Z axis)
  65441. */
  65442. z?: number);
  65443. /**
  65444. * Creates a string representation of the Vector3
  65445. * @returns a string with the Vector3 coordinates.
  65446. */
  65447. toString(): string;
  65448. /**
  65449. * Gets the class name
  65450. * @returns the string "Vector3"
  65451. */
  65452. getClassName(): string;
  65453. /**
  65454. * Creates the Vector3 hash code
  65455. * @returns a number which tends to be unique between Vector3 instances
  65456. */
  65457. getHashCode(): number;
  65458. /**
  65459. * Creates an array containing three elements : the coordinates of the Vector3
  65460. * @returns a new array of numbers
  65461. */
  65462. asArray(): number[];
  65463. /**
  65464. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  65465. * @param array defines the destination array
  65466. * @param index defines the offset in the destination array
  65467. * @returns the current Vector3
  65468. */
  65469. toArray(array: FloatArray, index?: number): Vector3;
  65470. /**
  65471. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  65472. * @returns a new Quaternion object, computed from the Vector3 coordinates
  65473. */
  65474. toQuaternion(): Quaternion;
  65475. /**
  65476. * Adds the given vector to the current Vector3
  65477. * @param otherVector defines the second operand
  65478. * @returns the current updated Vector3
  65479. */
  65480. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65481. /**
  65482. * Adds the given coordinates to the current Vector3
  65483. * @param x defines the x coordinate of the operand
  65484. * @param y defines the y coordinate of the operand
  65485. * @param z defines the z coordinate of the operand
  65486. * @returns the current updated Vector3
  65487. */
  65488. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65489. /**
  65490. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  65491. * @param otherVector defines the second operand
  65492. * @returns the resulting Vector3
  65493. */
  65494. add(otherVector: DeepImmutable<Vector3>): Vector3;
  65495. /**
  65496. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  65497. * @param otherVector defines the second operand
  65498. * @param result defines the Vector3 object where to store the result
  65499. * @returns the current Vector3
  65500. */
  65501. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65502. /**
  65503. * Subtract the given vector from the current Vector3
  65504. * @param otherVector defines the second operand
  65505. * @returns the current updated Vector3
  65506. */
  65507. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65508. /**
  65509. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  65510. * @param otherVector defines the second operand
  65511. * @returns the resulting Vector3
  65512. */
  65513. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  65514. /**
  65515. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  65516. * @param otherVector defines the second operand
  65517. * @param result defines the Vector3 object where to store the result
  65518. * @returns the current Vector3
  65519. */
  65520. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65521. /**
  65522. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  65523. * @param x defines the x coordinate of the operand
  65524. * @param y defines the y coordinate of the operand
  65525. * @param z defines the z coordinate of the operand
  65526. * @returns the resulting Vector3
  65527. */
  65528. subtractFromFloats(x: number, y: number, z: number): Vector3;
  65529. /**
  65530. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  65531. * @param x defines the x coordinate of the operand
  65532. * @param y defines the y coordinate of the operand
  65533. * @param z defines the z coordinate of the operand
  65534. * @param result defines the Vector3 object where to store the result
  65535. * @returns the current Vector3
  65536. */
  65537. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  65538. /**
  65539. * Gets a new Vector3 set with the current Vector3 negated coordinates
  65540. * @returns a new Vector3
  65541. */
  65542. negate(): Vector3;
  65543. /**
  65544. * Multiplies the Vector3 coordinates by the float "scale"
  65545. * @param scale defines the multiplier factor
  65546. * @returns the current updated Vector3
  65547. */
  65548. scaleInPlace(scale: number): Vector3;
  65549. /**
  65550. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  65551. * @param scale defines the multiplier factor
  65552. * @returns a new Vector3
  65553. */
  65554. scale(scale: number): Vector3;
  65555. /**
  65556. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  65557. * @param scale defines the multiplier factor
  65558. * @param result defines the Vector3 object where to store the result
  65559. * @returns the current Vector3
  65560. */
  65561. scaleToRef(scale: number, result: Vector3): Vector3;
  65562. /**
  65563. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  65564. * @param scale defines the scale factor
  65565. * @param result defines the Vector3 object where to store the result
  65566. * @returns the unmodified current Vector3
  65567. */
  65568. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  65569. /**
  65570. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  65571. * @param otherVector defines the second operand
  65572. * @returns true if both vectors are equals
  65573. */
  65574. equals(otherVector: DeepImmutable<Vector3>): boolean;
  65575. /**
  65576. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  65577. * @param otherVector defines the second operand
  65578. * @param epsilon defines the minimal distance to define values as equals
  65579. * @returns true if both vectors are distant less than epsilon
  65580. */
  65581. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  65582. /**
  65583. * Returns true if the current Vector3 coordinates equals the given floats
  65584. * @param x defines the x coordinate of the operand
  65585. * @param y defines the y coordinate of the operand
  65586. * @param z defines the z coordinate of the operand
  65587. * @returns true if both vectors are equals
  65588. */
  65589. equalsToFloats(x: number, y: number, z: number): boolean;
  65590. /**
  65591. * Multiplies the current Vector3 coordinates by the given ones
  65592. * @param otherVector defines the second operand
  65593. * @returns the current updated Vector3
  65594. */
  65595. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65596. /**
  65597. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  65598. * @param otherVector defines the second operand
  65599. * @returns the new Vector3
  65600. */
  65601. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  65602. /**
  65603. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  65604. * @param otherVector defines the second operand
  65605. * @param result defines the Vector3 object where to store the result
  65606. * @returns the current Vector3
  65607. */
  65608. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65609. /**
  65610. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  65611. * @param x defines the x coordinate of the operand
  65612. * @param y defines the y coordinate of the operand
  65613. * @param z defines the z coordinate of the operand
  65614. * @returns the new Vector3
  65615. */
  65616. multiplyByFloats(x: number, y: number, z: number): Vector3;
  65617. /**
  65618. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  65619. * @param otherVector defines the second operand
  65620. * @returns the new Vector3
  65621. */
  65622. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  65623. /**
  65624. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  65625. * @param otherVector defines the second operand
  65626. * @param result defines the Vector3 object where to store the result
  65627. * @returns the current Vector3
  65628. */
  65629. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65630. /**
  65631. * Divides the current Vector3 coordinates by the given ones.
  65632. * @param otherVector defines the second operand
  65633. * @returns the current updated Vector3
  65634. */
  65635. divideInPlace(otherVector: Vector3): Vector3;
  65636. /**
  65637. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  65638. * @param other defines the second operand
  65639. * @returns the current updated Vector3
  65640. */
  65641. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65642. /**
  65643. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  65644. * @param other defines the second operand
  65645. * @returns the current updated Vector3
  65646. */
  65647. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65648. /**
  65649. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  65650. * @param x defines the x coordinate of the operand
  65651. * @param y defines the y coordinate of the operand
  65652. * @param z defines the z coordinate of the operand
  65653. * @returns the current updated Vector3
  65654. */
  65655. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65656. /**
  65657. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  65658. * @param x defines the x coordinate of the operand
  65659. * @param y defines the y coordinate of the operand
  65660. * @param z defines the z coordinate of the operand
  65661. * @returns the current updated Vector3
  65662. */
  65663. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65664. /**
  65665. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  65666. * Check if is non uniform within a certain amount of decimal places to account for this
  65667. * @param epsilon the amount the values can differ
  65668. * @returns if the the vector is non uniform to a certain number of decimal places
  65669. */
  65670. isNonUniformWithinEpsilon(epsilon: number): boolean;
  65671. /**
  65672. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  65673. */
  65674. readonly isNonUniform: boolean;
  65675. /**
  65676. * Gets a new Vector3 from current Vector3 floored values
  65677. * @returns a new Vector3
  65678. */
  65679. floor(): Vector3;
  65680. /**
  65681. * Gets a new Vector3 from current Vector3 floored values
  65682. * @returns a new Vector3
  65683. */
  65684. fract(): Vector3;
  65685. /**
  65686. * Gets the length of the Vector3
  65687. * @returns the length of the Vector3
  65688. */
  65689. length(): number;
  65690. /**
  65691. * Gets the squared length of the Vector3
  65692. * @returns squared length of the Vector3
  65693. */
  65694. lengthSquared(): number;
  65695. /**
  65696. * Normalize the current Vector3.
  65697. * Please note that this is an in place operation.
  65698. * @returns the current updated Vector3
  65699. */
  65700. normalize(): Vector3;
  65701. /**
  65702. * Reorders the x y z properties of the vector in place
  65703. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  65704. * @returns the current updated vector
  65705. */
  65706. reorderInPlace(order: string): this;
  65707. /**
  65708. * Rotates the vector around 0,0,0 by a quaternion
  65709. * @param quaternion the rotation quaternion
  65710. * @param result vector to store the result
  65711. * @returns the resulting vector
  65712. */
  65713. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  65714. /**
  65715. * Rotates a vector around a given point
  65716. * @param quaternion the rotation quaternion
  65717. * @param point the point to rotate around
  65718. * @param result vector to store the result
  65719. * @returns the resulting vector
  65720. */
  65721. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  65722. /**
  65723. * Normalize the current Vector3 with the given input length.
  65724. * Please note that this is an in place operation.
  65725. * @param len the length of the vector
  65726. * @returns the current updated Vector3
  65727. */
  65728. normalizeFromLength(len: number): Vector3;
  65729. /**
  65730. * Normalize the current Vector3 to a new vector
  65731. * @returns the new Vector3
  65732. */
  65733. normalizeToNew(): Vector3;
  65734. /**
  65735. * Normalize the current Vector3 to the reference
  65736. * @param reference define the Vector3 to update
  65737. * @returns the updated Vector3
  65738. */
  65739. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  65740. /**
  65741. * Creates a new Vector3 copied from the current Vector3
  65742. * @returns the new Vector3
  65743. */
  65744. clone(): Vector3;
  65745. /**
  65746. * Copies the given vector coordinates to the current Vector3 ones
  65747. * @param source defines the source Vector3
  65748. * @returns the current updated Vector3
  65749. */
  65750. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  65751. /**
  65752. * Copies the given floats to the current Vector3 coordinates
  65753. * @param x defines the x coordinate of the operand
  65754. * @param y defines the y coordinate of the operand
  65755. * @param z defines the z coordinate of the operand
  65756. * @returns the current updated Vector3
  65757. */
  65758. copyFromFloats(x: number, y: number, z: number): Vector3;
  65759. /**
  65760. * Copies the given floats to the current Vector3 coordinates
  65761. * @param x defines the x coordinate of the operand
  65762. * @param y defines the y coordinate of the operand
  65763. * @param z defines the z coordinate of the operand
  65764. * @returns the current updated Vector3
  65765. */
  65766. set(x: number, y: number, z: number): Vector3;
  65767. /**
  65768. * Copies the given float to the current Vector3 coordinates
  65769. * @param v defines the x, y and z coordinates of the operand
  65770. * @returns the current updated Vector3
  65771. */
  65772. setAll(v: number): Vector3;
  65773. /**
  65774. * Get the clip factor between two vectors
  65775. * @param vector0 defines the first operand
  65776. * @param vector1 defines the second operand
  65777. * @param axis defines the axis to use
  65778. * @param size defines the size along the axis
  65779. * @returns the clip factor
  65780. */
  65781. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  65782. /**
  65783. * Get angle between two vectors
  65784. * @param vector0 angle between vector0 and vector1
  65785. * @param vector1 angle between vector0 and vector1
  65786. * @param normal direction of the normal
  65787. * @return the angle between vector0 and vector1
  65788. */
  65789. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  65790. /**
  65791. * Returns a new Vector3 set from the index "offset" of the given array
  65792. * @param array defines the source array
  65793. * @param offset defines the offset in the source array
  65794. * @returns the new Vector3
  65795. */
  65796. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  65797. /**
  65798. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  65799. * This function is deprecated. Use FromArray instead
  65800. * @param array defines the source array
  65801. * @param offset defines the offset in the source array
  65802. * @returns the new Vector3
  65803. */
  65804. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  65805. /**
  65806. * Sets the given vector "result" with the element values from the index "offset" of the given array
  65807. * @param array defines the source array
  65808. * @param offset defines the offset in the source array
  65809. * @param result defines the Vector3 where to store the result
  65810. */
  65811. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  65812. /**
  65813. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  65814. * This function is deprecated. Use FromArrayToRef instead.
  65815. * @param array defines the source array
  65816. * @param offset defines the offset in the source array
  65817. * @param result defines the Vector3 where to store the result
  65818. */
  65819. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  65820. /**
  65821. * Sets the given vector "result" with the given floats.
  65822. * @param x defines the x coordinate of the source
  65823. * @param y defines the y coordinate of the source
  65824. * @param z defines the z coordinate of the source
  65825. * @param result defines the Vector3 where to store the result
  65826. */
  65827. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  65828. /**
  65829. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  65830. * @returns a new empty Vector3
  65831. */
  65832. static Zero(): Vector3;
  65833. /**
  65834. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  65835. * @returns a new unit Vector3
  65836. */
  65837. static One(): Vector3;
  65838. /**
  65839. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  65840. * @returns a new up Vector3
  65841. */
  65842. static Up(): Vector3;
  65843. /**
  65844. * Gets a up Vector3 that must not be updated
  65845. */
  65846. static readonly UpReadOnly: DeepImmutable<Vector3>;
  65847. /**
  65848. * Gets a zero Vector3 that must not be updated
  65849. */
  65850. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  65851. /**
  65852. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  65853. * @returns a new down Vector3
  65854. */
  65855. static Down(): Vector3;
  65856. /**
  65857. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  65858. * @returns a new forward Vector3
  65859. */
  65860. static Forward(): Vector3;
  65861. /**
  65862. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  65863. * @returns a new forward Vector3
  65864. */
  65865. static Backward(): Vector3;
  65866. /**
  65867. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  65868. * @returns a new right Vector3
  65869. */
  65870. static Right(): Vector3;
  65871. /**
  65872. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  65873. * @returns a new left Vector3
  65874. */
  65875. static Left(): Vector3;
  65876. /**
  65877. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  65878. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  65879. * @param vector defines the Vector3 to transform
  65880. * @param transformation defines the transformation matrix
  65881. * @returns the transformed Vector3
  65882. */
  65883. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  65884. /**
  65885. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  65886. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  65887. * @param vector defines the Vector3 to transform
  65888. * @param transformation defines the transformation matrix
  65889. * @param result defines the Vector3 where to store the result
  65890. */
  65891. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65892. /**
  65893. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  65894. * This method computes tranformed coordinates only, not transformed direction vectors
  65895. * @param x define the x coordinate of the source vector
  65896. * @param y define the y coordinate of the source vector
  65897. * @param z define the z coordinate of the source vector
  65898. * @param transformation defines the transformation matrix
  65899. * @param result defines the Vector3 where to store the result
  65900. */
  65901. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65902. /**
  65903. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  65904. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  65905. * @param vector defines the Vector3 to transform
  65906. * @param transformation defines the transformation matrix
  65907. * @returns the new Vector3
  65908. */
  65909. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  65910. /**
  65911. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  65912. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  65913. * @param vector defines the Vector3 to transform
  65914. * @param transformation defines the transformation matrix
  65915. * @param result defines the Vector3 where to store the result
  65916. */
  65917. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65918. /**
  65919. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  65920. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  65921. * @param x define the x coordinate of the source vector
  65922. * @param y define the y coordinate of the source vector
  65923. * @param z define the z coordinate of the source vector
  65924. * @param transformation defines the transformation matrix
  65925. * @param result defines the Vector3 where to store the result
  65926. */
  65927. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65928. /**
  65929. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  65930. * @param value1 defines the first control point
  65931. * @param value2 defines the second control point
  65932. * @param value3 defines the third control point
  65933. * @param value4 defines the fourth control point
  65934. * @param amount defines the amount on the spline to use
  65935. * @returns the new Vector3
  65936. */
  65937. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  65938. /**
  65939. * 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"
  65940. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  65941. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  65942. * @param value defines the current value
  65943. * @param min defines the lower range value
  65944. * @param max defines the upper range value
  65945. * @returns the new Vector3
  65946. */
  65947. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  65948. /**
  65949. * 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"
  65950. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  65951. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  65952. * @param value defines the current value
  65953. * @param min defines the lower range value
  65954. * @param max defines the upper range value
  65955. * @param result defines the Vector3 where to store the result
  65956. */
  65957. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  65958. /**
  65959. * Checks if a given vector is inside a specific range
  65960. * @param v defines the vector to test
  65961. * @param min defines the minimum range
  65962. * @param max defines the maximum range
  65963. */
  65964. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  65965. /**
  65966. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  65967. * @param value1 defines the first control point
  65968. * @param tangent1 defines the first tangent vector
  65969. * @param value2 defines the second control point
  65970. * @param tangent2 defines the second tangent vector
  65971. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  65972. * @returns the new Vector3
  65973. */
  65974. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  65975. /**
  65976. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  65977. * @param start defines the start value
  65978. * @param end defines the end value
  65979. * @param amount max defines amount between both (between 0 and 1)
  65980. * @returns the new Vector3
  65981. */
  65982. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  65983. /**
  65984. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  65985. * @param start defines the start value
  65986. * @param end defines the end value
  65987. * @param amount max defines amount between both (between 0 and 1)
  65988. * @param result defines the Vector3 where to store the result
  65989. */
  65990. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  65991. /**
  65992. * Returns the dot product (float) between the vectors "left" and "right"
  65993. * @param left defines the left operand
  65994. * @param right defines the right operand
  65995. * @returns the dot product
  65996. */
  65997. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  65998. /**
  65999. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66000. * The cross product is then orthogonal to both "left" and "right"
  66001. * @param left defines the left operand
  66002. * @param right defines the right operand
  66003. * @returns the cross product
  66004. */
  66005. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66006. /**
  66007. * Sets the given vector "result" with the cross product of "left" and "right"
  66008. * The cross product is then orthogonal to both "left" and "right"
  66009. * @param left defines the left operand
  66010. * @param right defines the right operand
  66011. * @param result defines the Vector3 where to store the result
  66012. */
  66013. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66014. /**
  66015. * Returns a new Vector3 as the normalization of the given vector
  66016. * @param vector defines the Vector3 to normalize
  66017. * @returns the new Vector3
  66018. */
  66019. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66020. /**
  66021. * Sets the given vector "result" with the normalization of the given first vector
  66022. * @param vector defines the Vector3 to normalize
  66023. * @param result defines the Vector3 where to store the result
  66024. */
  66025. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66026. /**
  66027. * Project a Vector3 onto screen space
  66028. * @param vector defines the Vector3 to project
  66029. * @param world defines the world matrix to use
  66030. * @param transform defines the transform (view x projection) matrix to use
  66031. * @param viewport defines the screen viewport to use
  66032. * @returns the new Vector3
  66033. */
  66034. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66035. /** @hidden */
  66036. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66037. /**
  66038. * Unproject from screen space to object space
  66039. * @param source defines the screen space Vector3 to use
  66040. * @param viewportWidth defines the current width of the viewport
  66041. * @param viewportHeight defines the current height of the viewport
  66042. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66043. * @param transform defines the transform (view x projection) matrix to use
  66044. * @returns the new Vector3
  66045. */
  66046. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66047. /**
  66048. * Unproject from screen space to object space
  66049. * @param source defines the screen space Vector3 to use
  66050. * @param viewportWidth defines the current width of the viewport
  66051. * @param viewportHeight defines the current height of the viewport
  66052. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66053. * @param view defines the view matrix to use
  66054. * @param projection defines the projection matrix to use
  66055. * @returns the new Vector3
  66056. */
  66057. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66058. /**
  66059. * Unproject from screen space to object space
  66060. * @param source defines the screen space Vector3 to use
  66061. * @param viewportWidth defines the current width of the viewport
  66062. * @param viewportHeight defines the current height of the viewport
  66063. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66064. * @param view defines the view matrix to use
  66065. * @param projection defines the projection matrix to use
  66066. * @param result defines the Vector3 where to store the result
  66067. */
  66068. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66069. /**
  66070. * Unproject from screen space to object space
  66071. * @param sourceX defines the screen space x coordinate to use
  66072. * @param sourceY defines the screen space y coordinate to use
  66073. * @param sourceZ defines the screen space z coordinate to use
  66074. * @param viewportWidth defines the current width of the viewport
  66075. * @param viewportHeight defines the current height of the viewport
  66076. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66077. * @param view defines the view matrix to use
  66078. * @param projection defines the projection matrix to use
  66079. * @param result defines the Vector3 where to store the result
  66080. */
  66081. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66082. /**
  66083. * Gets the minimal coordinate values between two Vector3
  66084. * @param left defines the first operand
  66085. * @param right defines the second operand
  66086. * @returns the new Vector3
  66087. */
  66088. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66089. /**
  66090. * Gets the maximal coordinate values between two Vector3
  66091. * @param left defines the first operand
  66092. * @param right defines the second operand
  66093. * @returns the new Vector3
  66094. */
  66095. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66096. /**
  66097. * Returns the distance between the vectors "value1" and "value2"
  66098. * @param value1 defines the first operand
  66099. * @param value2 defines the second operand
  66100. * @returns the distance
  66101. */
  66102. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66103. /**
  66104. * Returns the squared distance between the vectors "value1" and "value2"
  66105. * @param value1 defines the first operand
  66106. * @param value2 defines the second operand
  66107. * @returns the squared distance
  66108. */
  66109. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66110. /**
  66111. * Returns a new Vector3 located at the center between "value1" and "value2"
  66112. * @param value1 defines the first operand
  66113. * @param value2 defines the second operand
  66114. * @returns the new Vector3
  66115. */
  66116. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66117. /**
  66118. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66119. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66120. * to something in order to rotate it from its local system to the given target system
  66121. * Note: axis1, axis2 and axis3 are normalized during this operation
  66122. * @param axis1 defines the first axis
  66123. * @param axis2 defines the second axis
  66124. * @param axis3 defines the third axis
  66125. * @returns a new Vector3
  66126. */
  66127. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  66128. /**
  66129. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  66130. * @param axis1 defines the first axis
  66131. * @param axis2 defines the second axis
  66132. * @param axis3 defines the third axis
  66133. * @param ref defines the Vector3 where to store the result
  66134. */
  66135. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  66136. }
  66137. /**
  66138. * Vector4 class created for EulerAngle class conversion to Quaternion
  66139. */
  66140. export class Vector4 {
  66141. /** x value of the vector */
  66142. x: number;
  66143. /** y value of the vector */
  66144. y: number;
  66145. /** z value of the vector */
  66146. z: number;
  66147. /** w value of the vector */
  66148. w: number;
  66149. /**
  66150. * Creates a Vector4 object from the given floats.
  66151. * @param x x value of the vector
  66152. * @param y y value of the vector
  66153. * @param z z value of the vector
  66154. * @param w w value of the vector
  66155. */
  66156. constructor(
  66157. /** x value of the vector */
  66158. x: number,
  66159. /** y value of the vector */
  66160. y: number,
  66161. /** z value of the vector */
  66162. z: number,
  66163. /** w value of the vector */
  66164. w: number);
  66165. /**
  66166. * Returns the string with the Vector4 coordinates.
  66167. * @returns a string containing all the vector values
  66168. */
  66169. toString(): string;
  66170. /**
  66171. * Returns the string "Vector4".
  66172. * @returns "Vector4"
  66173. */
  66174. getClassName(): string;
  66175. /**
  66176. * Returns the Vector4 hash code.
  66177. * @returns a unique hash code
  66178. */
  66179. getHashCode(): number;
  66180. /**
  66181. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  66182. * @returns the resulting array
  66183. */
  66184. asArray(): number[];
  66185. /**
  66186. * Populates the given array from the given index with the Vector4 coordinates.
  66187. * @param array array to populate
  66188. * @param index index of the array to start at (default: 0)
  66189. * @returns the Vector4.
  66190. */
  66191. toArray(array: FloatArray, index?: number): Vector4;
  66192. /**
  66193. * Adds the given vector to the current Vector4.
  66194. * @param otherVector the vector to add
  66195. * @returns the updated Vector4.
  66196. */
  66197. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66198. /**
  66199. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  66200. * @param otherVector the vector to add
  66201. * @returns the resulting vector
  66202. */
  66203. add(otherVector: DeepImmutable<Vector4>): Vector4;
  66204. /**
  66205. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  66206. * @param otherVector the vector to add
  66207. * @param result the vector to store the result
  66208. * @returns the current Vector4.
  66209. */
  66210. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66211. /**
  66212. * Subtract in place the given vector from the current Vector4.
  66213. * @param otherVector the vector to subtract
  66214. * @returns the updated Vector4.
  66215. */
  66216. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66217. /**
  66218. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  66219. * @param otherVector the vector to add
  66220. * @returns the new vector with the result
  66221. */
  66222. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  66223. /**
  66224. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  66225. * @param otherVector the vector to subtract
  66226. * @param result the vector to store the result
  66227. * @returns the current Vector4.
  66228. */
  66229. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66230. /**
  66231. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66232. */
  66233. /**
  66234. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66235. * @param x value to subtract
  66236. * @param y value to subtract
  66237. * @param z value to subtract
  66238. * @param w value to subtract
  66239. * @returns new vector containing the result
  66240. */
  66241. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66242. /**
  66243. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66244. * @param x value to subtract
  66245. * @param y value to subtract
  66246. * @param z value to subtract
  66247. * @param w value to subtract
  66248. * @param result the vector to store the result in
  66249. * @returns the current Vector4.
  66250. */
  66251. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  66252. /**
  66253. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  66254. * @returns a new vector with the negated values
  66255. */
  66256. negate(): Vector4;
  66257. /**
  66258. * Multiplies the current Vector4 coordinates by scale (float).
  66259. * @param scale the number to scale with
  66260. * @returns the updated Vector4.
  66261. */
  66262. scaleInPlace(scale: number): Vector4;
  66263. /**
  66264. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  66265. * @param scale the number to scale with
  66266. * @returns a new vector with the result
  66267. */
  66268. scale(scale: number): Vector4;
  66269. /**
  66270. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  66271. * @param scale the number to scale with
  66272. * @param result a vector to store the result in
  66273. * @returns the current Vector4.
  66274. */
  66275. scaleToRef(scale: number, result: Vector4): Vector4;
  66276. /**
  66277. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  66278. * @param scale defines the scale factor
  66279. * @param result defines the Vector4 object where to store the result
  66280. * @returns the unmodified current Vector4
  66281. */
  66282. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  66283. /**
  66284. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  66285. * @param otherVector the vector to compare against
  66286. * @returns true if they are equal
  66287. */
  66288. equals(otherVector: DeepImmutable<Vector4>): boolean;
  66289. /**
  66290. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  66291. * @param otherVector vector to compare against
  66292. * @param epsilon (Default: very small number)
  66293. * @returns true if they are equal
  66294. */
  66295. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  66296. /**
  66297. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  66298. * @param x x value to compare against
  66299. * @param y y value to compare against
  66300. * @param z z value to compare against
  66301. * @param w w value to compare against
  66302. * @returns true if equal
  66303. */
  66304. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  66305. /**
  66306. * Multiplies in place the current Vector4 by the given one.
  66307. * @param otherVector vector to multiple with
  66308. * @returns the updated Vector4.
  66309. */
  66310. multiplyInPlace(otherVector: Vector4): Vector4;
  66311. /**
  66312. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  66313. * @param otherVector vector to multiple with
  66314. * @returns resulting new vector
  66315. */
  66316. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  66317. /**
  66318. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  66319. * @param otherVector vector to multiple with
  66320. * @param result vector to store the result
  66321. * @returns the current Vector4.
  66322. */
  66323. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66324. /**
  66325. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  66326. * @param x x value multiply with
  66327. * @param y y value multiply with
  66328. * @param z z value multiply with
  66329. * @param w w value multiply with
  66330. * @returns resulting new vector
  66331. */
  66332. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  66333. /**
  66334. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  66335. * @param otherVector vector to devide with
  66336. * @returns resulting new vector
  66337. */
  66338. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  66339. /**
  66340. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  66341. * @param otherVector vector to devide with
  66342. * @param result vector to store the result
  66343. * @returns the current Vector4.
  66344. */
  66345. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66346. /**
  66347. * Divides the current Vector3 coordinates by the given ones.
  66348. * @param otherVector vector to devide with
  66349. * @returns the updated Vector3.
  66350. */
  66351. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66352. /**
  66353. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  66354. * @param other defines the second operand
  66355. * @returns the current updated Vector4
  66356. */
  66357. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66358. /**
  66359. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  66360. * @param other defines the second operand
  66361. * @returns the current updated Vector4
  66362. */
  66363. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66364. /**
  66365. * Gets a new Vector4 from current Vector4 floored values
  66366. * @returns a new Vector4
  66367. */
  66368. floor(): Vector4;
  66369. /**
  66370. * Gets a new Vector4 from current Vector3 floored values
  66371. * @returns a new Vector4
  66372. */
  66373. fract(): Vector4;
  66374. /**
  66375. * Returns the Vector4 length (float).
  66376. * @returns the length
  66377. */
  66378. length(): number;
  66379. /**
  66380. * Returns the Vector4 squared length (float).
  66381. * @returns the length squared
  66382. */
  66383. lengthSquared(): number;
  66384. /**
  66385. * Normalizes in place the Vector4.
  66386. * @returns the updated Vector4.
  66387. */
  66388. normalize(): Vector4;
  66389. /**
  66390. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  66391. * @returns this converted to a new vector3
  66392. */
  66393. toVector3(): Vector3;
  66394. /**
  66395. * Returns a new Vector4 copied from the current one.
  66396. * @returns the new cloned vector
  66397. */
  66398. clone(): Vector4;
  66399. /**
  66400. * Updates the current Vector4 with the given one coordinates.
  66401. * @param source the source vector to copy from
  66402. * @returns the updated Vector4.
  66403. */
  66404. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  66405. /**
  66406. * Updates the current Vector4 coordinates with the given floats.
  66407. * @param x float to copy from
  66408. * @param y float to copy from
  66409. * @param z float to copy from
  66410. * @param w float to copy from
  66411. * @returns the updated Vector4.
  66412. */
  66413. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66414. /**
  66415. * Updates the current Vector4 coordinates with the given floats.
  66416. * @param x float to set from
  66417. * @param y float to set from
  66418. * @param z float to set from
  66419. * @param w float to set from
  66420. * @returns the updated Vector4.
  66421. */
  66422. set(x: number, y: number, z: number, w: number): Vector4;
  66423. /**
  66424. * Copies the given float to the current Vector3 coordinates
  66425. * @param v defines the x, y, z and w coordinates of the operand
  66426. * @returns the current updated Vector3
  66427. */
  66428. setAll(v: number): Vector4;
  66429. /**
  66430. * Returns a new Vector4 set from the starting index of the given array.
  66431. * @param array the array to pull values from
  66432. * @param offset the offset into the array to start at
  66433. * @returns the new vector
  66434. */
  66435. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  66436. /**
  66437. * Updates the given vector "result" from the starting index of the given array.
  66438. * @param array the array to pull values from
  66439. * @param offset the offset into the array to start at
  66440. * @param result the vector to store the result in
  66441. */
  66442. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  66443. /**
  66444. * Updates the given vector "result" from the starting index of the given Float32Array.
  66445. * @param array the array to pull values from
  66446. * @param offset the offset into the array to start at
  66447. * @param result the vector to store the result in
  66448. */
  66449. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  66450. /**
  66451. * Updates the given vector "result" coordinates from the given floats.
  66452. * @param x float to set from
  66453. * @param y float to set from
  66454. * @param z float to set from
  66455. * @param w float to set from
  66456. * @param result the vector to the floats in
  66457. */
  66458. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  66459. /**
  66460. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  66461. * @returns the new vector
  66462. */
  66463. static Zero(): Vector4;
  66464. /**
  66465. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  66466. * @returns the new vector
  66467. */
  66468. static One(): Vector4;
  66469. /**
  66470. * Returns a new normalized Vector4 from the given one.
  66471. * @param vector the vector to normalize
  66472. * @returns the vector
  66473. */
  66474. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  66475. /**
  66476. * Updates the given vector "result" from the normalization of the given one.
  66477. * @param vector the vector to normalize
  66478. * @param result the vector to store the result in
  66479. */
  66480. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  66481. /**
  66482. * Returns a vector with the minimum values from the left and right vectors
  66483. * @param left left vector to minimize
  66484. * @param right right vector to minimize
  66485. * @returns a new vector with the minimum of the left and right vector values
  66486. */
  66487. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66488. /**
  66489. * Returns a vector with the maximum values from the left and right vectors
  66490. * @param left left vector to maximize
  66491. * @param right right vector to maximize
  66492. * @returns a new vector with the maximum of the left and right vector values
  66493. */
  66494. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66495. /**
  66496. * Returns the distance (float) between the vectors "value1" and "value2".
  66497. * @param value1 value to calulate the distance between
  66498. * @param value2 value to calulate the distance between
  66499. * @return the distance between the two vectors
  66500. */
  66501. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66502. /**
  66503. * Returns the squared distance (float) between the vectors "value1" and "value2".
  66504. * @param value1 value to calulate the distance between
  66505. * @param value2 value to calulate the distance between
  66506. * @return the distance between the two vectors squared
  66507. */
  66508. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66509. /**
  66510. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  66511. * @param value1 value to calulate the center between
  66512. * @param value2 value to calulate the center between
  66513. * @return the center between the two vectors
  66514. */
  66515. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  66516. /**
  66517. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  66518. * This methods computes transformed normalized direction vectors only.
  66519. * @param vector the vector to transform
  66520. * @param transformation the transformation matrix to apply
  66521. * @returns the new vector
  66522. */
  66523. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  66524. /**
  66525. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  66526. * This methods computes transformed normalized direction vectors only.
  66527. * @param vector the vector to transform
  66528. * @param transformation the transformation matrix to apply
  66529. * @param result the vector to store the result in
  66530. */
  66531. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66532. /**
  66533. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  66534. * This methods computes transformed normalized direction vectors only.
  66535. * @param x value to transform
  66536. * @param y value to transform
  66537. * @param z value to transform
  66538. * @param w value to transform
  66539. * @param transformation the transformation matrix to apply
  66540. * @param result the vector to store the results in
  66541. */
  66542. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66543. /**
  66544. * Creates a new Vector4 from a Vector3
  66545. * @param source defines the source data
  66546. * @param w defines the 4th component (default is 0)
  66547. * @returns a new Vector4
  66548. */
  66549. static FromVector3(source: Vector3, w?: number): Vector4;
  66550. }
  66551. /**
  66552. * Class used to store quaternion data
  66553. * @see https://en.wikipedia.org/wiki/Quaternion
  66554. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  66555. */
  66556. export class Quaternion {
  66557. /** defines the first component (0 by default) */
  66558. x: number;
  66559. /** defines the second component (0 by default) */
  66560. y: number;
  66561. /** defines the third component (0 by default) */
  66562. z: number;
  66563. /** defines the fourth component (1.0 by default) */
  66564. w: number;
  66565. /**
  66566. * Creates a new Quaternion from the given floats
  66567. * @param x defines the first component (0 by default)
  66568. * @param y defines the second component (0 by default)
  66569. * @param z defines the third component (0 by default)
  66570. * @param w defines the fourth component (1.0 by default)
  66571. */
  66572. constructor(
  66573. /** defines the first component (0 by default) */
  66574. x?: number,
  66575. /** defines the second component (0 by default) */
  66576. y?: number,
  66577. /** defines the third component (0 by default) */
  66578. z?: number,
  66579. /** defines the fourth component (1.0 by default) */
  66580. w?: number);
  66581. /**
  66582. * Gets a string representation for the current quaternion
  66583. * @returns a string with the Quaternion coordinates
  66584. */
  66585. toString(): string;
  66586. /**
  66587. * Gets the class name of the quaternion
  66588. * @returns the string "Quaternion"
  66589. */
  66590. getClassName(): string;
  66591. /**
  66592. * Gets a hash code for this quaternion
  66593. * @returns the quaternion hash code
  66594. */
  66595. getHashCode(): number;
  66596. /**
  66597. * Copy the quaternion to an array
  66598. * @returns a new array populated with 4 elements from the quaternion coordinates
  66599. */
  66600. asArray(): number[];
  66601. /**
  66602. * Check if two quaternions are equals
  66603. * @param otherQuaternion defines the second operand
  66604. * @return true if the current quaternion and the given one coordinates are strictly equals
  66605. */
  66606. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  66607. /**
  66608. * Clone the current quaternion
  66609. * @returns a new quaternion copied from the current one
  66610. */
  66611. clone(): Quaternion;
  66612. /**
  66613. * Copy a quaternion to the current one
  66614. * @param other defines the other quaternion
  66615. * @returns the updated current quaternion
  66616. */
  66617. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  66618. /**
  66619. * Updates the current quaternion with the given float coordinates
  66620. * @param x defines the x coordinate
  66621. * @param y defines the y coordinate
  66622. * @param z defines the z coordinate
  66623. * @param w defines the w coordinate
  66624. * @returns the updated current quaternion
  66625. */
  66626. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  66627. /**
  66628. * Updates the current quaternion from the given float coordinates
  66629. * @param x defines the x coordinate
  66630. * @param y defines the y coordinate
  66631. * @param z defines the z coordinate
  66632. * @param w defines the w coordinate
  66633. * @returns the updated current quaternion
  66634. */
  66635. set(x: number, y: number, z: number, w: number): Quaternion;
  66636. /**
  66637. * Adds two quaternions
  66638. * @param other defines the second operand
  66639. * @returns a new quaternion as the addition result of the given one and the current quaternion
  66640. */
  66641. add(other: DeepImmutable<Quaternion>): Quaternion;
  66642. /**
  66643. * Add a quaternion to the current one
  66644. * @param other defines the quaternion to add
  66645. * @returns the current quaternion
  66646. */
  66647. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  66648. /**
  66649. * Subtract two quaternions
  66650. * @param other defines the second operand
  66651. * @returns a new quaternion as the subtraction result of the given one from the current one
  66652. */
  66653. subtract(other: Quaternion): Quaternion;
  66654. /**
  66655. * Multiplies the current quaternion by a scale factor
  66656. * @param value defines the scale factor
  66657. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  66658. */
  66659. scale(value: number): Quaternion;
  66660. /**
  66661. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  66662. * @param scale defines the scale factor
  66663. * @param result defines the Quaternion object where to store the result
  66664. * @returns the unmodified current quaternion
  66665. */
  66666. scaleToRef(scale: number, result: Quaternion): Quaternion;
  66667. /**
  66668. * Multiplies in place the current quaternion by a scale factor
  66669. * @param value defines the scale factor
  66670. * @returns the current modified quaternion
  66671. */
  66672. scaleInPlace(value: number): Quaternion;
  66673. /**
  66674. * Scale the current quaternion values by a factor and add the result to a given quaternion
  66675. * @param scale defines the scale factor
  66676. * @param result defines the Quaternion object where to store the result
  66677. * @returns the unmodified current quaternion
  66678. */
  66679. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  66680. /**
  66681. * Multiplies two quaternions
  66682. * @param q1 defines the second operand
  66683. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  66684. */
  66685. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  66686. /**
  66687. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  66688. * @param q1 defines the second operand
  66689. * @param result defines the target quaternion
  66690. * @returns the current quaternion
  66691. */
  66692. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  66693. /**
  66694. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  66695. * @param q1 defines the second operand
  66696. * @returns the currentupdated quaternion
  66697. */
  66698. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  66699. /**
  66700. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  66701. * @param ref defines the target quaternion
  66702. * @returns the current quaternion
  66703. */
  66704. conjugateToRef(ref: Quaternion): Quaternion;
  66705. /**
  66706. * Conjugates in place (1-q) the current quaternion
  66707. * @returns the current updated quaternion
  66708. */
  66709. conjugateInPlace(): Quaternion;
  66710. /**
  66711. * Conjugates in place (1-q) the current quaternion
  66712. * @returns a new quaternion
  66713. */
  66714. conjugate(): Quaternion;
  66715. /**
  66716. * Gets length of current quaternion
  66717. * @returns the quaternion length (float)
  66718. */
  66719. length(): number;
  66720. /**
  66721. * Normalize in place the current quaternion
  66722. * @returns the current updated quaternion
  66723. */
  66724. normalize(): Quaternion;
  66725. /**
  66726. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  66727. * @param order is a reserved parameter and is ignore for now
  66728. * @returns a new Vector3 containing the Euler angles
  66729. */
  66730. toEulerAngles(order?: string): Vector3;
  66731. /**
  66732. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  66733. * @param result defines the vector which will be filled with the Euler angles
  66734. * @param order is a reserved parameter and is ignore for now
  66735. * @returns the current unchanged quaternion
  66736. */
  66737. toEulerAnglesToRef(result: Vector3): Quaternion;
  66738. /**
  66739. * Updates the given rotation matrix with the current quaternion values
  66740. * @param result defines the target matrix
  66741. * @returns the current unchanged quaternion
  66742. */
  66743. toRotationMatrix(result: Matrix): Quaternion;
  66744. /**
  66745. * Updates the current quaternion from the given rotation matrix values
  66746. * @param matrix defines the source matrix
  66747. * @returns the current updated quaternion
  66748. */
  66749. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  66750. /**
  66751. * Creates a new quaternion from a rotation matrix
  66752. * @param matrix defines the source matrix
  66753. * @returns a new quaternion created from the given rotation matrix values
  66754. */
  66755. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  66756. /**
  66757. * Updates the given quaternion with the given rotation matrix values
  66758. * @param matrix defines the source matrix
  66759. * @param result defines the target quaternion
  66760. */
  66761. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  66762. /**
  66763. * Returns the dot product (float) between the quaternions "left" and "right"
  66764. * @param left defines the left operand
  66765. * @param right defines the right operand
  66766. * @returns the dot product
  66767. */
  66768. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  66769. /**
  66770. * Checks if the two quaternions are close to each other
  66771. * @param quat0 defines the first quaternion to check
  66772. * @param quat1 defines the second quaternion to check
  66773. * @returns true if the two quaternions are close to each other
  66774. */
  66775. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  66776. /**
  66777. * Creates an empty quaternion
  66778. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  66779. */
  66780. static Zero(): Quaternion;
  66781. /**
  66782. * Inverse a given quaternion
  66783. * @param q defines the source quaternion
  66784. * @returns a new quaternion as the inverted current quaternion
  66785. */
  66786. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  66787. /**
  66788. * Inverse a given quaternion
  66789. * @param q defines the source quaternion
  66790. * @param result the quaternion the result will be stored in
  66791. * @returns the result quaternion
  66792. */
  66793. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  66794. /**
  66795. * Creates an identity quaternion
  66796. * @returns the identity quaternion
  66797. */
  66798. static Identity(): Quaternion;
  66799. /**
  66800. * Gets a boolean indicating if the given quaternion is identity
  66801. * @param quaternion defines the quaternion to check
  66802. * @returns true if the quaternion is identity
  66803. */
  66804. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  66805. /**
  66806. * Creates a quaternion from a rotation around an axis
  66807. * @param axis defines the axis to use
  66808. * @param angle defines the angle to use
  66809. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  66810. */
  66811. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  66812. /**
  66813. * Creates a rotation around an axis and stores it into the given quaternion
  66814. * @param axis defines the axis to use
  66815. * @param angle defines the angle to use
  66816. * @param result defines the target quaternion
  66817. * @returns the target quaternion
  66818. */
  66819. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  66820. /**
  66821. * Creates a new quaternion from data stored into an array
  66822. * @param array defines the data source
  66823. * @param offset defines the offset in the source array where the data starts
  66824. * @returns a new quaternion
  66825. */
  66826. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  66827. /**
  66828. * Create a quaternion from Euler rotation angles
  66829. * @param x Pitch
  66830. * @param y Yaw
  66831. * @param z Roll
  66832. * @returns the new Quaternion
  66833. */
  66834. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  66835. /**
  66836. * Updates a quaternion from Euler rotation angles
  66837. * @param x Pitch
  66838. * @param y Yaw
  66839. * @param z Roll
  66840. * @param result the quaternion to store the result
  66841. * @returns the updated quaternion
  66842. */
  66843. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  66844. /**
  66845. * Create a quaternion from Euler rotation vector
  66846. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  66847. * @returns the new Quaternion
  66848. */
  66849. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  66850. /**
  66851. * Updates a quaternion from Euler rotation vector
  66852. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  66853. * @param result the quaternion to store the result
  66854. * @returns the updated quaternion
  66855. */
  66856. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  66857. /**
  66858. * Creates a new quaternion from the given Euler float angles (y, x, z)
  66859. * @param yaw defines the rotation around Y axis
  66860. * @param pitch defines the rotation around X axis
  66861. * @param roll defines the rotation around Z axis
  66862. * @returns the new quaternion
  66863. */
  66864. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  66865. /**
  66866. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  66867. * @param yaw defines the rotation around Y axis
  66868. * @param pitch defines the rotation around X axis
  66869. * @param roll defines the rotation around Z axis
  66870. * @param result defines the target quaternion
  66871. */
  66872. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  66873. /**
  66874. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  66875. * @param alpha defines the rotation around first axis
  66876. * @param beta defines the rotation around second axis
  66877. * @param gamma defines the rotation around third axis
  66878. * @returns the new quaternion
  66879. */
  66880. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  66881. /**
  66882. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  66883. * @param alpha defines the rotation around first axis
  66884. * @param beta defines the rotation around second axis
  66885. * @param gamma defines the rotation around third axis
  66886. * @param result defines the target quaternion
  66887. */
  66888. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  66889. /**
  66890. * 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)
  66891. * @param axis1 defines the first axis
  66892. * @param axis2 defines the second axis
  66893. * @param axis3 defines the third axis
  66894. * @returns the new quaternion
  66895. */
  66896. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  66897. /**
  66898. * 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
  66899. * @param axis1 defines the first axis
  66900. * @param axis2 defines the second axis
  66901. * @param axis3 defines the third axis
  66902. * @param ref defines the target quaternion
  66903. */
  66904. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  66905. /**
  66906. * Interpolates between two quaternions
  66907. * @param left defines first quaternion
  66908. * @param right defines second quaternion
  66909. * @param amount defines the gradient to use
  66910. * @returns the new interpolated quaternion
  66911. */
  66912. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  66913. /**
  66914. * Interpolates between two quaternions and stores it into a target quaternion
  66915. * @param left defines first quaternion
  66916. * @param right defines second quaternion
  66917. * @param amount defines the gradient to use
  66918. * @param result defines the target quaternion
  66919. */
  66920. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  66921. /**
  66922. * Interpolate between two quaternions using Hermite interpolation
  66923. * @param value1 defines first quaternion
  66924. * @param tangent1 defines the incoming tangent
  66925. * @param value2 defines second quaternion
  66926. * @param tangent2 defines the outgoing tangent
  66927. * @param amount defines the target quaternion
  66928. * @returns the new interpolated quaternion
  66929. */
  66930. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  66931. }
  66932. /**
  66933. * Class used to store matrix data (4x4)
  66934. */
  66935. export class Matrix {
  66936. private static _updateFlagSeed;
  66937. private static _identityReadOnly;
  66938. private _isIdentity;
  66939. private _isIdentityDirty;
  66940. private _isIdentity3x2;
  66941. private _isIdentity3x2Dirty;
  66942. /**
  66943. * Gets the update flag of the matrix which is an unique number for the matrix.
  66944. * It will be incremented every time the matrix data change.
  66945. * You can use it to speed the comparison between two versions of the same matrix.
  66946. */
  66947. updateFlag: number;
  66948. private readonly _m;
  66949. /**
  66950. * Gets the internal data of the matrix
  66951. */
  66952. readonly m: DeepImmutable<Float32Array>;
  66953. /** @hidden */
  66954. _markAsUpdated(): void;
  66955. /** @hidden */
  66956. private _updateIdentityStatus;
  66957. /**
  66958. * Creates an empty matrix (filled with zeros)
  66959. */
  66960. constructor();
  66961. /**
  66962. * Check if the current matrix is identity
  66963. * @returns true is the matrix is the identity matrix
  66964. */
  66965. isIdentity(): boolean;
  66966. /**
  66967. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  66968. * @returns true is the matrix is the identity matrix
  66969. */
  66970. isIdentityAs3x2(): boolean;
  66971. /**
  66972. * Gets the determinant of the matrix
  66973. * @returns the matrix determinant
  66974. */
  66975. determinant(): number;
  66976. /**
  66977. * Returns the matrix as a Float32Array
  66978. * @returns the matrix underlying array
  66979. */
  66980. toArray(): DeepImmutable<Float32Array>;
  66981. /**
  66982. * Returns the matrix as a Float32Array
  66983. * @returns the matrix underlying array.
  66984. */
  66985. asArray(): DeepImmutable<Float32Array>;
  66986. /**
  66987. * Inverts the current matrix in place
  66988. * @returns the current inverted matrix
  66989. */
  66990. invert(): Matrix;
  66991. /**
  66992. * Sets all the matrix elements to zero
  66993. * @returns the current matrix
  66994. */
  66995. reset(): Matrix;
  66996. /**
  66997. * Adds the current matrix with a second one
  66998. * @param other defines the matrix to add
  66999. * @returns a new matrix as the addition of the current matrix and the given one
  67000. */
  67001. add(other: DeepImmutable<Matrix>): Matrix;
  67002. /**
  67003. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67004. * @param other defines the matrix to add
  67005. * @param result defines the target matrix
  67006. * @returns the current matrix
  67007. */
  67008. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67009. /**
  67010. * Adds in place the given matrix to the current matrix
  67011. * @param other defines the second operand
  67012. * @returns the current updated matrix
  67013. */
  67014. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67015. /**
  67016. * Sets the given matrix to the current inverted Matrix
  67017. * @param other defines the target matrix
  67018. * @returns the unmodified current matrix
  67019. */
  67020. invertToRef(other: Matrix): Matrix;
  67021. /**
  67022. * add a value at the specified position in the current Matrix
  67023. * @param index the index of the value within the matrix. between 0 and 15.
  67024. * @param value the value to be added
  67025. * @returns the current updated matrix
  67026. */
  67027. addAtIndex(index: number, value: number): Matrix;
  67028. /**
  67029. * mutiply the specified position in the current Matrix by a value
  67030. * @param index the index of the value within the matrix. between 0 and 15.
  67031. * @param value the value to be added
  67032. * @returns the current updated matrix
  67033. */
  67034. multiplyAtIndex(index: number, value: number): Matrix;
  67035. /**
  67036. * Inserts the translation vector (using 3 floats) in the current matrix
  67037. * @param x defines the 1st component of the translation
  67038. * @param y defines the 2nd component of the translation
  67039. * @param z defines the 3rd component of the translation
  67040. * @returns the current updated matrix
  67041. */
  67042. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67043. /**
  67044. * Adds the translation vector (using 3 floats) in the current matrix
  67045. * @param x defines the 1st component of the translation
  67046. * @param y defines the 2nd component of the translation
  67047. * @param z defines the 3rd component of the translation
  67048. * @returns the current updated matrix
  67049. */
  67050. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67051. /**
  67052. * Inserts the translation vector in the current matrix
  67053. * @param vector3 defines the translation to insert
  67054. * @returns the current updated matrix
  67055. */
  67056. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67057. /**
  67058. * Gets the translation value of the current matrix
  67059. * @returns a new Vector3 as the extracted translation from the matrix
  67060. */
  67061. getTranslation(): Vector3;
  67062. /**
  67063. * Fill a Vector3 with the extracted translation from the matrix
  67064. * @param result defines the Vector3 where to store the translation
  67065. * @returns the current matrix
  67066. */
  67067. getTranslationToRef(result: Vector3): Matrix;
  67068. /**
  67069. * Remove rotation and scaling part from the matrix
  67070. * @returns the updated matrix
  67071. */
  67072. removeRotationAndScaling(): Matrix;
  67073. /**
  67074. * Multiply two matrices
  67075. * @param other defines the second operand
  67076. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67077. */
  67078. multiply(other: DeepImmutable<Matrix>): Matrix;
  67079. /**
  67080. * Copy the current matrix from the given one
  67081. * @param other defines the source matrix
  67082. * @returns the current updated matrix
  67083. */
  67084. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67085. /**
  67086. * Populates the given array from the starting index with the current matrix values
  67087. * @param array defines the target array
  67088. * @param offset defines the offset in the target array where to start storing values
  67089. * @returns the current matrix
  67090. */
  67091. copyToArray(array: Float32Array, offset?: number): Matrix;
  67092. /**
  67093. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67094. * @param other defines the second operand
  67095. * @param result defines the matrix where to store the multiplication
  67096. * @returns the current matrix
  67097. */
  67098. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67099. /**
  67100. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67101. * @param other defines the second operand
  67102. * @param result defines the array where to store the multiplication
  67103. * @param offset defines the offset in the target array where to start storing values
  67104. * @returns the current matrix
  67105. */
  67106. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67107. /**
  67108. * Check equality between this matrix and a second one
  67109. * @param value defines the second matrix to compare
  67110. * @returns true is the current matrix and the given one values are strictly equal
  67111. */
  67112. equals(value: DeepImmutable<Matrix>): boolean;
  67113. /**
  67114. * Clone the current matrix
  67115. * @returns a new matrix from the current matrix
  67116. */
  67117. clone(): Matrix;
  67118. /**
  67119. * Returns the name of the current matrix class
  67120. * @returns the string "Matrix"
  67121. */
  67122. getClassName(): string;
  67123. /**
  67124. * Gets the hash code of the current matrix
  67125. * @returns the hash code
  67126. */
  67127. getHashCode(): number;
  67128. /**
  67129. * Decomposes the current Matrix into a translation, rotation and scaling components
  67130. * @param scale defines the scale vector3 given as a reference to update
  67131. * @param rotation defines the rotation quaternion given as a reference to update
  67132. * @param translation defines the translation vector3 given as a reference to update
  67133. * @returns true if operation was successful
  67134. */
  67135. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  67136. /**
  67137. * Gets specific row of the matrix
  67138. * @param index defines the number of the row to get
  67139. * @returns the index-th row of the current matrix as a new Vector4
  67140. */
  67141. getRow(index: number): Nullable<Vector4>;
  67142. /**
  67143. * Sets the index-th row of the current matrix to the vector4 values
  67144. * @param index defines the number of the row to set
  67145. * @param row defines the target vector4
  67146. * @returns the updated current matrix
  67147. */
  67148. setRow(index: number, row: Vector4): Matrix;
  67149. /**
  67150. * Compute the transpose of the matrix
  67151. * @returns the new transposed matrix
  67152. */
  67153. transpose(): Matrix;
  67154. /**
  67155. * Compute the transpose of the matrix and store it in a given matrix
  67156. * @param result defines the target matrix
  67157. * @returns the current matrix
  67158. */
  67159. transposeToRef(result: Matrix): Matrix;
  67160. /**
  67161. * Sets the index-th row of the current matrix with the given 4 x float values
  67162. * @param index defines the row index
  67163. * @param x defines the x component to set
  67164. * @param y defines the y component to set
  67165. * @param z defines the z component to set
  67166. * @param w defines the w component to set
  67167. * @returns the updated current matrix
  67168. */
  67169. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  67170. /**
  67171. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  67172. * @param scale defines the scale factor
  67173. * @returns a new matrix
  67174. */
  67175. scale(scale: number): Matrix;
  67176. /**
  67177. * Scale the current matrix values by a factor to a given result matrix
  67178. * @param scale defines the scale factor
  67179. * @param result defines the matrix to store the result
  67180. * @returns the current matrix
  67181. */
  67182. scaleToRef(scale: number, result: Matrix): Matrix;
  67183. /**
  67184. * Scale the current matrix values by a factor and add the result to a given matrix
  67185. * @param scale defines the scale factor
  67186. * @param result defines the Matrix to store the result
  67187. * @returns the current matrix
  67188. */
  67189. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  67190. /**
  67191. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  67192. * @param ref matrix to store the result
  67193. */
  67194. toNormalMatrix(ref: Matrix): void;
  67195. /**
  67196. * Gets only rotation part of the current matrix
  67197. * @returns a new matrix sets to the extracted rotation matrix from the current one
  67198. */
  67199. getRotationMatrix(): Matrix;
  67200. /**
  67201. * Extracts the rotation matrix from the current one and sets it as the given "result"
  67202. * @param result defines the target matrix to store data to
  67203. * @returns the current matrix
  67204. */
  67205. getRotationMatrixToRef(result: Matrix): Matrix;
  67206. /**
  67207. * Toggles model matrix from being right handed to left handed in place and vice versa
  67208. */
  67209. toggleModelMatrixHandInPlace(): void;
  67210. /**
  67211. * Toggles projection matrix from being right handed to left handed in place and vice versa
  67212. */
  67213. toggleProjectionMatrixHandInPlace(): void;
  67214. /**
  67215. * Creates a matrix from an array
  67216. * @param array defines the source array
  67217. * @param offset defines an offset in the source array
  67218. * @returns a new Matrix set from the starting index of the given array
  67219. */
  67220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  67221. /**
  67222. * Copy the content of an array into a given matrix
  67223. * @param array defines the source array
  67224. * @param offset defines an offset in the source array
  67225. * @param result defines the target matrix
  67226. */
  67227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  67228. /**
  67229. * Stores an array into a matrix after having multiplied each component by a given factor
  67230. * @param array defines the source array
  67231. * @param offset defines the offset in the source array
  67232. * @param scale defines the scaling factor
  67233. * @param result defines the target matrix
  67234. */
  67235. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  67236. /**
  67237. * Gets an identity matrix that must not be updated
  67238. */
  67239. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  67240. /**
  67241. * Stores a list of values (16) inside a given matrix
  67242. * @param initialM11 defines 1st value of 1st row
  67243. * @param initialM12 defines 2nd value of 1st row
  67244. * @param initialM13 defines 3rd value of 1st row
  67245. * @param initialM14 defines 4th value of 1st row
  67246. * @param initialM21 defines 1st value of 2nd row
  67247. * @param initialM22 defines 2nd value of 2nd row
  67248. * @param initialM23 defines 3rd value of 2nd row
  67249. * @param initialM24 defines 4th value of 2nd row
  67250. * @param initialM31 defines 1st value of 3rd row
  67251. * @param initialM32 defines 2nd value of 3rd row
  67252. * @param initialM33 defines 3rd value of 3rd row
  67253. * @param initialM34 defines 4th value of 3rd row
  67254. * @param initialM41 defines 1st value of 4th row
  67255. * @param initialM42 defines 2nd value of 4th row
  67256. * @param initialM43 defines 3rd value of 4th row
  67257. * @param initialM44 defines 4th value of 4th row
  67258. * @param result defines the target matrix
  67259. */
  67260. 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;
  67261. /**
  67262. * Creates new matrix from a list of values (16)
  67263. * @param initialM11 defines 1st value of 1st row
  67264. * @param initialM12 defines 2nd value of 1st row
  67265. * @param initialM13 defines 3rd value of 1st row
  67266. * @param initialM14 defines 4th value of 1st row
  67267. * @param initialM21 defines 1st value of 2nd row
  67268. * @param initialM22 defines 2nd value of 2nd row
  67269. * @param initialM23 defines 3rd value of 2nd row
  67270. * @param initialM24 defines 4th value of 2nd row
  67271. * @param initialM31 defines 1st value of 3rd row
  67272. * @param initialM32 defines 2nd value of 3rd row
  67273. * @param initialM33 defines 3rd value of 3rd row
  67274. * @param initialM34 defines 4th value of 3rd row
  67275. * @param initialM41 defines 1st value of 4th row
  67276. * @param initialM42 defines 2nd value of 4th row
  67277. * @param initialM43 defines 3rd value of 4th row
  67278. * @param initialM44 defines 4th value of 4th row
  67279. * @returns the new matrix
  67280. */
  67281. 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;
  67282. /**
  67283. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67284. * @param scale defines the scale vector3
  67285. * @param rotation defines the rotation quaternion
  67286. * @param translation defines the translation vector3
  67287. * @returns a new matrix
  67288. */
  67289. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  67290. /**
  67291. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67292. * @param scale defines the scale vector3
  67293. * @param rotation defines the rotation quaternion
  67294. * @param translation defines the translation vector3
  67295. * @param result defines the target matrix
  67296. */
  67297. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  67298. /**
  67299. * Creates a new identity matrix
  67300. * @returns a new identity matrix
  67301. */
  67302. static Identity(): Matrix;
  67303. /**
  67304. * Creates a new identity matrix and stores the result in a given matrix
  67305. * @param result defines the target matrix
  67306. */
  67307. static IdentityToRef(result: Matrix): void;
  67308. /**
  67309. * Creates a new zero matrix
  67310. * @returns a new zero matrix
  67311. */
  67312. static Zero(): Matrix;
  67313. /**
  67314. * Creates a new rotation matrix for "angle" radians around the X axis
  67315. * @param angle defines the angle (in radians) to use
  67316. * @return the new matrix
  67317. */
  67318. static RotationX(angle: number): Matrix;
  67319. /**
  67320. * Creates a new matrix as the invert of a given matrix
  67321. * @param source defines the source matrix
  67322. * @returns the new matrix
  67323. */
  67324. static Invert(source: DeepImmutable<Matrix>): Matrix;
  67325. /**
  67326. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  67327. * @param angle defines the angle (in radians) to use
  67328. * @param result defines the target matrix
  67329. */
  67330. static RotationXToRef(angle: number, result: Matrix): void;
  67331. /**
  67332. * Creates a new rotation matrix for "angle" radians around the Y axis
  67333. * @param angle defines the angle (in radians) to use
  67334. * @return the new matrix
  67335. */
  67336. static RotationY(angle: number): Matrix;
  67337. /**
  67338. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  67339. * @param angle defines the angle (in radians) to use
  67340. * @param result defines the target matrix
  67341. */
  67342. static RotationYToRef(angle: number, result: Matrix): void;
  67343. /**
  67344. * Creates a new rotation matrix for "angle" radians around the Z axis
  67345. * @param angle defines the angle (in radians) to use
  67346. * @return the new matrix
  67347. */
  67348. static RotationZ(angle: number): Matrix;
  67349. /**
  67350. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  67351. * @param angle defines the angle (in radians) to use
  67352. * @param result defines the target matrix
  67353. */
  67354. static RotationZToRef(angle: number, result: Matrix): void;
  67355. /**
  67356. * Creates a new rotation matrix for "angle" radians around the given axis
  67357. * @param axis defines the axis to use
  67358. * @param angle defines the angle (in radians) to use
  67359. * @return the new matrix
  67360. */
  67361. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  67362. /**
  67363. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  67364. * @param axis defines the axis to use
  67365. * @param angle defines the angle (in radians) to use
  67366. * @param result defines the target matrix
  67367. */
  67368. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  67369. /**
  67370. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  67371. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  67372. * @param from defines the vector to align
  67373. * @param to defines the vector to align to
  67374. * @param result defines the target matrix
  67375. */
  67376. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  67377. /**
  67378. * Creates a rotation matrix
  67379. * @param yaw defines the yaw angle in radians (Y axis)
  67380. * @param pitch defines the pitch angle in radians (X axis)
  67381. * @param roll defines the roll angle in radians (X axis)
  67382. * @returns the new rotation matrix
  67383. */
  67384. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  67385. /**
  67386. * Creates a rotation matrix and stores it in a given matrix
  67387. * @param yaw defines the yaw angle in radians (Y axis)
  67388. * @param pitch defines the pitch angle in radians (X axis)
  67389. * @param roll defines the roll angle in radians (X axis)
  67390. * @param result defines the target matrix
  67391. */
  67392. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  67393. /**
  67394. * Creates a scaling matrix
  67395. * @param x defines the scale factor on X axis
  67396. * @param y defines the scale factor on Y axis
  67397. * @param z defines the scale factor on Z axis
  67398. * @returns the new matrix
  67399. */
  67400. static Scaling(x: number, y: number, z: number): Matrix;
  67401. /**
  67402. * Creates a scaling matrix and stores it in a given matrix
  67403. * @param x defines the scale factor on X axis
  67404. * @param y defines the scale factor on Y axis
  67405. * @param z defines the scale factor on Z axis
  67406. * @param result defines the target matrix
  67407. */
  67408. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  67409. /**
  67410. * Creates a translation matrix
  67411. * @param x defines the translation on X axis
  67412. * @param y defines the translation on Y axis
  67413. * @param z defines the translationon Z axis
  67414. * @returns the new matrix
  67415. */
  67416. static Translation(x: number, y: number, z: number): Matrix;
  67417. /**
  67418. * Creates a translation matrix and stores it in a given matrix
  67419. * @param x defines the translation on X axis
  67420. * @param y defines the translation on Y axis
  67421. * @param z defines the translationon Z axis
  67422. * @param result defines the target matrix
  67423. */
  67424. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  67425. /**
  67426. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67427. * @param startValue defines the start value
  67428. * @param endValue defines the end value
  67429. * @param gradient defines the gradient factor
  67430. * @returns the new matrix
  67431. */
  67432. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67433. /**
  67434. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67435. * @param startValue defines the start value
  67436. * @param endValue defines the end value
  67437. * @param gradient defines the gradient factor
  67438. * @param result defines the Matrix object where to store data
  67439. */
  67440. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67441. /**
  67442. * Builds a new matrix whose values are computed by:
  67443. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67444. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67445. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67446. * @param startValue defines the first matrix
  67447. * @param endValue defines the second matrix
  67448. * @param gradient defines the gradient between the two matrices
  67449. * @returns the new matrix
  67450. */
  67451. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67452. /**
  67453. * Update a matrix to values which are computed by:
  67454. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67455. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67456. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67457. * @param startValue defines the first matrix
  67458. * @param endValue defines the second matrix
  67459. * @param gradient defines the gradient between the two matrices
  67460. * @param result defines the target matrix
  67461. */
  67462. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67463. /**
  67464. * 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"
  67465. * This function works in left handed mode
  67466. * @param eye defines the final position of the entity
  67467. * @param target defines where the entity should look at
  67468. * @param up defines the up vector for the entity
  67469. * @returns the new matrix
  67470. */
  67471. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67472. /**
  67473. * 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".
  67474. * This function works in left handed mode
  67475. * @param eye defines the final position of the entity
  67476. * @param target defines where the entity should look at
  67477. * @param up defines the up vector for the entity
  67478. * @param result defines the target matrix
  67479. */
  67480. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67481. /**
  67482. * 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"
  67483. * This function works in right handed mode
  67484. * @param eye defines the final position of the entity
  67485. * @param target defines where the entity should look at
  67486. * @param up defines the up vector for the entity
  67487. * @returns the new matrix
  67488. */
  67489. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67490. /**
  67491. * 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".
  67492. * This function works in right handed mode
  67493. * @param eye defines the final position of the entity
  67494. * @param target defines where the entity should look at
  67495. * @param up defines the up vector for the entity
  67496. * @param result defines the target matrix
  67497. */
  67498. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67499. /**
  67500. * Create a left-handed orthographic projection matrix
  67501. * @param width defines the viewport width
  67502. * @param height defines the viewport height
  67503. * @param znear defines the near clip plane
  67504. * @param zfar defines the far clip plane
  67505. * @returns a new matrix as a left-handed orthographic projection matrix
  67506. */
  67507. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67508. /**
  67509. * Store a left-handed orthographic projection to a given matrix
  67510. * @param width defines the viewport width
  67511. * @param height defines the viewport height
  67512. * @param znear defines the near clip plane
  67513. * @param zfar defines the far clip plane
  67514. * @param result defines the target matrix
  67515. */
  67516. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  67517. /**
  67518. * Create a left-handed orthographic projection matrix
  67519. * @param left defines the viewport left coordinate
  67520. * @param right defines the viewport right coordinate
  67521. * @param bottom defines the viewport bottom coordinate
  67522. * @param top defines the viewport top coordinate
  67523. * @param znear defines the near clip plane
  67524. * @param zfar defines the far clip plane
  67525. * @returns a new matrix as a left-handed orthographic projection matrix
  67526. */
  67527. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67528. /**
  67529. * Stores a left-handed orthographic projection into a given matrix
  67530. * @param left defines the viewport left coordinate
  67531. * @param right defines the viewport right coordinate
  67532. * @param bottom defines the viewport bottom coordinate
  67533. * @param top defines the viewport top coordinate
  67534. * @param znear defines the near clip plane
  67535. * @param zfar defines the far clip plane
  67536. * @param result defines the target matrix
  67537. */
  67538. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67539. /**
  67540. * Creates a right-handed orthographic projection matrix
  67541. * @param left defines the viewport left coordinate
  67542. * @param right defines the viewport right coordinate
  67543. * @param bottom defines the viewport bottom coordinate
  67544. * @param top defines the viewport top coordinate
  67545. * @param znear defines the near clip plane
  67546. * @param zfar defines the far clip plane
  67547. * @returns a new matrix as a right-handed orthographic projection matrix
  67548. */
  67549. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67550. /**
  67551. * Stores a right-handed orthographic projection into a given matrix
  67552. * @param left defines the viewport left coordinate
  67553. * @param right defines the viewport right coordinate
  67554. * @param bottom defines the viewport bottom coordinate
  67555. * @param top defines the viewport top coordinate
  67556. * @param znear defines the near clip plane
  67557. * @param zfar defines the far clip plane
  67558. * @param result defines the target matrix
  67559. */
  67560. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67561. /**
  67562. * Creates a left-handed perspective projection matrix
  67563. * @param width defines the viewport width
  67564. * @param height defines the viewport height
  67565. * @param znear defines the near clip plane
  67566. * @param zfar defines the far clip plane
  67567. * @returns a new matrix as a left-handed perspective projection matrix
  67568. */
  67569. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67570. /**
  67571. * Creates a left-handed perspective projection matrix
  67572. * @param fov defines the horizontal field of view
  67573. * @param aspect defines the aspect ratio
  67574. * @param znear defines the near clip plane
  67575. * @param zfar defines the far clip plane
  67576. * @returns a new matrix as a left-handed perspective projection matrix
  67577. */
  67578. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67579. /**
  67580. * Stores a left-handed perspective projection into a given matrix
  67581. * @param fov defines the horizontal field of view
  67582. * @param aspect defines the aspect ratio
  67583. * @param znear defines the near clip plane
  67584. * @param zfar defines the far clip plane
  67585. * @param result defines the target matrix
  67586. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67587. */
  67588. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67589. /**
  67590. * Creates a right-handed perspective projection matrix
  67591. * @param fov defines the horizontal field of view
  67592. * @param aspect defines the aspect ratio
  67593. * @param znear defines the near clip plane
  67594. * @param zfar defines the far clip plane
  67595. * @returns a new matrix as a right-handed perspective projection matrix
  67596. */
  67597. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67598. /**
  67599. * Stores a right-handed perspective projection into a given matrix
  67600. * @param fov defines the horizontal field of view
  67601. * @param aspect defines the aspect ratio
  67602. * @param znear defines the near clip plane
  67603. * @param zfar defines the far clip plane
  67604. * @param result defines the target matrix
  67605. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67606. */
  67607. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67608. /**
  67609. * Stores a perspective projection for WebVR info a given matrix
  67610. * @param fov defines the field of view
  67611. * @param znear defines the near clip plane
  67612. * @param zfar defines the far clip plane
  67613. * @param result defines the target matrix
  67614. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  67615. */
  67616. static PerspectiveFovWebVRToRef(fov: {
  67617. upDegrees: number;
  67618. downDegrees: number;
  67619. leftDegrees: number;
  67620. rightDegrees: number;
  67621. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  67622. /**
  67623. * Computes a complete transformation matrix
  67624. * @param viewport defines the viewport to use
  67625. * @param world defines the world matrix
  67626. * @param view defines the view matrix
  67627. * @param projection defines the projection matrix
  67628. * @param zmin defines the near clip plane
  67629. * @param zmax defines the far clip plane
  67630. * @returns the transformation matrix
  67631. */
  67632. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  67633. /**
  67634. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  67635. * @param matrix defines the matrix to use
  67636. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  67637. */
  67638. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  67639. /**
  67640. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  67641. * @param matrix defines the matrix to use
  67642. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  67643. */
  67644. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  67645. /**
  67646. * Compute the transpose of a given matrix
  67647. * @param matrix defines the matrix to transpose
  67648. * @returns the new matrix
  67649. */
  67650. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  67651. /**
  67652. * Compute the transpose of a matrix and store it in a target matrix
  67653. * @param matrix defines the matrix to transpose
  67654. * @param result defines the target matrix
  67655. */
  67656. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  67657. /**
  67658. * Computes a reflection matrix from a plane
  67659. * @param plane defines the reflection plane
  67660. * @returns a new matrix
  67661. */
  67662. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  67663. /**
  67664. * Computes a reflection matrix from a plane
  67665. * @param plane defines the reflection plane
  67666. * @param result defines the target matrix
  67667. */
  67668. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  67669. /**
  67670. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  67671. * @param xaxis defines the value of the 1st axis
  67672. * @param yaxis defines the value of the 2nd axis
  67673. * @param zaxis defines the value of the 3rd axis
  67674. * @param result defines the target matrix
  67675. */
  67676. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  67677. /**
  67678. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  67679. * @param quat defines the quaternion to use
  67680. * @param result defines the target matrix
  67681. */
  67682. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  67683. }
  67684. /**
  67685. * @hidden
  67686. */
  67687. export class TmpVectors {
  67688. static Vector2: Vector2[];
  67689. static Vector3: Vector3[];
  67690. static Vector4: Vector4[];
  67691. static Quaternion: Quaternion[];
  67692. static Matrix: Matrix[];
  67693. }
  67694. }
  67695. declare module BABYLON {
  67696. /** Defines the cross module used constants to avoid circular dependncies */
  67697. export class Constants {
  67698. /** Defines that alpha blending is disabled */
  67699. static readonly ALPHA_DISABLE: number;
  67700. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67701. static readonly ALPHA_ADD: number;
  67702. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67703. static readonly ALPHA_COMBINE: number;
  67704. /** Defines that alpha blending to DEST - SRC * DEST */
  67705. static readonly ALPHA_SUBTRACT: number;
  67706. /** Defines that alpha blending to SRC * DEST */
  67707. static readonly ALPHA_MULTIPLY: number;
  67708. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67709. static readonly ALPHA_MAXIMIZED: number;
  67710. /** Defines that alpha blending to SRC + DEST */
  67711. static readonly ALPHA_ONEONE: number;
  67712. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67713. static readonly ALPHA_PREMULTIPLIED: number;
  67714. /**
  67715. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67716. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67717. */
  67718. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67719. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67720. static readonly ALPHA_INTERPOLATE: number;
  67721. /**
  67722. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67723. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67724. */
  67725. static readonly ALPHA_SCREENMODE: number;
  67726. /** Defines that the ressource is not delayed*/
  67727. static readonly DELAYLOADSTATE_NONE: number;
  67728. /** Defines that the ressource was successfully delay loaded */
  67729. static readonly DELAYLOADSTATE_LOADED: number;
  67730. /** Defines that the ressource is currently delay loading */
  67731. static readonly DELAYLOADSTATE_LOADING: number;
  67732. /** Defines that the ressource is delayed and has not started loading */
  67733. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67734. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67735. static readonly NEVER: number;
  67736. /** 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 */
  67737. static readonly ALWAYS: number;
  67738. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67739. static readonly LESS: number;
  67740. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67741. static readonly EQUAL: number;
  67742. /** 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 */
  67743. static readonly LEQUAL: number;
  67744. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67745. static readonly GREATER: number;
  67746. /** 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 */
  67747. static readonly GEQUAL: number;
  67748. /** 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 */
  67749. static readonly NOTEQUAL: number;
  67750. /** Passed to stencilOperation to specify that stencil value must be kept */
  67751. static readonly KEEP: number;
  67752. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67753. static readonly REPLACE: number;
  67754. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67755. static readonly INCR: number;
  67756. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67757. static readonly DECR: number;
  67758. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67759. static readonly INVERT: number;
  67760. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67761. static readonly INCR_WRAP: number;
  67762. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67763. static readonly DECR_WRAP: number;
  67764. /** Texture is not repeating outside of 0..1 UVs */
  67765. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67766. /** Texture is repeating outside of 0..1 UVs */
  67767. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67768. /** Texture is repeating and mirrored */
  67769. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67770. /** ALPHA */
  67771. static readonly TEXTUREFORMAT_ALPHA: number;
  67772. /** LUMINANCE */
  67773. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67774. /** LUMINANCE_ALPHA */
  67775. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67776. /** RGB */
  67777. static readonly TEXTUREFORMAT_RGB: number;
  67778. /** RGBA */
  67779. static readonly TEXTUREFORMAT_RGBA: number;
  67780. /** RED */
  67781. static readonly TEXTUREFORMAT_RED: number;
  67782. /** RED (2nd reference) */
  67783. static readonly TEXTUREFORMAT_R: number;
  67784. /** RG */
  67785. static readonly TEXTUREFORMAT_RG: number;
  67786. /** RED_INTEGER */
  67787. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67788. /** RED_INTEGER (2nd reference) */
  67789. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67790. /** RG_INTEGER */
  67791. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67792. /** RGB_INTEGER */
  67793. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67794. /** RGBA_INTEGER */
  67795. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67796. /** UNSIGNED_BYTE */
  67797. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67798. /** UNSIGNED_BYTE (2nd reference) */
  67799. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67800. /** FLOAT */
  67801. static readonly TEXTURETYPE_FLOAT: number;
  67802. /** HALF_FLOAT */
  67803. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67804. /** BYTE */
  67805. static readonly TEXTURETYPE_BYTE: number;
  67806. /** SHORT */
  67807. static readonly TEXTURETYPE_SHORT: number;
  67808. /** UNSIGNED_SHORT */
  67809. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67810. /** INT */
  67811. static readonly TEXTURETYPE_INT: number;
  67812. /** UNSIGNED_INT */
  67813. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67814. /** UNSIGNED_SHORT_4_4_4_4 */
  67815. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67816. /** UNSIGNED_SHORT_5_5_5_1 */
  67817. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67818. /** UNSIGNED_SHORT_5_6_5 */
  67819. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67820. /** UNSIGNED_INT_2_10_10_10_REV */
  67821. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67822. /** UNSIGNED_INT_24_8 */
  67823. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67824. /** UNSIGNED_INT_10F_11F_11F_REV */
  67825. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67826. /** UNSIGNED_INT_5_9_9_9_REV */
  67827. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67828. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67829. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67830. /** nearest is mag = nearest and min = nearest and mip = linear */
  67831. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67832. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67833. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67834. /** Trilinear is mag = linear and min = linear and mip = linear */
  67835. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67836. /** nearest is mag = nearest and min = nearest and mip = linear */
  67837. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67838. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67839. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67840. /** Trilinear is mag = linear and min = linear and mip = linear */
  67841. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67842. /** mag = nearest and min = nearest and mip = nearest */
  67843. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67844. /** mag = nearest and min = linear and mip = nearest */
  67845. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67846. /** mag = nearest and min = linear and mip = linear */
  67847. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67848. /** mag = nearest and min = linear and mip = none */
  67849. static readonly TEXTURE_NEAREST_LINEAR: number;
  67850. /** mag = nearest and min = nearest and mip = none */
  67851. static readonly TEXTURE_NEAREST_NEAREST: number;
  67852. /** mag = linear and min = nearest and mip = nearest */
  67853. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67854. /** mag = linear and min = nearest and mip = linear */
  67855. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67856. /** mag = linear and min = linear and mip = none */
  67857. static readonly TEXTURE_LINEAR_LINEAR: number;
  67858. /** mag = linear and min = nearest and mip = none */
  67859. static readonly TEXTURE_LINEAR_NEAREST: number;
  67860. /** Explicit coordinates mode */
  67861. static readonly TEXTURE_EXPLICIT_MODE: number;
  67862. /** Spherical coordinates mode */
  67863. static readonly TEXTURE_SPHERICAL_MODE: number;
  67864. /** Planar coordinates mode */
  67865. static readonly TEXTURE_PLANAR_MODE: number;
  67866. /** Cubic coordinates mode */
  67867. static readonly TEXTURE_CUBIC_MODE: number;
  67868. /** Projection coordinates mode */
  67869. static readonly TEXTURE_PROJECTION_MODE: number;
  67870. /** Skybox coordinates mode */
  67871. static readonly TEXTURE_SKYBOX_MODE: number;
  67872. /** Inverse Cubic coordinates mode */
  67873. static readonly TEXTURE_INVCUBIC_MODE: number;
  67874. /** Equirectangular coordinates mode */
  67875. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67876. /** Equirectangular Fixed coordinates mode */
  67877. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67878. /** Equirectangular Fixed Mirrored coordinates mode */
  67879. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67880. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67881. static readonly SCALEMODE_FLOOR: number;
  67882. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67883. static readonly SCALEMODE_NEAREST: number;
  67884. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67885. static readonly SCALEMODE_CEILING: number;
  67886. /**
  67887. * The dirty texture flag value
  67888. */
  67889. static readonly MATERIAL_TextureDirtyFlag: number;
  67890. /**
  67891. * The dirty light flag value
  67892. */
  67893. static readonly MATERIAL_LightDirtyFlag: number;
  67894. /**
  67895. * The dirty fresnel flag value
  67896. */
  67897. static readonly MATERIAL_FresnelDirtyFlag: number;
  67898. /**
  67899. * The dirty attribute flag value
  67900. */
  67901. static readonly MATERIAL_AttributesDirtyFlag: number;
  67902. /**
  67903. * The dirty misc flag value
  67904. */
  67905. static readonly MATERIAL_MiscDirtyFlag: number;
  67906. /**
  67907. * The all dirty flag value
  67908. */
  67909. static readonly MATERIAL_AllDirtyFlag: number;
  67910. /**
  67911. * Returns the triangle fill mode
  67912. */
  67913. static readonly MATERIAL_TriangleFillMode: number;
  67914. /**
  67915. * Returns the wireframe mode
  67916. */
  67917. static readonly MATERIAL_WireFrameFillMode: number;
  67918. /**
  67919. * Returns the point fill mode
  67920. */
  67921. static readonly MATERIAL_PointFillMode: number;
  67922. /**
  67923. * Returns the point list draw mode
  67924. */
  67925. static readonly MATERIAL_PointListDrawMode: number;
  67926. /**
  67927. * Returns the line list draw mode
  67928. */
  67929. static readonly MATERIAL_LineListDrawMode: number;
  67930. /**
  67931. * Returns the line loop draw mode
  67932. */
  67933. static readonly MATERIAL_LineLoopDrawMode: number;
  67934. /**
  67935. * Returns the line strip draw mode
  67936. */
  67937. static readonly MATERIAL_LineStripDrawMode: number;
  67938. /**
  67939. * Returns the triangle strip draw mode
  67940. */
  67941. static readonly MATERIAL_TriangleStripDrawMode: number;
  67942. /**
  67943. * Returns the triangle fan draw mode
  67944. */
  67945. static readonly MATERIAL_TriangleFanDrawMode: number;
  67946. /**
  67947. * Stores the clock-wise side orientation
  67948. */
  67949. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67950. /**
  67951. * Stores the counter clock-wise side orientation
  67952. */
  67953. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67954. /**
  67955. * Nothing
  67956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67957. */
  67958. static readonly ACTION_NothingTrigger: number;
  67959. /**
  67960. * On pick
  67961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67962. */
  67963. static readonly ACTION_OnPickTrigger: number;
  67964. /**
  67965. * On left pick
  67966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67967. */
  67968. static readonly ACTION_OnLeftPickTrigger: number;
  67969. /**
  67970. * On right pick
  67971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67972. */
  67973. static readonly ACTION_OnRightPickTrigger: number;
  67974. /**
  67975. * On center pick
  67976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67977. */
  67978. static readonly ACTION_OnCenterPickTrigger: number;
  67979. /**
  67980. * On pick down
  67981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67982. */
  67983. static readonly ACTION_OnPickDownTrigger: number;
  67984. /**
  67985. * On double pick
  67986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67987. */
  67988. static readonly ACTION_OnDoublePickTrigger: number;
  67989. /**
  67990. * On pick up
  67991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67992. */
  67993. static readonly ACTION_OnPickUpTrigger: number;
  67994. /**
  67995. * On pick out.
  67996. * This trigger will only be raised if you also declared a OnPickDown
  67997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67998. */
  67999. static readonly ACTION_OnPickOutTrigger: number;
  68000. /**
  68001. * On long press
  68002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68003. */
  68004. static readonly ACTION_OnLongPressTrigger: number;
  68005. /**
  68006. * On pointer over
  68007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68008. */
  68009. static readonly ACTION_OnPointerOverTrigger: number;
  68010. /**
  68011. * On pointer out
  68012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68013. */
  68014. static readonly ACTION_OnPointerOutTrigger: number;
  68015. /**
  68016. * On every frame
  68017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68018. */
  68019. static readonly ACTION_OnEveryFrameTrigger: number;
  68020. /**
  68021. * On intersection enter
  68022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68023. */
  68024. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68025. /**
  68026. * On intersection exit
  68027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68028. */
  68029. static readonly ACTION_OnIntersectionExitTrigger: number;
  68030. /**
  68031. * On key down
  68032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68033. */
  68034. static readonly ACTION_OnKeyDownTrigger: number;
  68035. /**
  68036. * On key up
  68037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68038. */
  68039. static readonly ACTION_OnKeyUpTrigger: number;
  68040. /**
  68041. * Billboard mode will only apply to Y axis
  68042. */
  68043. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68044. /**
  68045. * Billboard mode will apply to all axes
  68046. */
  68047. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68048. /**
  68049. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68050. */
  68051. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68052. /**
  68053. * Gets or sets base Assets URL
  68054. */
  68055. static PARTICLES_BaseAssetsUrl: string;
  68056. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68057. * Test order :
  68058. * Is the bounding sphere outside the frustum ?
  68059. * If not, are the bounding box vertices outside the frustum ?
  68060. * It not, then the cullable object is in the frustum.
  68061. */
  68062. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68063. /** Culling strategy : Bounding Sphere Only.
  68064. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68065. * It's also less accurate than the standard because some not visible objects can still be selected.
  68066. * Test : is the bounding sphere outside the frustum ?
  68067. * If not, then the cullable object is in the frustum.
  68068. */
  68069. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68070. /** Culling strategy : Optimistic Inclusion.
  68071. * This in an inclusion test first, then the standard exclusion test.
  68072. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68073. * 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.
  68074. * Anyway, it's as accurate as the standard strategy.
  68075. * Test :
  68076. * Is the cullable object bounding sphere center in the frustum ?
  68077. * If not, apply the default culling strategy.
  68078. */
  68079. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68080. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68081. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68082. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68083. * 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.
  68084. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68085. * Test :
  68086. * Is the cullable object bounding sphere center in the frustum ?
  68087. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68088. */
  68089. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68090. /**
  68091. * No logging while loading
  68092. */
  68093. static readonly SCENELOADER_NO_LOGGING: number;
  68094. /**
  68095. * Minimal logging while loading
  68096. */
  68097. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68098. /**
  68099. * Summary logging while loading
  68100. */
  68101. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68102. /**
  68103. * Detailled logging while loading
  68104. */
  68105. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68106. }
  68107. }
  68108. declare module BABYLON {
  68109. /**
  68110. * Class used to store and describe the pipeline context associated with an effect
  68111. */
  68112. export interface IPipelineContext {
  68113. /**
  68114. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68115. */
  68116. isAsync: boolean;
  68117. /**
  68118. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68119. */
  68120. isReady: boolean;
  68121. /** @hidden */
  68122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68123. }
  68124. }
  68125. declare module BABYLON {
  68126. /** @hidden */
  68127. export interface IShaderProcessor {
  68128. attributeProcessor?: (attribute: string) => string;
  68129. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68130. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68131. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68132. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68133. lineProcessor?: (line: string, isFragment: boolean) => string;
  68134. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68135. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68136. }
  68137. }
  68138. declare module BABYLON {
  68139. /** @hidden */
  68140. export interface ProcessingOptions {
  68141. defines: string[];
  68142. indexParameters: any;
  68143. isFragment: boolean;
  68144. shouldUseHighPrecisionShader: boolean;
  68145. supportsUniformBuffers: boolean;
  68146. shadersRepository: string;
  68147. includesShadersStore: {
  68148. [key: string]: string;
  68149. };
  68150. processor?: IShaderProcessor;
  68151. version: string;
  68152. platformName: string;
  68153. lookForClosingBracketForUniformBuffer?: boolean;
  68154. }
  68155. }
  68156. declare module BABYLON {
  68157. /**
  68158. * Helper to manipulate strings
  68159. */
  68160. export class StringTools {
  68161. /**
  68162. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68163. * @param str Source string
  68164. * @param suffix Suffix to search for in the source string
  68165. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68166. */
  68167. static EndsWith(str: string, suffix: string): boolean;
  68168. /**
  68169. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68170. * @param str Source string
  68171. * @param suffix Suffix to search for in the source string
  68172. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68173. */
  68174. static StartsWith(str: string, suffix: string): boolean;
  68175. }
  68176. }
  68177. declare module BABYLON {
  68178. /** @hidden */
  68179. export class ShaderCodeNode {
  68180. line: string;
  68181. children: ShaderCodeNode[];
  68182. additionalDefineKey?: string;
  68183. additionalDefineValue?: string;
  68184. isValid(preprocessors: {
  68185. [key: string]: string;
  68186. }): boolean;
  68187. process(preprocessors: {
  68188. [key: string]: string;
  68189. }, options: ProcessingOptions): string;
  68190. }
  68191. }
  68192. declare module BABYLON {
  68193. /** @hidden */
  68194. export class ShaderCodeCursor {
  68195. private _lines;
  68196. lineIndex: number;
  68197. readonly currentLine: string;
  68198. readonly canRead: boolean;
  68199. lines: string[];
  68200. }
  68201. }
  68202. declare module BABYLON {
  68203. /** @hidden */
  68204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68205. process(preprocessors: {
  68206. [key: string]: string;
  68207. }, options: ProcessingOptions): string;
  68208. }
  68209. }
  68210. declare module BABYLON {
  68211. /** @hidden */
  68212. export class ShaderDefineExpression {
  68213. isTrue(preprocessors: {
  68214. [key: string]: string;
  68215. }): boolean;
  68216. }
  68217. }
  68218. declare module BABYLON {
  68219. /** @hidden */
  68220. export class ShaderCodeTestNode extends ShaderCodeNode {
  68221. testExpression: ShaderDefineExpression;
  68222. isValid(preprocessors: {
  68223. [key: string]: string;
  68224. }): boolean;
  68225. }
  68226. }
  68227. declare module BABYLON {
  68228. /** @hidden */
  68229. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68230. define: string;
  68231. not: boolean;
  68232. constructor(define: string, not?: boolean);
  68233. isTrue(preprocessors: {
  68234. [key: string]: string;
  68235. }): boolean;
  68236. }
  68237. }
  68238. declare module BABYLON {
  68239. /** @hidden */
  68240. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68241. leftOperand: ShaderDefineExpression;
  68242. rightOperand: ShaderDefineExpression;
  68243. isTrue(preprocessors: {
  68244. [key: string]: string;
  68245. }): boolean;
  68246. }
  68247. }
  68248. declare module BABYLON {
  68249. /** @hidden */
  68250. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68251. leftOperand: ShaderDefineExpression;
  68252. rightOperand: ShaderDefineExpression;
  68253. isTrue(preprocessors: {
  68254. [key: string]: string;
  68255. }): boolean;
  68256. }
  68257. }
  68258. declare module BABYLON {
  68259. /** @hidden */
  68260. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68261. define: string;
  68262. operand: string;
  68263. testValue: string;
  68264. constructor(define: string, operand: string, testValue: string);
  68265. isTrue(preprocessors: {
  68266. [key: string]: string;
  68267. }): boolean;
  68268. }
  68269. }
  68270. declare module BABYLON {
  68271. /**
  68272. * @ignore
  68273. * Application error to support additional information when loading a file
  68274. */
  68275. export class LoadFileError extends Error {
  68276. /** defines the optional web request */
  68277. request?: WebRequest | undefined;
  68278. private static _setPrototypeOf;
  68279. /**
  68280. * Creates a new LoadFileError
  68281. * @param message defines the message of the error
  68282. * @param request defines the optional web request
  68283. */
  68284. constructor(message: string,
  68285. /** defines the optional web request */
  68286. request?: WebRequest | undefined);
  68287. }
  68288. }
  68289. declare module BABYLON {
  68290. /**
  68291. * Class used to enable access to offline support
  68292. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68293. */
  68294. export interface IOfflineProvider {
  68295. /**
  68296. * Gets a boolean indicating if scene must be saved in the database
  68297. */
  68298. enableSceneOffline: boolean;
  68299. /**
  68300. * Gets a boolean indicating if textures must be saved in the database
  68301. */
  68302. enableTexturesOffline: boolean;
  68303. /**
  68304. * Open the offline support and make it available
  68305. * @param successCallback defines the callback to call on success
  68306. * @param errorCallback defines the callback to call on error
  68307. */
  68308. open(successCallback: () => void, errorCallback: () => void): void;
  68309. /**
  68310. * Loads an image from the offline support
  68311. * @param url defines the url to load from
  68312. * @param image defines the target DOM image
  68313. */
  68314. loadImage(url: string, image: HTMLImageElement): void;
  68315. /**
  68316. * Loads a file from offline support
  68317. * @param url defines the URL to load from
  68318. * @param sceneLoaded defines a callback to call on success
  68319. * @param progressCallBack defines a callback to call when progress changed
  68320. * @param errorCallback defines a callback to call on error
  68321. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68322. */
  68323. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68324. }
  68325. }
  68326. declare module BABYLON {
  68327. /**
  68328. * Class used to help managing file picking and drag'n'drop
  68329. * File Storage
  68330. */
  68331. export class FilesInputStore {
  68332. /**
  68333. * List of files ready to be loaded
  68334. */
  68335. static FilesToLoad: {
  68336. [key: string]: File;
  68337. };
  68338. }
  68339. }
  68340. declare module BABYLON {
  68341. /**
  68342. * Class used to define a retry strategy when error happens while loading assets
  68343. */
  68344. export class RetryStrategy {
  68345. /**
  68346. * Function used to defines an exponential back off strategy
  68347. * @param maxRetries defines the maximum number of retries (3 by default)
  68348. * @param baseInterval defines the interval between retries
  68349. * @returns the strategy function to use
  68350. */
  68351. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68352. }
  68353. }
  68354. declare module BABYLON {
  68355. /**
  68356. * @hidden
  68357. */
  68358. export class FileTools {
  68359. /**
  68360. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68361. */
  68362. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68363. /**
  68364. * Gets or sets the base URL to use to load assets
  68365. */
  68366. static BaseUrl: string;
  68367. /**
  68368. * Default behaviour for cors in the application.
  68369. * It can be a string if the expected behavior is identical in the entire app.
  68370. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68371. */
  68372. static CorsBehavior: string | ((url: string | string[]) => string);
  68373. /**
  68374. * Gets or sets a function used to pre-process url before using them to load assets
  68375. */
  68376. static PreprocessUrl: (url: string) => string;
  68377. /**
  68378. * Removes unwanted characters from an url
  68379. * @param url defines the url to clean
  68380. * @returns the cleaned url
  68381. */
  68382. private static _CleanUrl;
  68383. /**
  68384. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68385. * @param url define the url we are trying
  68386. * @param element define the dom element where to configure the cors policy
  68387. */
  68388. static SetCorsBehavior(url: string | string[], element: {
  68389. crossOrigin: string | null;
  68390. }): void;
  68391. /**
  68392. * Loads an image as an HTMLImageElement.
  68393. * @param input url string, ArrayBuffer, or Blob to load
  68394. * @param onLoad callback called when the image successfully loads
  68395. * @param onError callback called when the image fails to load
  68396. * @param offlineProvider offline provider for caching
  68397. * @returns the HTMLImageElement of the loaded image
  68398. */
  68399. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68400. /**
  68401. * Loads a file
  68402. * @param fileToLoad defines the file to load
  68403. * @param callback defines the callback to call when data is loaded
  68404. * @param progressCallBack defines the callback to call during loading process
  68405. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68406. * @returns a file request object
  68407. */
  68408. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68409. /**
  68410. * Loads a file
  68411. * @param url url string, ArrayBuffer, or Blob to load
  68412. * @param onSuccess callback called when the file successfully loads
  68413. * @param onProgress callback called while file is loading (if the server supports this mode)
  68414. * @param offlineProvider defines the offline provider for caching
  68415. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68416. * @param onError callback called when the file fails to load
  68417. * @returns a file request object
  68418. */
  68419. 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;
  68420. /**
  68421. * Checks if the loaded document was accessed via `file:`-Protocol.
  68422. * @returns boolean
  68423. */
  68424. static IsFileURL(): boolean;
  68425. }
  68426. }
  68427. declare module BABYLON {
  68428. /** @hidden */
  68429. export class ShaderProcessor {
  68430. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68431. private static _ProcessPrecision;
  68432. private static _ExtractOperation;
  68433. private static _BuildSubExpression;
  68434. private static _BuildExpression;
  68435. private static _MoveCursorWithinIf;
  68436. private static _MoveCursor;
  68437. private static _EvaluatePreProcessors;
  68438. private static _PreparePreProcessors;
  68439. private static _ProcessShaderConversion;
  68440. private static _ProcessIncludes;
  68441. }
  68442. }
  68443. declare module BABYLON {
  68444. /**
  68445. * Class used to hold a RBG color
  68446. */
  68447. export class Color3 {
  68448. /**
  68449. * Defines the red component (between 0 and 1, default is 0)
  68450. */
  68451. r: number;
  68452. /**
  68453. * Defines the green component (between 0 and 1, default is 0)
  68454. */
  68455. g: number;
  68456. /**
  68457. * Defines the blue component (between 0 and 1, default is 0)
  68458. */
  68459. b: number;
  68460. /**
  68461. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  68462. * @param r defines the red component (between 0 and 1, default is 0)
  68463. * @param g defines the green component (between 0 and 1, default is 0)
  68464. * @param b defines the blue component (between 0 and 1, default is 0)
  68465. */
  68466. constructor(
  68467. /**
  68468. * Defines the red component (between 0 and 1, default is 0)
  68469. */
  68470. r?: number,
  68471. /**
  68472. * Defines the green component (between 0 and 1, default is 0)
  68473. */
  68474. g?: number,
  68475. /**
  68476. * Defines the blue component (between 0 and 1, default is 0)
  68477. */
  68478. b?: number);
  68479. /**
  68480. * Creates a string with the Color3 current values
  68481. * @returns the string representation of the Color3 object
  68482. */
  68483. toString(): string;
  68484. /**
  68485. * Returns the string "Color3"
  68486. * @returns "Color3"
  68487. */
  68488. getClassName(): string;
  68489. /**
  68490. * Compute the Color3 hash code
  68491. * @returns an unique number that can be used to hash Color3 objects
  68492. */
  68493. getHashCode(): number;
  68494. /**
  68495. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  68496. * @param array defines the array where to store the r,g,b components
  68497. * @param index defines an optional index in the target array to define where to start storing values
  68498. * @returns the current Color3 object
  68499. */
  68500. toArray(array: FloatArray, index?: number): Color3;
  68501. /**
  68502. * Returns a new Color4 object from the current Color3 and the given alpha
  68503. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  68504. * @returns a new Color4 object
  68505. */
  68506. toColor4(alpha?: number): Color4;
  68507. /**
  68508. * Returns a new array populated with 3 numeric elements : red, green and blue values
  68509. * @returns the new array
  68510. */
  68511. asArray(): number[];
  68512. /**
  68513. * Returns the luminance value
  68514. * @returns a float value
  68515. */
  68516. toLuminance(): number;
  68517. /**
  68518. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  68519. * @param otherColor defines the second operand
  68520. * @returns the new Color3 object
  68521. */
  68522. multiply(otherColor: DeepImmutable<Color3>): Color3;
  68523. /**
  68524. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  68525. * @param otherColor defines the second operand
  68526. * @param result defines the Color3 object where to store the result
  68527. * @returns the current Color3
  68528. */
  68529. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68530. /**
  68531. * Determines equality between Color3 objects
  68532. * @param otherColor defines the second operand
  68533. * @returns true if the rgb values are equal to the given ones
  68534. */
  68535. equals(otherColor: DeepImmutable<Color3>): boolean;
  68536. /**
  68537. * Determines equality between the current Color3 object and a set of r,b,g values
  68538. * @param r defines the red component to check
  68539. * @param g defines the green component to check
  68540. * @param b defines the blue component to check
  68541. * @returns true if the rgb values are equal to the given ones
  68542. */
  68543. equalsFloats(r: number, g: number, b: number): boolean;
  68544. /**
  68545. * Multiplies in place each rgb value by scale
  68546. * @param scale defines the scaling factor
  68547. * @returns the updated Color3
  68548. */
  68549. scale(scale: number): Color3;
  68550. /**
  68551. * Multiplies the rgb values by scale and stores the result into "result"
  68552. * @param scale defines the scaling factor
  68553. * @param result defines the Color3 object where to store the result
  68554. * @returns the unmodified current Color3
  68555. */
  68556. scaleToRef(scale: number, result: Color3): Color3;
  68557. /**
  68558. * Scale the current Color3 values by a factor and add the result to a given Color3
  68559. * @param scale defines the scale factor
  68560. * @param result defines color to store the result into
  68561. * @returns the unmodified current Color3
  68562. */
  68563. scaleAndAddToRef(scale: number, result: Color3): Color3;
  68564. /**
  68565. * Clamps the rgb values by the min and max values and stores the result into "result"
  68566. * @param min defines minimum clamping value (default is 0)
  68567. * @param max defines maximum clamping value (default is 1)
  68568. * @param result defines color to store the result into
  68569. * @returns the original Color3
  68570. */
  68571. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  68572. /**
  68573. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68574. * @param otherColor defines the second operand
  68575. * @returns the new Color3
  68576. */
  68577. add(otherColor: DeepImmutable<Color3>): Color3;
  68578. /**
  68579. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68580. * @param otherColor defines the second operand
  68581. * @param result defines Color3 object to store the result into
  68582. * @returns the unmodified current Color3
  68583. */
  68584. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68585. /**
  68586. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68587. * @param otherColor defines the second operand
  68588. * @returns the new Color3
  68589. */
  68590. subtract(otherColor: DeepImmutable<Color3>): Color3;
  68591. /**
  68592. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68593. * @param otherColor defines the second operand
  68594. * @param result defines Color3 object to store the result into
  68595. * @returns the unmodified current Color3
  68596. */
  68597. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68598. /**
  68599. * Copy the current object
  68600. * @returns a new Color3 copied the current one
  68601. */
  68602. clone(): Color3;
  68603. /**
  68604. * Copies the rgb values from the source in the current Color3
  68605. * @param source defines the source Color3 object
  68606. * @returns the updated Color3 object
  68607. */
  68608. copyFrom(source: DeepImmutable<Color3>): Color3;
  68609. /**
  68610. * Updates the Color3 rgb values from the given floats
  68611. * @param r defines the red component to read from
  68612. * @param g defines the green component to read from
  68613. * @param b defines the blue component to read from
  68614. * @returns the current Color3 object
  68615. */
  68616. copyFromFloats(r: number, g: number, b: number): Color3;
  68617. /**
  68618. * Updates the Color3 rgb values from the given floats
  68619. * @param r defines the red component to read from
  68620. * @param g defines the green component to read from
  68621. * @param b defines the blue component to read from
  68622. * @returns the current Color3 object
  68623. */
  68624. set(r: number, g: number, b: number): Color3;
  68625. /**
  68626. * Compute the Color3 hexadecimal code as a string
  68627. * @returns a string containing the hexadecimal representation of the Color3 object
  68628. */
  68629. toHexString(): string;
  68630. /**
  68631. * Computes a new Color3 converted from the current one to linear space
  68632. * @returns a new Color3 object
  68633. */
  68634. toLinearSpace(): Color3;
  68635. /**
  68636. * Converts current color in rgb space to HSV values
  68637. * @returns a new color3 representing the HSV values
  68638. */
  68639. toHSV(): Color3;
  68640. /**
  68641. * Converts current color in rgb space to HSV values
  68642. * @param result defines the Color3 where to store the HSV values
  68643. */
  68644. toHSVToRef(result: Color3): void;
  68645. /**
  68646. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68647. * @param convertedColor defines the Color3 object where to store the linear space version
  68648. * @returns the unmodified Color3
  68649. */
  68650. toLinearSpaceToRef(convertedColor: Color3): Color3;
  68651. /**
  68652. * Computes a new Color3 converted from the current one to gamma space
  68653. * @returns a new Color3 object
  68654. */
  68655. toGammaSpace(): Color3;
  68656. /**
  68657. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68658. * @param convertedColor defines the Color3 object where to store the gamma space version
  68659. * @returns the unmodified Color3
  68660. */
  68661. toGammaSpaceToRef(convertedColor: Color3): Color3;
  68662. private static _BlackReadOnly;
  68663. /**
  68664. * Convert Hue, saturation and value to a Color3 (RGB)
  68665. * @param hue defines the hue
  68666. * @param saturation defines the saturation
  68667. * @param value defines the value
  68668. * @param result defines the Color3 where to store the RGB values
  68669. */
  68670. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  68671. /**
  68672. * Creates a new Color3 from the string containing valid hexadecimal values
  68673. * @param hex defines a string containing valid hexadecimal values
  68674. * @returns a new Color3 object
  68675. */
  68676. static FromHexString(hex: string): Color3;
  68677. /**
  68678. * Creates a new Color3 from the starting index of the given array
  68679. * @param array defines the source array
  68680. * @param offset defines an offset in the source array
  68681. * @returns a new Color3 object
  68682. */
  68683. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  68684. /**
  68685. * Creates a new Color3 from integer values (< 256)
  68686. * @param r defines the red component to read from (value between 0 and 255)
  68687. * @param g defines the green component to read from (value between 0 and 255)
  68688. * @param b defines the blue component to read from (value between 0 and 255)
  68689. * @returns a new Color3 object
  68690. */
  68691. static FromInts(r: number, g: number, b: number): Color3;
  68692. /**
  68693. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68694. * @param start defines the start Color3 value
  68695. * @param end defines the end Color3 value
  68696. * @param amount defines the gradient value between start and end
  68697. * @returns a new Color3 object
  68698. */
  68699. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  68700. /**
  68701. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68702. * @param left defines the start value
  68703. * @param right defines the end value
  68704. * @param amount defines the gradient factor
  68705. * @param result defines the Color3 object where to store the result
  68706. */
  68707. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  68708. /**
  68709. * Returns a Color3 value containing a red color
  68710. * @returns a new Color3 object
  68711. */
  68712. static Red(): Color3;
  68713. /**
  68714. * Returns a Color3 value containing a green color
  68715. * @returns a new Color3 object
  68716. */
  68717. static Green(): Color3;
  68718. /**
  68719. * Returns a Color3 value containing a blue color
  68720. * @returns a new Color3 object
  68721. */
  68722. static Blue(): Color3;
  68723. /**
  68724. * Returns a Color3 value containing a black color
  68725. * @returns a new Color3 object
  68726. */
  68727. static Black(): Color3;
  68728. /**
  68729. * Gets a Color3 value containing a black color that must not be updated
  68730. */
  68731. static readonly BlackReadOnly: DeepImmutable<Color3>;
  68732. /**
  68733. * Returns a Color3 value containing a white color
  68734. * @returns a new Color3 object
  68735. */
  68736. static White(): Color3;
  68737. /**
  68738. * Returns a Color3 value containing a purple color
  68739. * @returns a new Color3 object
  68740. */
  68741. static Purple(): Color3;
  68742. /**
  68743. * Returns a Color3 value containing a magenta color
  68744. * @returns a new Color3 object
  68745. */
  68746. static Magenta(): Color3;
  68747. /**
  68748. * Returns a Color3 value containing a yellow color
  68749. * @returns a new Color3 object
  68750. */
  68751. static Yellow(): Color3;
  68752. /**
  68753. * Returns a Color3 value containing a gray color
  68754. * @returns a new Color3 object
  68755. */
  68756. static Gray(): Color3;
  68757. /**
  68758. * Returns a Color3 value containing a teal color
  68759. * @returns a new Color3 object
  68760. */
  68761. static Teal(): Color3;
  68762. /**
  68763. * Returns a Color3 value containing a random color
  68764. * @returns a new Color3 object
  68765. */
  68766. static Random(): Color3;
  68767. }
  68768. /**
  68769. * Class used to hold a RBGA color
  68770. */
  68771. export class Color4 {
  68772. /**
  68773. * Defines the red component (between 0 and 1, default is 0)
  68774. */
  68775. r: number;
  68776. /**
  68777. * Defines the green component (between 0 and 1, default is 0)
  68778. */
  68779. g: number;
  68780. /**
  68781. * Defines the blue component (between 0 and 1, default is 0)
  68782. */
  68783. b: number;
  68784. /**
  68785. * Defines the alpha component (between 0 and 1, default is 1)
  68786. */
  68787. a: number;
  68788. /**
  68789. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  68790. * @param r defines the red component (between 0 and 1, default is 0)
  68791. * @param g defines the green component (between 0 and 1, default is 0)
  68792. * @param b defines the blue component (between 0 and 1, default is 0)
  68793. * @param a defines the alpha component (between 0 and 1, default is 1)
  68794. */
  68795. constructor(
  68796. /**
  68797. * Defines the red component (between 0 and 1, default is 0)
  68798. */
  68799. r?: number,
  68800. /**
  68801. * Defines the green component (between 0 and 1, default is 0)
  68802. */
  68803. g?: number,
  68804. /**
  68805. * Defines the blue component (between 0 and 1, default is 0)
  68806. */
  68807. b?: number,
  68808. /**
  68809. * Defines the alpha component (between 0 and 1, default is 1)
  68810. */
  68811. a?: number);
  68812. /**
  68813. * Adds in place the given Color4 values to the current Color4 object
  68814. * @param right defines the second operand
  68815. * @returns the current updated Color4 object
  68816. */
  68817. addInPlace(right: DeepImmutable<Color4>): Color4;
  68818. /**
  68819. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68820. * @returns the new array
  68821. */
  68822. asArray(): number[];
  68823. /**
  68824. * Stores from the starting index in the given array the Color4 successive values
  68825. * @param array defines the array where to store the r,g,b components
  68826. * @param index defines an optional index in the target array to define where to start storing values
  68827. * @returns the current Color4 object
  68828. */
  68829. toArray(array: number[], index?: number): Color4;
  68830. /**
  68831. * Determines equality between Color4 objects
  68832. * @param otherColor defines the second operand
  68833. * @returns true if the rgba values are equal to the given ones
  68834. */
  68835. equals(otherColor: DeepImmutable<Color4>): boolean;
  68836. /**
  68837. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68838. * @param right defines the second operand
  68839. * @returns a new Color4 object
  68840. */
  68841. add(right: DeepImmutable<Color4>): Color4;
  68842. /**
  68843. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68844. * @param right defines the second operand
  68845. * @returns a new Color4 object
  68846. */
  68847. subtract(right: DeepImmutable<Color4>): Color4;
  68848. /**
  68849. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68850. * @param right defines the second operand
  68851. * @param result defines the Color4 object where to store the result
  68852. * @returns the current Color4 object
  68853. */
  68854. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  68855. /**
  68856. * Creates a new Color4 with the current Color4 values multiplied by scale
  68857. * @param scale defines the scaling factor to apply
  68858. * @returns a new Color4 object
  68859. */
  68860. scale(scale: number): Color4;
  68861. /**
  68862. * Multiplies the current Color4 values by scale and stores the result in "result"
  68863. * @param scale defines the scaling factor to apply
  68864. * @param result defines the Color4 object where to store the result
  68865. * @returns the current unmodified Color4
  68866. */
  68867. scaleToRef(scale: number, result: Color4): Color4;
  68868. /**
  68869. * Scale the current Color4 values by a factor and add the result to a given Color4
  68870. * @param scale defines the scale factor
  68871. * @param result defines the Color4 object where to store the result
  68872. * @returns the unmodified current Color4
  68873. */
  68874. scaleAndAddToRef(scale: number, result: Color4): Color4;
  68875. /**
  68876. * Clamps the rgb values by the min and max values and stores the result into "result"
  68877. * @param min defines minimum clamping value (default is 0)
  68878. * @param max defines maximum clamping value (default is 1)
  68879. * @param result defines color to store the result into.
  68880. * @returns the cuurent Color4
  68881. */
  68882. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  68883. /**
  68884. * Multipy an Color4 value by another and return a new Color4 object
  68885. * @param color defines the Color4 value to multiply by
  68886. * @returns a new Color4 object
  68887. */
  68888. multiply(color: Color4): Color4;
  68889. /**
  68890. * Multipy a Color4 value by another and push the result in a reference value
  68891. * @param color defines the Color4 value to multiply by
  68892. * @param result defines the Color4 to fill the result in
  68893. * @returns the result Color4
  68894. */
  68895. multiplyToRef(color: Color4, result: Color4): Color4;
  68896. /**
  68897. * Creates a string with the Color4 current values
  68898. * @returns the string representation of the Color4 object
  68899. */
  68900. toString(): string;
  68901. /**
  68902. * Returns the string "Color4"
  68903. * @returns "Color4"
  68904. */
  68905. getClassName(): string;
  68906. /**
  68907. * Compute the Color4 hash code
  68908. * @returns an unique number that can be used to hash Color4 objects
  68909. */
  68910. getHashCode(): number;
  68911. /**
  68912. * Creates a new Color4 copied from the current one
  68913. * @returns a new Color4 object
  68914. */
  68915. clone(): Color4;
  68916. /**
  68917. * Copies the given Color4 values into the current one
  68918. * @param source defines the source Color4 object
  68919. * @returns the current updated Color4 object
  68920. */
  68921. copyFrom(source: Color4): Color4;
  68922. /**
  68923. * Copies the given float values into the current one
  68924. * @param r defines the red component to read from
  68925. * @param g defines the green component to read from
  68926. * @param b defines the blue component to read from
  68927. * @param a defines the alpha component to read from
  68928. * @returns the current updated Color4 object
  68929. */
  68930. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  68931. /**
  68932. * Copies the given float values into the current one
  68933. * @param r defines the red component to read from
  68934. * @param g defines the green component to read from
  68935. * @param b defines the blue component to read from
  68936. * @param a defines the alpha component to read from
  68937. * @returns the current updated Color4 object
  68938. */
  68939. set(r: number, g: number, b: number, a: number): Color4;
  68940. /**
  68941. * Compute the Color4 hexadecimal code as a string
  68942. * @returns a string containing the hexadecimal representation of the Color4 object
  68943. */
  68944. toHexString(): string;
  68945. /**
  68946. * Computes a new Color4 converted from the current one to linear space
  68947. * @returns a new Color4 object
  68948. */
  68949. toLinearSpace(): Color4;
  68950. /**
  68951. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  68952. * @param convertedColor defines the Color4 object where to store the linear space version
  68953. * @returns the unmodified Color4
  68954. */
  68955. toLinearSpaceToRef(convertedColor: Color4): Color4;
  68956. /**
  68957. * Computes a new Color4 converted from the current one to gamma space
  68958. * @returns a new Color4 object
  68959. */
  68960. toGammaSpace(): Color4;
  68961. /**
  68962. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  68963. * @param convertedColor defines the Color4 object where to store the gamma space version
  68964. * @returns the unmodified Color4
  68965. */
  68966. toGammaSpaceToRef(convertedColor: Color4): Color4;
  68967. /**
  68968. * Creates a new Color4 from the string containing valid hexadecimal values
  68969. * @param hex defines a string containing valid hexadecimal values
  68970. * @returns a new Color4 object
  68971. */
  68972. static FromHexString(hex: string): Color4;
  68973. /**
  68974. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68975. * @param left defines the start value
  68976. * @param right defines the end value
  68977. * @param amount defines the gradient factor
  68978. * @returns a new Color4 object
  68979. */
  68980. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  68981. /**
  68982. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68983. * @param left defines the start value
  68984. * @param right defines the end value
  68985. * @param amount defines the gradient factor
  68986. * @param result defines the Color4 object where to store data
  68987. */
  68988. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  68989. /**
  68990. * Creates a new Color4 from a Color3 and an alpha value
  68991. * @param color3 defines the source Color3 to read from
  68992. * @param alpha defines the alpha component (1.0 by default)
  68993. * @returns a new Color4 object
  68994. */
  68995. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  68996. /**
  68997. * Creates a new Color4 from the starting index element of the given array
  68998. * @param array defines the source array to read from
  68999. * @param offset defines the offset in the source array
  69000. * @returns a new Color4 object
  69001. */
  69002. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69003. /**
  69004. * Creates a new Color3 from integer values (< 256)
  69005. * @param r defines the red component to read from (value between 0 and 255)
  69006. * @param g defines the green component to read from (value between 0 and 255)
  69007. * @param b defines the blue component to read from (value between 0 and 255)
  69008. * @param a defines the alpha component to read from (value between 0 and 255)
  69009. * @returns a new Color3 object
  69010. */
  69011. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69012. /**
  69013. * Check the content of a given array and convert it to an array containing RGBA data
  69014. * If the original array was already containing count * 4 values then it is returned directly
  69015. * @param colors defines the array to check
  69016. * @param count defines the number of RGBA data to expect
  69017. * @returns an array containing count * 4 values (RGBA)
  69018. */
  69019. static CheckColors4(colors: number[], count: number): number[];
  69020. }
  69021. /**
  69022. * @hidden
  69023. */
  69024. export class TmpColors {
  69025. static Color3: Color3[];
  69026. static Color4: Color4[];
  69027. }
  69028. }
  69029. declare module BABYLON {
  69030. /**
  69031. * Class representing spherical harmonics coefficients to the 3rd degree
  69032. */
  69033. export class SphericalHarmonics {
  69034. /**
  69035. * Defines whether or not the harmonics have been prescaled for rendering.
  69036. */
  69037. preScaled: boolean;
  69038. /**
  69039. * The l0,0 coefficients of the spherical harmonics
  69040. */
  69041. l00: Vector3;
  69042. /**
  69043. * The l1,-1 coefficients of the spherical harmonics
  69044. */
  69045. l1_1: Vector3;
  69046. /**
  69047. * The l1,0 coefficients of the spherical harmonics
  69048. */
  69049. l10: Vector3;
  69050. /**
  69051. * The l1,1 coefficients of the spherical harmonics
  69052. */
  69053. l11: Vector3;
  69054. /**
  69055. * The l2,-2 coefficients of the spherical harmonics
  69056. */
  69057. l2_2: Vector3;
  69058. /**
  69059. * The l2,-1 coefficients of the spherical harmonics
  69060. */
  69061. l2_1: Vector3;
  69062. /**
  69063. * The l2,0 coefficients of the spherical harmonics
  69064. */
  69065. l20: Vector3;
  69066. /**
  69067. * The l2,1 coefficients of the spherical harmonics
  69068. */
  69069. l21: Vector3;
  69070. /**
  69071. * The l2,2 coefficients of the spherical harmonics
  69072. */
  69073. l22: Vector3;
  69074. /**
  69075. * Adds a light to the spherical harmonics
  69076. * @param direction the direction of the light
  69077. * @param color the color of the light
  69078. * @param deltaSolidAngle the delta solid angle of the light
  69079. */
  69080. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69081. /**
  69082. * Scales the spherical harmonics by the given amount
  69083. * @param scale the amount to scale
  69084. */
  69085. scaleInPlace(scale: number): void;
  69086. /**
  69087. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69088. *
  69089. * ```
  69090. * E_lm = A_l * L_lm
  69091. * ```
  69092. *
  69093. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69094. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69095. * the scaling factors are given in equation 9.
  69096. */
  69097. convertIncidentRadianceToIrradiance(): void;
  69098. /**
  69099. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69100. *
  69101. * ```
  69102. * L = (1/pi) * E * rho
  69103. * ```
  69104. *
  69105. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69106. */
  69107. convertIrradianceToLambertianRadiance(): void;
  69108. /**
  69109. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69110. * required operations at run time.
  69111. *
  69112. * This is simply done by scaling back the SH with Ylm constants parameter.
  69113. * The trigonometric part being applied by the shader at run time.
  69114. */
  69115. preScaleForRendering(): void;
  69116. /**
  69117. * Constructs a spherical harmonics from an array.
  69118. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69119. * @returns the spherical harmonics
  69120. */
  69121. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69122. /**
  69123. * Gets the spherical harmonics from polynomial
  69124. * @param polynomial the spherical polynomial
  69125. * @returns the spherical harmonics
  69126. */
  69127. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69128. }
  69129. /**
  69130. * Class representing spherical polynomial coefficients to the 3rd degree
  69131. */
  69132. export class SphericalPolynomial {
  69133. private _harmonics;
  69134. /**
  69135. * The spherical harmonics used to create the polynomials.
  69136. */
  69137. readonly preScaledHarmonics: SphericalHarmonics;
  69138. /**
  69139. * The x coefficients of the spherical polynomial
  69140. */
  69141. x: Vector3;
  69142. /**
  69143. * The y coefficients of the spherical polynomial
  69144. */
  69145. y: Vector3;
  69146. /**
  69147. * The z coefficients of the spherical polynomial
  69148. */
  69149. z: Vector3;
  69150. /**
  69151. * The xx coefficients of the spherical polynomial
  69152. */
  69153. xx: Vector3;
  69154. /**
  69155. * The yy coefficients of the spherical polynomial
  69156. */
  69157. yy: Vector3;
  69158. /**
  69159. * The zz coefficients of the spherical polynomial
  69160. */
  69161. zz: Vector3;
  69162. /**
  69163. * The xy coefficients of the spherical polynomial
  69164. */
  69165. xy: Vector3;
  69166. /**
  69167. * The yz coefficients of the spherical polynomial
  69168. */
  69169. yz: Vector3;
  69170. /**
  69171. * The zx coefficients of the spherical polynomial
  69172. */
  69173. zx: Vector3;
  69174. /**
  69175. * Adds an ambient color to the spherical polynomial
  69176. * @param color the color to add
  69177. */
  69178. addAmbient(color: Color3): void;
  69179. /**
  69180. * Scales the spherical polynomial by the given amount
  69181. * @param scale the amount to scale
  69182. */
  69183. scaleInPlace(scale: number): void;
  69184. /**
  69185. * Gets the spherical polynomial from harmonics
  69186. * @param harmonics the spherical harmonics
  69187. * @returns the spherical polynomial
  69188. */
  69189. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69190. /**
  69191. * Constructs a spherical polynomial from an array.
  69192. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69193. * @returns the spherical polynomial
  69194. */
  69195. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69196. }
  69197. }
  69198. declare module BABYLON {
  69199. /**
  69200. * Define options used to create a render target texture
  69201. */
  69202. export class RenderTargetCreationOptions {
  69203. /**
  69204. * Specifies is mipmaps must be generated
  69205. */
  69206. generateMipMaps?: boolean;
  69207. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69208. generateDepthBuffer?: boolean;
  69209. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69210. generateStencilBuffer?: boolean;
  69211. /** Defines texture type (int by default) */
  69212. type?: number;
  69213. /** Defines sampling mode (trilinear by default) */
  69214. samplingMode?: number;
  69215. /** Defines format (RGBA by default) */
  69216. format?: number;
  69217. }
  69218. }
  69219. declare module BABYLON {
  69220. /**
  69221. * @hidden
  69222. **/
  69223. export class _AlphaState {
  69224. private _isAlphaBlendDirty;
  69225. private _isBlendFunctionParametersDirty;
  69226. private _isBlendEquationParametersDirty;
  69227. private _isBlendConstantsDirty;
  69228. private _alphaBlend;
  69229. private _blendFunctionParameters;
  69230. private _blendEquationParameters;
  69231. private _blendConstants;
  69232. /**
  69233. * Initializes the state.
  69234. */
  69235. constructor();
  69236. readonly isDirty: boolean;
  69237. alphaBlend: boolean;
  69238. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69239. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69240. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69241. reset(): void;
  69242. apply(gl: WebGLRenderingContext): void;
  69243. }
  69244. }
  69245. declare module BABYLON {
  69246. /**
  69247. * @hidden
  69248. **/
  69249. export class _DepthCullingState {
  69250. private _isDepthTestDirty;
  69251. private _isDepthMaskDirty;
  69252. private _isDepthFuncDirty;
  69253. private _isCullFaceDirty;
  69254. private _isCullDirty;
  69255. private _isZOffsetDirty;
  69256. private _isFrontFaceDirty;
  69257. private _depthTest;
  69258. private _depthMask;
  69259. private _depthFunc;
  69260. private _cull;
  69261. private _cullFace;
  69262. private _zOffset;
  69263. private _frontFace;
  69264. /**
  69265. * Initializes the state.
  69266. */
  69267. constructor();
  69268. readonly isDirty: boolean;
  69269. zOffset: number;
  69270. cullFace: Nullable<number>;
  69271. cull: Nullable<boolean>;
  69272. depthFunc: Nullable<number>;
  69273. depthMask: boolean;
  69274. depthTest: boolean;
  69275. frontFace: Nullable<number>;
  69276. reset(): void;
  69277. apply(gl: WebGLRenderingContext): void;
  69278. }
  69279. }
  69280. declare module BABYLON {
  69281. /**
  69282. * @hidden
  69283. **/
  69284. export class _StencilState {
  69285. /** 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 */
  69286. static readonly ALWAYS: number;
  69287. /** Passed to stencilOperation to specify that stencil value must be kept */
  69288. static readonly KEEP: number;
  69289. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69290. static readonly REPLACE: number;
  69291. private _isStencilTestDirty;
  69292. private _isStencilMaskDirty;
  69293. private _isStencilFuncDirty;
  69294. private _isStencilOpDirty;
  69295. private _stencilTest;
  69296. private _stencilMask;
  69297. private _stencilFunc;
  69298. private _stencilFuncRef;
  69299. private _stencilFuncMask;
  69300. private _stencilOpStencilFail;
  69301. private _stencilOpDepthFail;
  69302. private _stencilOpStencilDepthPass;
  69303. readonly isDirty: boolean;
  69304. stencilFunc: number;
  69305. stencilFuncRef: number;
  69306. stencilFuncMask: number;
  69307. stencilOpStencilFail: number;
  69308. stencilOpDepthFail: number;
  69309. stencilOpStencilDepthPass: number;
  69310. stencilMask: number;
  69311. stencilTest: boolean;
  69312. constructor();
  69313. reset(): void;
  69314. apply(gl: WebGLRenderingContext): void;
  69315. }
  69316. }
  69317. declare module BABYLON {
  69318. /**
  69319. * @hidden
  69320. **/
  69321. export class _TimeToken {
  69322. _startTimeQuery: Nullable<WebGLQuery>;
  69323. _endTimeQuery: Nullable<WebGLQuery>;
  69324. _timeElapsedQuery: Nullable<WebGLQuery>;
  69325. _timeElapsedQueryEnded: boolean;
  69326. }
  69327. }
  69328. declare module BABYLON {
  69329. /**
  69330. * Class used to evalaute queries containing `and` and `or` operators
  69331. */
  69332. export class AndOrNotEvaluator {
  69333. /**
  69334. * Evaluate a query
  69335. * @param query defines the query to evaluate
  69336. * @param evaluateCallback defines the callback used to filter result
  69337. * @returns true if the query matches
  69338. */
  69339. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69340. private static _HandleParenthesisContent;
  69341. private static _SimplifyNegation;
  69342. }
  69343. }
  69344. declare module BABYLON {
  69345. /**
  69346. * Class used to store custom tags
  69347. */
  69348. export class Tags {
  69349. /**
  69350. * Adds support for tags on the given object
  69351. * @param obj defines the object to use
  69352. */
  69353. static EnableFor(obj: any): void;
  69354. /**
  69355. * Removes tags support
  69356. * @param obj defines the object to use
  69357. */
  69358. static DisableFor(obj: any): void;
  69359. /**
  69360. * Gets a boolean indicating if the given object has tags
  69361. * @param obj defines the object to use
  69362. * @returns a boolean
  69363. */
  69364. static HasTags(obj: any): boolean;
  69365. /**
  69366. * Gets the tags available on a given object
  69367. * @param obj defines the object to use
  69368. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69369. * @returns the tags
  69370. */
  69371. static GetTags(obj: any, asString?: boolean): any;
  69372. /**
  69373. * Adds tags to an object
  69374. * @param obj defines the object to use
  69375. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69376. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69377. */
  69378. static AddTagsTo(obj: any, tagsString: string): void;
  69379. /**
  69380. * @hidden
  69381. */
  69382. static _AddTagTo(obj: any, tag: string): void;
  69383. /**
  69384. * Removes specific tags from a specific object
  69385. * @param obj defines the object to use
  69386. * @param tagsString defines the tags to remove
  69387. */
  69388. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69389. /**
  69390. * @hidden
  69391. */
  69392. static _RemoveTagFrom(obj: any, tag: string): void;
  69393. /**
  69394. * Defines if tags hosted on an object match a given query
  69395. * @param obj defines the object to use
  69396. * @param tagsQuery defines the tag query
  69397. * @returns a boolean
  69398. */
  69399. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69400. }
  69401. }
  69402. declare module BABYLON {
  69403. /**
  69404. * Defines potential orientation for back face culling
  69405. */
  69406. export enum Orientation {
  69407. /**
  69408. * Clockwise
  69409. */
  69410. CW = 0,
  69411. /** Counter clockwise */
  69412. CCW = 1
  69413. }
  69414. /** Class used to represent a Bezier curve */
  69415. export class BezierCurve {
  69416. /**
  69417. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  69418. * @param t defines the time
  69419. * @param x1 defines the left coordinate on X axis
  69420. * @param y1 defines the left coordinate on Y axis
  69421. * @param x2 defines the right coordinate on X axis
  69422. * @param y2 defines the right coordinate on Y axis
  69423. * @returns the interpolated value
  69424. */
  69425. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  69426. }
  69427. /**
  69428. * Defines angle representation
  69429. */
  69430. export class Angle {
  69431. private _radians;
  69432. /**
  69433. * Creates an Angle object of "radians" radians (float).
  69434. * @param radians the angle in radians
  69435. */
  69436. constructor(radians: number);
  69437. /**
  69438. * Get value in degrees
  69439. * @returns the Angle value in degrees (float)
  69440. */
  69441. degrees(): number;
  69442. /**
  69443. * Get value in radians
  69444. * @returns the Angle value in radians (float)
  69445. */
  69446. radians(): number;
  69447. /**
  69448. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  69449. * @param a defines first vector
  69450. * @param b defines second vector
  69451. * @returns a new Angle
  69452. */
  69453. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  69454. /**
  69455. * Gets a new Angle object from the given float in radians
  69456. * @param radians defines the angle value in radians
  69457. * @returns a new Angle
  69458. */
  69459. static FromRadians(radians: number): Angle;
  69460. /**
  69461. * Gets a new Angle object from the given float in degrees
  69462. * @param degrees defines the angle value in degrees
  69463. * @returns a new Angle
  69464. */
  69465. static FromDegrees(degrees: number): Angle;
  69466. }
  69467. /**
  69468. * This represents an arc in a 2d space.
  69469. */
  69470. export class Arc2 {
  69471. /** Defines the start point of the arc */
  69472. startPoint: Vector2;
  69473. /** Defines the mid point of the arc */
  69474. midPoint: Vector2;
  69475. /** Defines the end point of the arc */
  69476. endPoint: Vector2;
  69477. /**
  69478. * Defines the center point of the arc.
  69479. */
  69480. centerPoint: Vector2;
  69481. /**
  69482. * Defines the radius of the arc.
  69483. */
  69484. radius: number;
  69485. /**
  69486. * Defines the angle of the arc (from mid point to end point).
  69487. */
  69488. angle: Angle;
  69489. /**
  69490. * Defines the start angle of the arc (from start point to middle point).
  69491. */
  69492. startAngle: Angle;
  69493. /**
  69494. * Defines the orientation of the arc (clock wise/counter clock wise).
  69495. */
  69496. orientation: Orientation;
  69497. /**
  69498. * Creates an Arc object from the three given points : start, middle and end.
  69499. * @param startPoint Defines the start point of the arc
  69500. * @param midPoint Defines the midlle point of the arc
  69501. * @param endPoint Defines the end point of the arc
  69502. */
  69503. constructor(
  69504. /** Defines the start point of the arc */
  69505. startPoint: Vector2,
  69506. /** Defines the mid point of the arc */
  69507. midPoint: Vector2,
  69508. /** Defines the end point of the arc */
  69509. endPoint: Vector2);
  69510. }
  69511. /**
  69512. * Represents a 2D path made up of multiple 2D points
  69513. */
  69514. export class Path2 {
  69515. private _points;
  69516. private _length;
  69517. /**
  69518. * If the path start and end point are the same
  69519. */
  69520. closed: boolean;
  69521. /**
  69522. * Creates a Path2 object from the starting 2D coordinates x and y.
  69523. * @param x the starting points x value
  69524. * @param y the starting points y value
  69525. */
  69526. constructor(x: number, y: number);
  69527. /**
  69528. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  69529. * @param x the added points x value
  69530. * @param y the added points y value
  69531. * @returns the updated Path2.
  69532. */
  69533. addLineTo(x: number, y: number): Path2;
  69534. /**
  69535. * 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.
  69536. * @param midX middle point x value
  69537. * @param midY middle point y value
  69538. * @param endX end point x value
  69539. * @param endY end point y value
  69540. * @param numberOfSegments (default: 36)
  69541. * @returns the updated Path2.
  69542. */
  69543. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  69544. /**
  69545. * Closes the Path2.
  69546. * @returns the Path2.
  69547. */
  69548. close(): Path2;
  69549. /**
  69550. * Gets the sum of the distance between each sequential point in the path
  69551. * @returns the Path2 total length (float).
  69552. */
  69553. length(): number;
  69554. /**
  69555. * Gets the points which construct the path
  69556. * @returns the Path2 internal array of points.
  69557. */
  69558. getPoints(): Vector2[];
  69559. /**
  69560. * Retreives the point at the distance aways from the starting point
  69561. * @param normalizedLengthPosition the length along the path to retreive the point from
  69562. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  69563. */
  69564. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  69565. /**
  69566. * Creates a new path starting from an x and y position
  69567. * @param x starting x value
  69568. * @param y starting y value
  69569. * @returns a new Path2 starting at the coordinates (x, y).
  69570. */
  69571. static StartingAt(x: number, y: number): Path2;
  69572. }
  69573. /**
  69574. * Represents a 3D path made up of multiple 3D points
  69575. */
  69576. export class Path3D {
  69577. /**
  69578. * an array of Vector3, the curve axis of the Path3D
  69579. */
  69580. path: Vector3[];
  69581. private _curve;
  69582. private _distances;
  69583. private _tangents;
  69584. private _normals;
  69585. private _binormals;
  69586. private _raw;
  69587. /**
  69588. * new Path3D(path, normal, raw)
  69589. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  69590. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  69591. * @param path an array of Vector3, the curve axis of the Path3D
  69592. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  69593. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  69594. */
  69595. constructor(
  69596. /**
  69597. * an array of Vector3, the curve axis of the Path3D
  69598. */
  69599. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  69600. /**
  69601. * Returns the Path3D array of successive Vector3 designing its curve.
  69602. * @returns the Path3D array of successive Vector3 designing its curve.
  69603. */
  69604. getCurve(): Vector3[];
  69605. /**
  69606. * Returns an array populated with tangent vectors on each Path3D curve point.
  69607. * @returns an array populated with tangent vectors on each Path3D curve point.
  69608. */
  69609. getTangents(): Vector3[];
  69610. /**
  69611. * Returns an array populated with normal vectors on each Path3D curve point.
  69612. * @returns an array populated with normal vectors on each Path3D curve point.
  69613. */
  69614. getNormals(): Vector3[];
  69615. /**
  69616. * Returns an array populated with binormal vectors on each Path3D curve point.
  69617. * @returns an array populated with binormal vectors on each Path3D curve point.
  69618. */
  69619. getBinormals(): Vector3[];
  69620. /**
  69621. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  69622. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  69623. */
  69624. getDistances(): number[];
  69625. /**
  69626. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  69627. * @param path path which all values are copied into the curves points
  69628. * @param firstNormal which should be projected onto the curve
  69629. * @returns the same object updated.
  69630. */
  69631. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  69632. private _compute;
  69633. private _getFirstNonNullVector;
  69634. private _getLastNonNullVector;
  69635. private _normalVector;
  69636. }
  69637. /**
  69638. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69639. * A Curve3 is designed from a series of successive Vector3.
  69640. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  69641. */
  69642. export class Curve3 {
  69643. private _points;
  69644. private _length;
  69645. /**
  69646. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  69647. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  69648. * @param v1 (Vector3) the control point
  69649. * @param v2 (Vector3) the end point of the Quadratic Bezier
  69650. * @param nbPoints (integer) the wanted number of points in the curve
  69651. * @returns the created Curve3
  69652. */
  69653. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69654. /**
  69655. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  69656. * @param v0 (Vector3) the origin point of the Cubic Bezier
  69657. * @param v1 (Vector3) the first control point
  69658. * @param v2 (Vector3) the second control point
  69659. * @param v3 (Vector3) the end point of the Cubic Bezier
  69660. * @param nbPoints (integer) the wanted number of points in the curve
  69661. * @returns the created Curve3
  69662. */
  69663. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69664. /**
  69665. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  69666. * @param p1 (Vector3) the origin point of the Hermite Spline
  69667. * @param t1 (Vector3) the tangent vector at the origin point
  69668. * @param p2 (Vector3) the end point of the Hermite Spline
  69669. * @param t2 (Vector3) the tangent vector at the end point
  69670. * @param nbPoints (integer) the wanted number of points in the curve
  69671. * @returns the created Curve3
  69672. */
  69673. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69674. /**
  69675. * Returns a Curve3 object along a CatmullRom Spline curve :
  69676. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  69677. * @param nbPoints (integer) the wanted number of points between each curve control points
  69678. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  69679. * @returns the created Curve3
  69680. */
  69681. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  69682. /**
  69683. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69684. * A Curve3 is designed from a series of successive Vector3.
  69685. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  69686. * @param points points which make up the curve
  69687. */
  69688. constructor(points: Vector3[]);
  69689. /**
  69690. * @returns the Curve3 stored array of successive Vector3
  69691. */
  69692. getPoints(): Vector3[];
  69693. /**
  69694. * @returns the computed length (float) of the curve.
  69695. */
  69696. length(): number;
  69697. /**
  69698. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  69699. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  69700. * curveA and curveB keep unchanged.
  69701. * @param curve the curve to continue from this curve
  69702. * @returns the newly constructed curve
  69703. */
  69704. continue(curve: DeepImmutable<Curve3>): Curve3;
  69705. private _computeLength;
  69706. }
  69707. }
  69708. declare module BABYLON {
  69709. /**
  69710. * This represents the main contract an easing function should follow.
  69711. * Easing functions are used throughout the animation system.
  69712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69713. */
  69714. export interface IEasingFunction {
  69715. /**
  69716. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69717. * of the easing function.
  69718. * The link below provides some of the most common examples of easing functions.
  69719. * @see https://easings.net/
  69720. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69721. * @returns the corresponding value on the curve defined by the easing function
  69722. */
  69723. ease(gradient: number): number;
  69724. }
  69725. /**
  69726. * Base class used for every default easing function.
  69727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69728. */
  69729. export class EasingFunction implements IEasingFunction {
  69730. /**
  69731. * Interpolation follows the mathematical formula associated with the easing function.
  69732. */
  69733. static readonly EASINGMODE_EASEIN: number;
  69734. /**
  69735. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69736. */
  69737. static readonly EASINGMODE_EASEOUT: number;
  69738. /**
  69739. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69740. */
  69741. static readonly EASINGMODE_EASEINOUT: number;
  69742. private _easingMode;
  69743. /**
  69744. * Sets the easing mode of the current function.
  69745. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69746. */
  69747. setEasingMode(easingMode: number): void;
  69748. /**
  69749. * Gets the current easing mode.
  69750. * @returns the easing mode
  69751. */
  69752. getEasingMode(): number;
  69753. /**
  69754. * @hidden
  69755. */
  69756. easeInCore(gradient: number): number;
  69757. /**
  69758. * Given an input gradient between 0 and 1, this returns the corresponding value
  69759. * of the easing function.
  69760. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69761. * @returns the corresponding value on the curve defined by the easing function
  69762. */
  69763. ease(gradient: number): number;
  69764. }
  69765. /**
  69766. * Easing function with a circle shape (see link below).
  69767. * @see https://easings.net/#easeInCirc
  69768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69769. */
  69770. export class CircleEase extends EasingFunction implements IEasingFunction {
  69771. /** @hidden */
  69772. easeInCore(gradient: number): number;
  69773. }
  69774. /**
  69775. * Easing function with a ease back shape (see link below).
  69776. * @see https://easings.net/#easeInBack
  69777. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69778. */
  69779. export class BackEase extends EasingFunction implements IEasingFunction {
  69780. /** Defines the amplitude of the function */
  69781. amplitude: number;
  69782. /**
  69783. * Instantiates a back ease easing
  69784. * @see https://easings.net/#easeInBack
  69785. * @param amplitude Defines the amplitude of the function
  69786. */
  69787. constructor(
  69788. /** Defines the amplitude of the function */
  69789. amplitude?: number);
  69790. /** @hidden */
  69791. easeInCore(gradient: number): number;
  69792. }
  69793. /**
  69794. * Easing function with a bouncing shape (see link below).
  69795. * @see https://easings.net/#easeInBounce
  69796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69797. */
  69798. export class BounceEase extends EasingFunction implements IEasingFunction {
  69799. /** Defines the number of bounces */
  69800. bounces: number;
  69801. /** Defines the amplitude of the bounce */
  69802. bounciness: number;
  69803. /**
  69804. * Instantiates a bounce easing
  69805. * @see https://easings.net/#easeInBounce
  69806. * @param bounces Defines the number of bounces
  69807. * @param bounciness Defines the amplitude of the bounce
  69808. */
  69809. constructor(
  69810. /** Defines the number of bounces */
  69811. bounces?: number,
  69812. /** Defines the amplitude of the bounce */
  69813. bounciness?: number);
  69814. /** @hidden */
  69815. easeInCore(gradient: number): number;
  69816. }
  69817. /**
  69818. * Easing function with a power of 3 shape (see link below).
  69819. * @see https://easings.net/#easeInCubic
  69820. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69821. */
  69822. export class CubicEase extends EasingFunction implements IEasingFunction {
  69823. /** @hidden */
  69824. easeInCore(gradient: number): number;
  69825. }
  69826. /**
  69827. * Easing function with an elastic shape (see link below).
  69828. * @see https://easings.net/#easeInElastic
  69829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69830. */
  69831. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69832. /** Defines the number of oscillations*/
  69833. oscillations: number;
  69834. /** Defines the amplitude of the oscillations*/
  69835. springiness: number;
  69836. /**
  69837. * Instantiates an elastic easing function
  69838. * @see https://easings.net/#easeInElastic
  69839. * @param oscillations Defines the number of oscillations
  69840. * @param springiness Defines the amplitude of the oscillations
  69841. */
  69842. constructor(
  69843. /** Defines the number of oscillations*/
  69844. oscillations?: number,
  69845. /** Defines the amplitude of the oscillations*/
  69846. springiness?: number);
  69847. /** @hidden */
  69848. easeInCore(gradient: number): number;
  69849. }
  69850. /**
  69851. * Easing function with an exponential shape (see link below).
  69852. * @see https://easings.net/#easeInExpo
  69853. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69854. */
  69855. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69856. /** Defines the exponent of the function */
  69857. exponent: number;
  69858. /**
  69859. * Instantiates an exponential easing function
  69860. * @see https://easings.net/#easeInExpo
  69861. * @param exponent Defines the exponent of the function
  69862. */
  69863. constructor(
  69864. /** Defines the exponent of the function */
  69865. exponent?: number);
  69866. /** @hidden */
  69867. easeInCore(gradient: number): number;
  69868. }
  69869. /**
  69870. * Easing function with a power shape (see link below).
  69871. * @see https://easings.net/#easeInQuad
  69872. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69873. */
  69874. export class PowerEase extends EasingFunction implements IEasingFunction {
  69875. /** Defines the power of the function */
  69876. power: number;
  69877. /**
  69878. * Instantiates an power base easing function
  69879. * @see https://easings.net/#easeInQuad
  69880. * @param power Defines the power of the function
  69881. */
  69882. constructor(
  69883. /** Defines the power of the function */
  69884. power?: number);
  69885. /** @hidden */
  69886. easeInCore(gradient: number): number;
  69887. }
  69888. /**
  69889. * Easing function with a power of 2 shape (see link below).
  69890. * @see https://easings.net/#easeInQuad
  69891. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69892. */
  69893. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69894. /** @hidden */
  69895. easeInCore(gradient: number): number;
  69896. }
  69897. /**
  69898. * Easing function with a power of 4 shape (see link below).
  69899. * @see https://easings.net/#easeInQuart
  69900. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69901. */
  69902. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69903. /** @hidden */
  69904. easeInCore(gradient: number): number;
  69905. }
  69906. /**
  69907. * Easing function with a power of 5 shape (see link below).
  69908. * @see https://easings.net/#easeInQuint
  69909. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69910. */
  69911. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69912. /** @hidden */
  69913. easeInCore(gradient: number): number;
  69914. }
  69915. /**
  69916. * Easing function with a sin shape (see link below).
  69917. * @see https://easings.net/#easeInSine
  69918. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69919. */
  69920. export class SineEase extends EasingFunction implements IEasingFunction {
  69921. /** @hidden */
  69922. easeInCore(gradient: number): number;
  69923. }
  69924. /**
  69925. * Easing function with a bezier shape (see link below).
  69926. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69927. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69928. */
  69929. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69930. /** Defines the x component of the start tangent in the bezier curve */
  69931. x1: number;
  69932. /** Defines the y component of the start tangent in the bezier curve */
  69933. y1: number;
  69934. /** Defines the x component of the end tangent in the bezier curve */
  69935. x2: number;
  69936. /** Defines the y component of the end tangent in the bezier curve */
  69937. y2: number;
  69938. /**
  69939. * Instantiates a bezier function
  69940. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69941. * @param x1 Defines the x component of the start tangent in the bezier curve
  69942. * @param y1 Defines the y component of the start tangent in the bezier curve
  69943. * @param x2 Defines the x component of the end tangent in the bezier curve
  69944. * @param y2 Defines the y component of the end tangent in the bezier curve
  69945. */
  69946. constructor(
  69947. /** Defines the x component of the start tangent in the bezier curve */
  69948. x1?: number,
  69949. /** Defines the y component of the start tangent in the bezier curve */
  69950. y1?: number,
  69951. /** Defines the x component of the end tangent in the bezier curve */
  69952. x2?: number,
  69953. /** Defines the y component of the end tangent in the bezier curve */
  69954. y2?: number);
  69955. /** @hidden */
  69956. easeInCore(gradient: number): number;
  69957. }
  69958. }
  69959. declare module BABYLON {
  69960. /**
  69961. * Defines an interface which represents an animation key frame
  69962. */
  69963. export interface IAnimationKey {
  69964. /**
  69965. * Frame of the key frame
  69966. */
  69967. frame: number;
  69968. /**
  69969. * Value at the specifies key frame
  69970. */
  69971. value: any;
  69972. /**
  69973. * The input tangent for the cubic hermite spline
  69974. */
  69975. inTangent?: any;
  69976. /**
  69977. * The output tangent for the cubic hermite spline
  69978. */
  69979. outTangent?: any;
  69980. /**
  69981. * The animation interpolation type
  69982. */
  69983. interpolation?: AnimationKeyInterpolation;
  69984. }
  69985. /**
  69986. * Enum for the animation key frame interpolation type
  69987. */
  69988. export enum AnimationKeyInterpolation {
  69989. /**
  69990. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69991. */
  69992. STEP = 1
  69993. }
  69994. }
  69995. declare module BABYLON {
  69996. /**
  69997. * Represents the range of an animation
  69998. */
  69999. export class AnimationRange {
  70000. /**The name of the animation range**/
  70001. name: string;
  70002. /**The starting frame of the animation */
  70003. from: number;
  70004. /**The ending frame of the animation*/
  70005. to: number;
  70006. /**
  70007. * Initializes the range of an animation
  70008. * @param name The name of the animation range
  70009. * @param from The starting frame of the animation
  70010. * @param to The ending frame of the animation
  70011. */
  70012. constructor(
  70013. /**The name of the animation range**/
  70014. name: string,
  70015. /**The starting frame of the animation */
  70016. from: number,
  70017. /**The ending frame of the animation*/
  70018. to: number);
  70019. /**
  70020. * Makes a copy of the animation range
  70021. * @returns A copy of the animation range
  70022. */
  70023. clone(): AnimationRange;
  70024. }
  70025. }
  70026. declare module BABYLON {
  70027. /**
  70028. * Composed of a frame, and an action function
  70029. */
  70030. export class AnimationEvent {
  70031. /** The frame for which the event is triggered **/
  70032. frame: number;
  70033. /** The event to perform when triggered **/
  70034. action: (currentFrame: number) => void;
  70035. /** Specifies if the event should be triggered only once**/
  70036. onlyOnce?: boolean | undefined;
  70037. /**
  70038. * Specifies if the animation event is done
  70039. */
  70040. isDone: boolean;
  70041. /**
  70042. * Initializes the animation event
  70043. * @param frame The frame for which the event is triggered
  70044. * @param action The event to perform when triggered
  70045. * @param onlyOnce Specifies if the event should be triggered only once
  70046. */
  70047. constructor(
  70048. /** The frame for which the event is triggered **/
  70049. frame: number,
  70050. /** The event to perform when triggered **/
  70051. action: (currentFrame: number) => void,
  70052. /** Specifies if the event should be triggered only once**/
  70053. onlyOnce?: boolean | undefined);
  70054. /** @hidden */
  70055. _clone(): AnimationEvent;
  70056. }
  70057. }
  70058. declare module BABYLON {
  70059. /**
  70060. * Interface used to define a behavior
  70061. */
  70062. export interface Behavior<T> {
  70063. /** gets or sets behavior's name */
  70064. name: string;
  70065. /**
  70066. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70067. */
  70068. init(): void;
  70069. /**
  70070. * Called when the behavior is attached to a target
  70071. * @param target defines the target where the behavior is attached to
  70072. */
  70073. attach(target: T): void;
  70074. /**
  70075. * Called when the behavior is detached from its target
  70076. */
  70077. detach(): void;
  70078. }
  70079. /**
  70080. * Interface implemented by classes supporting behaviors
  70081. */
  70082. export interface IBehaviorAware<T> {
  70083. /**
  70084. * Attach a behavior
  70085. * @param behavior defines the behavior to attach
  70086. * @returns the current host
  70087. */
  70088. addBehavior(behavior: Behavior<T>): T;
  70089. /**
  70090. * Remove a behavior from the current object
  70091. * @param behavior defines the behavior to detach
  70092. * @returns the current host
  70093. */
  70094. removeBehavior(behavior: Behavior<T>): T;
  70095. /**
  70096. * Gets a behavior using its name to search
  70097. * @param name defines the name to search
  70098. * @returns the behavior or null if not found
  70099. */
  70100. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70101. }
  70102. }
  70103. declare module BABYLON {
  70104. /**
  70105. * Defines an array and its length.
  70106. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70107. */
  70108. export interface ISmartArrayLike<T> {
  70109. /**
  70110. * The data of the array.
  70111. */
  70112. data: Array<T>;
  70113. /**
  70114. * The active length of the array.
  70115. */
  70116. length: number;
  70117. }
  70118. /**
  70119. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70120. */
  70121. export class SmartArray<T> implements ISmartArrayLike<T> {
  70122. /**
  70123. * The full set of data from the array.
  70124. */
  70125. data: Array<T>;
  70126. /**
  70127. * The active length of the array.
  70128. */
  70129. length: number;
  70130. protected _id: number;
  70131. /**
  70132. * Instantiates a Smart Array.
  70133. * @param capacity defines the default capacity of the array.
  70134. */
  70135. constructor(capacity: number);
  70136. /**
  70137. * Pushes a value at the end of the active data.
  70138. * @param value defines the object to push in the array.
  70139. */
  70140. push(value: T): void;
  70141. /**
  70142. * Iterates over the active data and apply the lambda to them.
  70143. * @param func defines the action to apply on each value.
  70144. */
  70145. forEach(func: (content: T) => void): void;
  70146. /**
  70147. * Sorts the full sets of data.
  70148. * @param compareFn defines the comparison function to apply.
  70149. */
  70150. sort(compareFn: (a: T, b: T) => number): void;
  70151. /**
  70152. * Resets the active data to an empty array.
  70153. */
  70154. reset(): void;
  70155. /**
  70156. * Releases all the data from the array as well as the array.
  70157. */
  70158. dispose(): void;
  70159. /**
  70160. * Concats the active data with a given array.
  70161. * @param array defines the data to concatenate with.
  70162. */
  70163. concat(array: any): void;
  70164. /**
  70165. * Returns the position of a value in the active data.
  70166. * @param value defines the value to find the index for
  70167. * @returns the index if found in the active data otherwise -1
  70168. */
  70169. indexOf(value: T): number;
  70170. /**
  70171. * Returns whether an element is part of the active data.
  70172. * @param value defines the value to look for
  70173. * @returns true if found in the active data otherwise false
  70174. */
  70175. contains(value: T): boolean;
  70176. private static _GlobalId;
  70177. }
  70178. /**
  70179. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70180. * The data in this array can only be present once
  70181. */
  70182. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70183. private _duplicateId;
  70184. /**
  70185. * Pushes a value at the end of the active data.
  70186. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70187. * @param value defines the object to push in the array.
  70188. */
  70189. push(value: T): void;
  70190. /**
  70191. * Pushes a value at the end of the active data.
  70192. * If the data is already present, it won t be added again
  70193. * @param value defines the object to push in the array.
  70194. * @returns true if added false if it was already present
  70195. */
  70196. pushNoDuplicate(value: T): boolean;
  70197. /**
  70198. * Resets the active data to an empty array.
  70199. */
  70200. reset(): void;
  70201. /**
  70202. * Concats the active data with a given array.
  70203. * This ensures no dupplicate will be present in the result.
  70204. * @param array defines the data to concatenate with.
  70205. */
  70206. concatWithNoDuplicate(array: any): void;
  70207. }
  70208. }
  70209. declare module BABYLON {
  70210. /**
  70211. * @ignore
  70212. * This is a list of all the different input types that are available in the application.
  70213. * Fo instance: ArcRotateCameraGamepadInput...
  70214. */
  70215. export var CameraInputTypes: {};
  70216. /**
  70217. * This is the contract to implement in order to create a new input class.
  70218. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70219. */
  70220. export interface ICameraInput<TCamera extends Camera> {
  70221. /**
  70222. * Defines the camera the input is attached to.
  70223. */
  70224. camera: Nullable<TCamera>;
  70225. /**
  70226. * Gets the class name of the current intput.
  70227. * @returns the class name
  70228. */
  70229. getClassName(): string;
  70230. /**
  70231. * Get the friendly name associated with the input class.
  70232. * @returns the input friendly name
  70233. */
  70234. getSimpleName(): string;
  70235. /**
  70236. * Attach the input controls to a specific dom element to get the input from.
  70237. * @param element Defines the element the controls should be listened from
  70238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70239. */
  70240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70241. /**
  70242. * Detach the current controls from the specified dom element.
  70243. * @param element Defines the element to stop listening the inputs from
  70244. */
  70245. detachControl(element: Nullable<HTMLElement>): void;
  70246. /**
  70247. * Update the current camera state depending on the inputs that have been used this frame.
  70248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70249. */
  70250. checkInputs?: () => void;
  70251. }
  70252. /**
  70253. * Represents a map of input types to input instance or input index to input instance.
  70254. */
  70255. export interface CameraInputsMap<TCamera extends Camera> {
  70256. /**
  70257. * Accessor to the input by input type.
  70258. */
  70259. [name: string]: ICameraInput<TCamera>;
  70260. /**
  70261. * Accessor to the input by input index.
  70262. */
  70263. [idx: number]: ICameraInput<TCamera>;
  70264. }
  70265. /**
  70266. * This represents the input manager used within a camera.
  70267. * It helps dealing with all the different kind of input attached to a camera.
  70268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70269. */
  70270. export class CameraInputsManager<TCamera extends Camera> {
  70271. /**
  70272. * Defines the list of inputs attahed to the camera.
  70273. */
  70274. attached: CameraInputsMap<TCamera>;
  70275. /**
  70276. * Defines the dom element the camera is collecting inputs from.
  70277. * This is null if the controls have not been attached.
  70278. */
  70279. attachedElement: Nullable<HTMLElement>;
  70280. /**
  70281. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70282. */
  70283. noPreventDefault: boolean;
  70284. /**
  70285. * Defined the camera the input manager belongs to.
  70286. */
  70287. camera: TCamera;
  70288. /**
  70289. * Update the current camera state depending on the inputs that have been used this frame.
  70290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70291. */
  70292. checkInputs: () => void;
  70293. /**
  70294. * Instantiate a new Camera Input Manager.
  70295. * @param camera Defines the camera the input manager blongs to
  70296. */
  70297. constructor(camera: TCamera);
  70298. /**
  70299. * Add an input method to a camera
  70300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70301. * @param input camera input method
  70302. */
  70303. add(input: ICameraInput<TCamera>): void;
  70304. /**
  70305. * Remove a specific input method from a camera
  70306. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70307. * @param inputToRemove camera input method
  70308. */
  70309. remove(inputToRemove: ICameraInput<TCamera>): void;
  70310. /**
  70311. * Remove a specific input type from a camera
  70312. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70313. * @param inputType the type of the input to remove
  70314. */
  70315. removeByType(inputType: string): void;
  70316. private _addCheckInputs;
  70317. /**
  70318. * Attach the input controls to the currently attached dom element to listen the events from.
  70319. * @param input Defines the input to attach
  70320. */
  70321. attachInput(input: ICameraInput<TCamera>): void;
  70322. /**
  70323. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70324. * @param element Defines the dom element to collect the events from
  70325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70326. */
  70327. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70328. /**
  70329. * Detach the current manager inputs controls from a specific dom element.
  70330. * @param element Defines the dom element to collect the events from
  70331. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70332. */
  70333. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70334. /**
  70335. * Rebuild the dynamic inputCheck function from the current list of
  70336. * defined inputs in the manager.
  70337. */
  70338. rebuildInputCheck(): void;
  70339. /**
  70340. * Remove all attached input methods from a camera
  70341. */
  70342. clear(): void;
  70343. /**
  70344. * Serialize the current input manager attached to a camera.
  70345. * This ensures than once parsed,
  70346. * the input associated to the camera will be identical to the current ones
  70347. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70348. */
  70349. serialize(serializedCamera: any): void;
  70350. /**
  70351. * Parses an input manager serialized JSON to restore the previous list of inputs
  70352. * and states associated to a camera.
  70353. * @param parsedCamera Defines the JSON to parse
  70354. */
  70355. parse(parsedCamera: any): void;
  70356. }
  70357. }
  70358. declare module BABYLON {
  70359. /**
  70360. * @hidden
  70361. */
  70362. export class IntersectionInfo {
  70363. bu: Nullable<number>;
  70364. bv: Nullable<number>;
  70365. distance: number;
  70366. faceId: number;
  70367. subMeshId: number;
  70368. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70369. }
  70370. }
  70371. declare module BABYLON {
  70372. /**
  70373. * Represens a plane by the equation ax + by + cz + d = 0
  70374. */
  70375. export class Plane {
  70376. private static _TmpMatrix;
  70377. /**
  70378. * Normal of the plane (a,b,c)
  70379. */
  70380. normal: Vector3;
  70381. /**
  70382. * d component of the plane
  70383. */
  70384. d: number;
  70385. /**
  70386. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  70387. * @param a a component of the plane
  70388. * @param b b component of the plane
  70389. * @param c c component of the plane
  70390. * @param d d component of the plane
  70391. */
  70392. constructor(a: number, b: number, c: number, d: number);
  70393. /**
  70394. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  70395. */
  70396. asArray(): number[];
  70397. /**
  70398. * @returns a new plane copied from the current Plane.
  70399. */
  70400. clone(): Plane;
  70401. /**
  70402. * @returns the string "Plane".
  70403. */
  70404. getClassName(): string;
  70405. /**
  70406. * @returns the Plane hash code.
  70407. */
  70408. getHashCode(): number;
  70409. /**
  70410. * Normalize the current Plane in place.
  70411. * @returns the updated Plane.
  70412. */
  70413. normalize(): Plane;
  70414. /**
  70415. * Applies a transformation the plane and returns the result
  70416. * @param transformation the transformation matrix to be applied to the plane
  70417. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  70418. */
  70419. transform(transformation: DeepImmutable<Matrix>): Plane;
  70420. /**
  70421. * Calcualtte the dot product between the point and the plane normal
  70422. * @param point point to calculate the dot product with
  70423. * @returns the dot product (float) of the point coordinates and the plane normal.
  70424. */
  70425. dotCoordinate(point: DeepImmutable<Vector3>): number;
  70426. /**
  70427. * Updates the current Plane from the plane defined by the three given points.
  70428. * @param point1 one of the points used to contruct the plane
  70429. * @param point2 one of the points used to contruct the plane
  70430. * @param point3 one of the points used to contruct the plane
  70431. * @returns the updated Plane.
  70432. */
  70433. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70434. /**
  70435. * Checks if the plane is facing a given direction
  70436. * @param direction the direction to check if the plane is facing
  70437. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  70438. * @returns True is the vector "direction" is the same side than the plane normal.
  70439. */
  70440. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  70441. /**
  70442. * Calculates the distance to a point
  70443. * @param point point to calculate distance to
  70444. * @returns the signed distance (float) from the given point to the Plane.
  70445. */
  70446. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  70447. /**
  70448. * Creates a plane from an array
  70449. * @param array the array to create a plane from
  70450. * @returns a new Plane from the given array.
  70451. */
  70452. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  70453. /**
  70454. * Creates a plane from three points
  70455. * @param point1 point used to create the plane
  70456. * @param point2 point used to create the plane
  70457. * @param point3 point used to create the plane
  70458. * @returns a new Plane defined by the three given points.
  70459. */
  70460. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70461. /**
  70462. * Creates a plane from an origin point and a normal
  70463. * @param origin origin of the plane to be constructed
  70464. * @param normal normal of the plane to be constructed
  70465. * @returns a new Plane the normal vector to this plane at the given origin point.
  70466. * Note : the vector "normal" is updated because normalized.
  70467. */
  70468. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  70469. /**
  70470. * Calculates the distance from a plane and a point
  70471. * @param origin origin of the plane to be constructed
  70472. * @param normal normal of the plane to be constructed
  70473. * @param point point to calculate distance to
  70474. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  70475. */
  70476. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  70477. }
  70478. }
  70479. declare module BABYLON {
  70480. /**
  70481. * Class used to store bounding sphere information
  70482. */
  70483. export class BoundingSphere {
  70484. /**
  70485. * Gets the center of the bounding sphere in local space
  70486. */
  70487. readonly center: Vector3;
  70488. /**
  70489. * Radius of the bounding sphere in local space
  70490. */
  70491. radius: number;
  70492. /**
  70493. * Gets the center of the bounding sphere in world space
  70494. */
  70495. readonly centerWorld: Vector3;
  70496. /**
  70497. * Radius of the bounding sphere in world space
  70498. */
  70499. radiusWorld: number;
  70500. /**
  70501. * Gets the minimum vector in local space
  70502. */
  70503. readonly minimum: Vector3;
  70504. /**
  70505. * Gets the maximum vector in local space
  70506. */
  70507. readonly maximum: Vector3;
  70508. private _worldMatrix;
  70509. private static readonly TmpVector3;
  70510. /**
  70511. * Creates a new bounding sphere
  70512. * @param min defines the minimum vector (in local space)
  70513. * @param max defines the maximum vector (in local space)
  70514. * @param worldMatrix defines the new world matrix
  70515. */
  70516. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70517. /**
  70518. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70519. * @param min defines the new minimum vector (in local space)
  70520. * @param max defines the new maximum vector (in local space)
  70521. * @param worldMatrix defines the new world matrix
  70522. */
  70523. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70524. /**
  70525. * Scale the current bounding sphere by applying a scale factor
  70526. * @param factor defines the scale factor to apply
  70527. * @returns the current bounding box
  70528. */
  70529. scale(factor: number): BoundingSphere;
  70530. /**
  70531. * Gets the world matrix of the bounding box
  70532. * @returns a matrix
  70533. */
  70534. getWorldMatrix(): DeepImmutable<Matrix>;
  70535. /** @hidden */
  70536. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70537. /**
  70538. * Tests if the bounding sphere is intersecting the frustum planes
  70539. * @param frustumPlanes defines the frustum planes to test
  70540. * @returns true if there is an intersection
  70541. */
  70542. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70543. /**
  70544. * Tests if the bounding sphere center is in between the frustum planes.
  70545. * Used for optimistic fast inclusion.
  70546. * @param frustumPlanes defines the frustum planes to test
  70547. * @returns true if the sphere center is in between the frustum planes
  70548. */
  70549. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70550. /**
  70551. * Tests if a point is inside the bounding sphere
  70552. * @param point defines the point to test
  70553. * @returns true if the point is inside the bounding sphere
  70554. */
  70555. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70556. /**
  70557. * Checks if two sphere intersct
  70558. * @param sphere0 sphere 0
  70559. * @param sphere1 sphere 1
  70560. * @returns true if the speres intersect
  70561. */
  70562. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70563. }
  70564. }
  70565. declare module BABYLON {
  70566. /**
  70567. * Class used to store bounding box information
  70568. */
  70569. export class BoundingBox implements ICullable {
  70570. /**
  70571. * Gets the 8 vectors representing the bounding box in local space
  70572. */
  70573. readonly vectors: Vector3[];
  70574. /**
  70575. * Gets the center of the bounding box in local space
  70576. */
  70577. readonly center: Vector3;
  70578. /**
  70579. * Gets the center of the bounding box in world space
  70580. */
  70581. readonly centerWorld: Vector3;
  70582. /**
  70583. * Gets the extend size in local space
  70584. */
  70585. readonly extendSize: Vector3;
  70586. /**
  70587. * Gets the extend size in world space
  70588. */
  70589. readonly extendSizeWorld: Vector3;
  70590. /**
  70591. * Gets the OBB (object bounding box) directions
  70592. */
  70593. readonly directions: Vector3[];
  70594. /**
  70595. * Gets the 8 vectors representing the bounding box in world space
  70596. */
  70597. readonly vectorsWorld: Vector3[];
  70598. /**
  70599. * Gets the minimum vector in world space
  70600. */
  70601. readonly minimumWorld: Vector3;
  70602. /**
  70603. * Gets the maximum vector in world space
  70604. */
  70605. readonly maximumWorld: Vector3;
  70606. /**
  70607. * Gets the minimum vector in local space
  70608. */
  70609. readonly minimum: Vector3;
  70610. /**
  70611. * Gets the maximum vector in local space
  70612. */
  70613. readonly maximum: Vector3;
  70614. private _worldMatrix;
  70615. private static readonly TmpVector3;
  70616. /**
  70617. * @hidden
  70618. */
  70619. _tag: number;
  70620. /**
  70621. * Creates a new bounding box
  70622. * @param min defines the minimum vector (in local space)
  70623. * @param max defines the maximum vector (in local space)
  70624. * @param worldMatrix defines the new world matrix
  70625. */
  70626. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70627. /**
  70628. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70629. * @param min defines the new minimum vector (in local space)
  70630. * @param max defines the new maximum vector (in local space)
  70631. * @param worldMatrix defines the new world matrix
  70632. */
  70633. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70634. /**
  70635. * Scale the current bounding box by applying a scale factor
  70636. * @param factor defines the scale factor to apply
  70637. * @returns the current bounding box
  70638. */
  70639. scale(factor: number): BoundingBox;
  70640. /**
  70641. * Gets the world matrix of the bounding box
  70642. * @returns a matrix
  70643. */
  70644. getWorldMatrix(): DeepImmutable<Matrix>;
  70645. /** @hidden */
  70646. _update(world: DeepImmutable<Matrix>): void;
  70647. /**
  70648. * Tests if the bounding box is intersecting the frustum planes
  70649. * @param frustumPlanes defines the frustum planes to test
  70650. * @returns true if there is an intersection
  70651. */
  70652. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70653. /**
  70654. * Tests if the bounding box is entirely inside the frustum planes
  70655. * @param frustumPlanes defines the frustum planes to test
  70656. * @returns true if there is an inclusion
  70657. */
  70658. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70659. /**
  70660. * Tests if a point is inside the bounding box
  70661. * @param point defines the point to test
  70662. * @returns true if the point is inside the bounding box
  70663. */
  70664. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70665. /**
  70666. * Tests if the bounding box intersects with a bounding sphere
  70667. * @param sphere defines the sphere to test
  70668. * @returns true if there is an intersection
  70669. */
  70670. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70671. /**
  70672. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70673. * @param min defines the min vector to use
  70674. * @param max defines the max vector to use
  70675. * @returns true if there is an intersection
  70676. */
  70677. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70678. /**
  70679. * Tests if two bounding boxes are intersections
  70680. * @param box0 defines the first box to test
  70681. * @param box1 defines the second box to test
  70682. * @returns true if there is an intersection
  70683. */
  70684. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70685. /**
  70686. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70687. * @param minPoint defines the minimum vector of the bounding box
  70688. * @param maxPoint defines the maximum vector of the bounding box
  70689. * @param sphereCenter defines the sphere center
  70690. * @param sphereRadius defines the sphere radius
  70691. * @returns true if there is an intersection
  70692. */
  70693. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70694. /**
  70695. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70696. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70697. * @param frustumPlanes defines the frustum planes to test
  70698. * @return true if there is an inclusion
  70699. */
  70700. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70701. /**
  70702. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70703. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70704. * @param frustumPlanes defines the frustum planes to test
  70705. * @return true if there is an intersection
  70706. */
  70707. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70708. }
  70709. }
  70710. declare module BABYLON {
  70711. /** @hidden */
  70712. export class Collider {
  70713. /** Define if a collision was found */
  70714. collisionFound: boolean;
  70715. /**
  70716. * Define last intersection point in local space
  70717. */
  70718. intersectionPoint: Vector3;
  70719. /**
  70720. * Define last collided mesh
  70721. */
  70722. collidedMesh: Nullable<AbstractMesh>;
  70723. private _collisionPoint;
  70724. private _planeIntersectionPoint;
  70725. private _tempVector;
  70726. private _tempVector2;
  70727. private _tempVector3;
  70728. private _tempVector4;
  70729. private _edge;
  70730. private _baseToVertex;
  70731. private _destinationPoint;
  70732. private _slidePlaneNormal;
  70733. private _displacementVector;
  70734. /** @hidden */
  70735. _radius: Vector3;
  70736. /** @hidden */
  70737. _retry: number;
  70738. private _velocity;
  70739. private _basePoint;
  70740. private _epsilon;
  70741. /** @hidden */
  70742. _velocityWorldLength: number;
  70743. /** @hidden */
  70744. _basePointWorld: Vector3;
  70745. private _velocityWorld;
  70746. private _normalizedVelocity;
  70747. /** @hidden */
  70748. _initialVelocity: Vector3;
  70749. /** @hidden */
  70750. _initialPosition: Vector3;
  70751. private _nearestDistance;
  70752. private _collisionMask;
  70753. collisionMask: number;
  70754. /**
  70755. * Gets the plane normal used to compute the sliding response (in local space)
  70756. */
  70757. readonly slidePlaneNormal: Vector3;
  70758. /** @hidden */
  70759. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70760. /** @hidden */
  70761. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70762. /** @hidden */
  70763. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70764. /** @hidden */
  70765. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70766. /** @hidden */
  70767. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70768. /** @hidden */
  70769. _getResponse(pos: Vector3, vel: Vector3): void;
  70770. }
  70771. }
  70772. declare module BABYLON {
  70773. /**
  70774. * Interface for cullable objects
  70775. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70776. */
  70777. export interface ICullable {
  70778. /**
  70779. * Checks if the object or part of the object is in the frustum
  70780. * @param frustumPlanes Camera near/planes
  70781. * @returns true if the object is in frustum otherwise false
  70782. */
  70783. isInFrustum(frustumPlanes: Plane[]): boolean;
  70784. /**
  70785. * Checks if a cullable object (mesh...) is in the camera frustum
  70786. * Unlike isInFrustum this cheks the full bounding box
  70787. * @param frustumPlanes Camera near/planes
  70788. * @returns true if the object is in frustum otherwise false
  70789. */
  70790. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70791. }
  70792. /**
  70793. * Info for a bounding data of a mesh
  70794. */
  70795. export class BoundingInfo implements ICullable {
  70796. /**
  70797. * Bounding box for the mesh
  70798. */
  70799. readonly boundingBox: BoundingBox;
  70800. /**
  70801. * Bounding sphere for the mesh
  70802. */
  70803. readonly boundingSphere: BoundingSphere;
  70804. private _isLocked;
  70805. private static readonly TmpVector3;
  70806. /**
  70807. * Constructs bounding info
  70808. * @param minimum min vector of the bounding box/sphere
  70809. * @param maximum max vector of the bounding box/sphere
  70810. * @param worldMatrix defines the new world matrix
  70811. */
  70812. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70813. /**
  70814. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70815. * @param min defines the new minimum vector (in local space)
  70816. * @param max defines the new maximum vector (in local space)
  70817. * @param worldMatrix defines the new world matrix
  70818. */
  70819. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70820. /**
  70821. * min vector of the bounding box/sphere
  70822. */
  70823. readonly minimum: Vector3;
  70824. /**
  70825. * max vector of the bounding box/sphere
  70826. */
  70827. readonly maximum: Vector3;
  70828. /**
  70829. * If the info is locked and won't be updated to avoid perf overhead
  70830. */
  70831. isLocked: boolean;
  70832. /**
  70833. * Updates the bounding sphere and box
  70834. * @param world world matrix to be used to update
  70835. */
  70836. update(world: DeepImmutable<Matrix>): void;
  70837. /**
  70838. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70839. * @param center New center of the bounding info
  70840. * @param extend New extend of the bounding info
  70841. * @returns the current bounding info
  70842. */
  70843. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70844. /**
  70845. * Scale the current bounding info by applying a scale factor
  70846. * @param factor defines the scale factor to apply
  70847. * @returns the current bounding info
  70848. */
  70849. scale(factor: number): BoundingInfo;
  70850. /**
  70851. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70852. * @param frustumPlanes defines the frustum to test
  70853. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70854. * @returns true if the bounding info is in the frustum planes
  70855. */
  70856. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70857. /**
  70858. * Gets the world distance between the min and max points of the bounding box
  70859. */
  70860. readonly diagonalLength: number;
  70861. /**
  70862. * Checks if a cullable object (mesh...) is in the camera frustum
  70863. * Unlike isInFrustum this cheks the full bounding box
  70864. * @param frustumPlanes Camera near/planes
  70865. * @returns true if the object is in frustum otherwise false
  70866. */
  70867. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70868. /** @hidden */
  70869. _checkCollision(collider: Collider): boolean;
  70870. /**
  70871. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70872. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70873. * @param point the point to check intersection with
  70874. * @returns if the point intersects
  70875. */
  70876. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70877. /**
  70878. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70879. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70880. * @param boundingInfo the bounding info to check intersection with
  70881. * @param precise if the intersection should be done using OBB
  70882. * @returns if the bounding info intersects
  70883. */
  70884. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70885. }
  70886. }
  70887. declare module BABYLON {
  70888. /**
  70889. * Extracts minimum and maximum values from a list of indexed positions
  70890. * @param positions defines the positions to use
  70891. * @param indices defines the indices to the positions
  70892. * @param indexStart defines the start index
  70893. * @param indexCount defines the end index
  70894. * @param bias defines bias value to add to the result
  70895. * @return minimum and maximum values
  70896. */
  70897. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  70898. minimum: Vector3;
  70899. maximum: Vector3;
  70900. };
  70901. /**
  70902. * Extracts minimum and maximum values from a list of positions
  70903. * @param positions defines the positions to use
  70904. * @param start defines the start index in the positions array
  70905. * @param count defines the number of positions to handle
  70906. * @param bias defines bias value to add to the result
  70907. * @param stride defines the stride size to use (distance between two positions in the positions array)
  70908. * @return minimum and maximum values
  70909. */
  70910. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  70911. minimum: Vector3;
  70912. maximum: Vector3;
  70913. };
  70914. }
  70915. declare module BABYLON {
  70916. /**
  70917. * Enum that determines the text-wrapping mode to use.
  70918. */
  70919. export enum InspectableType {
  70920. /**
  70921. * Checkbox for booleans
  70922. */
  70923. Checkbox = 0,
  70924. /**
  70925. * Sliders for numbers
  70926. */
  70927. Slider = 1,
  70928. /**
  70929. * Vector3
  70930. */
  70931. Vector3 = 2,
  70932. /**
  70933. * Quaternions
  70934. */
  70935. Quaternion = 3,
  70936. /**
  70937. * Color3
  70938. */
  70939. Color3 = 4,
  70940. /**
  70941. * String
  70942. */
  70943. String = 5
  70944. }
  70945. /**
  70946. * Interface used to define custom inspectable properties.
  70947. * This interface is used by the inspector to display custom property grids
  70948. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70949. */
  70950. export interface IInspectable {
  70951. /**
  70952. * Gets the label to display
  70953. */
  70954. label: string;
  70955. /**
  70956. * Gets the name of the property to edit
  70957. */
  70958. propertyName: string;
  70959. /**
  70960. * Gets the type of the editor to use
  70961. */
  70962. type: InspectableType;
  70963. /**
  70964. * Gets the minimum value of the property when using in "slider" mode
  70965. */
  70966. min?: number;
  70967. /**
  70968. * Gets the maximum value of the property when using in "slider" mode
  70969. */
  70970. max?: number;
  70971. /**
  70972. * Gets the setp to use when using in "slider" mode
  70973. */
  70974. step?: number;
  70975. }
  70976. }
  70977. declare module BABYLON {
  70978. /**
  70979. * Class used to provide helper for timing
  70980. */
  70981. export class TimingTools {
  70982. /**
  70983. * Polyfill for setImmediate
  70984. * @param action defines the action to execute after the current execution block
  70985. */
  70986. static SetImmediate(action: () => void): void;
  70987. }
  70988. }
  70989. declare module BABYLON {
  70990. /**
  70991. * Class used to enable instatition of objects by class name
  70992. */
  70993. export class InstantiationTools {
  70994. /**
  70995. * Use this object to register external classes like custom textures or material
  70996. * to allow the laoders to instantiate them
  70997. */
  70998. static RegisteredExternalClasses: {
  70999. [key: string]: Object;
  71000. };
  71001. /**
  71002. * Tries to instantiate a new object from a given class name
  71003. * @param className defines the class name to instantiate
  71004. * @returns the new object or null if the system was not able to do the instantiation
  71005. */
  71006. static Instantiate(className: string): any;
  71007. }
  71008. }
  71009. declare module BABYLON {
  71010. /**
  71011. * This represents the required contract to create a new type of texture loader.
  71012. */
  71013. export interface IInternalTextureLoader {
  71014. /**
  71015. * Defines wether the loader supports cascade loading the different faces.
  71016. */
  71017. supportCascades: boolean;
  71018. /**
  71019. * This returns if the loader support the current file information.
  71020. * @param extension defines the file extension of the file being loaded
  71021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71022. * @param fallback defines the fallback internal texture if any
  71023. * @param isBase64 defines whether the texture is encoded as a base64
  71024. * @param isBuffer defines whether the texture data are stored as a buffer
  71025. * @returns true if the loader can load the specified file
  71026. */
  71027. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71028. /**
  71029. * Transform the url before loading if required.
  71030. * @param rootUrl the url of the texture
  71031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71032. * @returns the transformed texture
  71033. */
  71034. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71035. /**
  71036. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71037. * @param rootUrl the url of the texture
  71038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71039. * @returns the fallback texture
  71040. */
  71041. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71042. /**
  71043. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71044. * @param data contains the texture data
  71045. * @param texture defines the BabylonJS internal texture
  71046. * @param createPolynomials will be true if polynomials have been requested
  71047. * @param onLoad defines the callback to trigger once the texture is ready
  71048. * @param onError defines the callback to trigger in case of error
  71049. */
  71050. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71051. /**
  71052. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71053. * @param data contains the texture data
  71054. * @param texture defines the BabylonJS internal texture
  71055. * @param callback defines the method to call once ready to upload
  71056. */
  71057. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71058. }
  71059. }
  71060. declare module BABYLON {
  71061. interface Engine {
  71062. /**
  71063. * Creates a depth stencil cube texture.
  71064. * This is only available in WebGL 2.
  71065. * @param size The size of face edge in the cube texture.
  71066. * @param options The options defining the cube texture.
  71067. * @returns The cube texture
  71068. */
  71069. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71070. /**
  71071. * Creates a cube texture
  71072. * @param rootUrl defines the url where the files to load is located
  71073. * @param scene defines the current scene
  71074. * @param files defines the list of files to load (1 per face)
  71075. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71076. * @param onLoad defines an optional callback raised when the texture is loaded
  71077. * @param onError defines an optional callback raised if there is an issue to load the texture
  71078. * @param format defines the format of the data
  71079. * @param forcedExtension defines the extension to use to pick the right loader
  71080. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71081. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71082. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71083. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71084. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71085. * @returns the cube texture as an InternalTexture
  71086. */
  71087. 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;
  71088. /**
  71089. * Creates a cube texture
  71090. * @param rootUrl defines the url where the files to load is located
  71091. * @param scene defines the current scene
  71092. * @param files defines the list of files to load (1 per face)
  71093. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71094. * @param onLoad defines an optional callback raised when the texture is loaded
  71095. * @param onError defines an optional callback raised if there is an issue to load the texture
  71096. * @param format defines the format of the data
  71097. * @param forcedExtension defines the extension to use to pick the right loader
  71098. * @returns the cube texture as an InternalTexture
  71099. */
  71100. 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;
  71101. /**
  71102. * Creates a cube texture
  71103. * @param rootUrl defines the url where the files to load is located
  71104. * @param scene defines the current scene
  71105. * @param files defines the list of files to load (1 per face)
  71106. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71107. * @param onLoad defines an optional callback raised when the texture is loaded
  71108. * @param onError defines an optional callback raised if there is an issue to load the texture
  71109. * @param format defines the format of the data
  71110. * @param forcedExtension defines the extension to use to pick the right loader
  71111. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71112. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71113. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71114. * @returns the cube texture as an InternalTexture
  71115. */
  71116. 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;
  71117. /** @hidden */
  71118. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71119. /** @hidden */
  71120. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71121. /** @hidden */
  71122. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71123. /** @hidden */
  71124. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71125. }
  71126. }
  71127. declare module BABYLON {
  71128. /**
  71129. * Class for creating a cube texture
  71130. */
  71131. export class CubeTexture extends BaseTexture {
  71132. private _delayedOnLoad;
  71133. /**
  71134. * The url of the texture
  71135. */
  71136. url: string;
  71137. /**
  71138. * Gets or sets the center of the bounding box associated with the cube texture.
  71139. * It must define where the camera used to render the texture was set
  71140. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71141. */
  71142. boundingBoxPosition: Vector3;
  71143. private _boundingBoxSize;
  71144. /**
  71145. * Gets or sets the size of the bounding box associated with the cube texture
  71146. * When defined, the cubemap will switch to local mode
  71147. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71148. * @example https://www.babylonjs-playground.com/#RNASML
  71149. */
  71150. /**
  71151. * Returns the bounding box size
  71152. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71153. */
  71154. boundingBoxSize: Vector3;
  71155. protected _rotationY: number;
  71156. /**
  71157. * Sets texture matrix rotation angle around Y axis in radians.
  71158. */
  71159. /**
  71160. * Gets texture matrix rotation angle around Y axis radians.
  71161. */
  71162. rotationY: number;
  71163. /**
  71164. * Are mip maps generated for this texture or not.
  71165. */
  71166. readonly noMipmap: boolean;
  71167. private _noMipmap;
  71168. private _files;
  71169. private _extensions;
  71170. private _textureMatrix;
  71171. private _format;
  71172. private _createPolynomials;
  71173. /** @hidden */
  71174. _prefiltered: boolean;
  71175. /**
  71176. * Creates a cube texture from an array of image urls
  71177. * @param files defines an array of image urls
  71178. * @param scene defines the hosting scene
  71179. * @param noMipmap specifies if mip maps are not used
  71180. * @returns a cube texture
  71181. */
  71182. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71183. /**
  71184. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71185. * @param url defines the url of the prefiltered texture
  71186. * @param scene defines the scene the texture is attached to
  71187. * @param forcedExtension defines the extension of the file if different from the url
  71188. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71189. * @return the prefiltered texture
  71190. */
  71191. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71192. /**
  71193. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71194. * as prefiltered data.
  71195. * @param rootUrl defines the url of the texture or the root name of the six images
  71196. * @param scene defines the scene the texture is attached to
  71197. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71198. * @param noMipmap defines if mipmaps should be created or not
  71199. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71200. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71201. * @param onError defines a callback triggered in case of error during load
  71202. * @param format defines the internal format to use for the texture once loaded
  71203. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71204. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71205. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71206. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71207. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71208. * @return the cube texture
  71209. */
  71210. 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);
  71211. /**
  71212. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71213. */
  71214. readonly isPrefiltered: boolean;
  71215. /**
  71216. * Get the current class name of the texture useful for serialization or dynamic coding.
  71217. * @returns "CubeTexture"
  71218. */
  71219. getClassName(): string;
  71220. /**
  71221. * Update the url (and optional buffer) of this texture if url was null during construction.
  71222. * @param url the url of the texture
  71223. * @param forcedExtension defines the extension to use
  71224. * @param onLoad callback called when the texture is loaded (defaults to null)
  71225. */
  71226. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71227. /**
  71228. * Delays loading of the cube texture
  71229. * @param forcedExtension defines the extension to use
  71230. */
  71231. delayLoad(forcedExtension?: string): void;
  71232. /**
  71233. * Returns the reflection texture matrix
  71234. * @returns the reflection texture matrix
  71235. */
  71236. getReflectionTextureMatrix(): Matrix;
  71237. /**
  71238. * Sets the reflection texture matrix
  71239. * @param value Reflection texture matrix
  71240. */
  71241. setReflectionTextureMatrix(value: Matrix): void;
  71242. /**
  71243. * Parses text to create a cube texture
  71244. * @param parsedTexture define the serialized text to read from
  71245. * @param scene defines the hosting scene
  71246. * @param rootUrl defines the root url of the cube texture
  71247. * @returns a cube texture
  71248. */
  71249. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71250. /**
  71251. * Makes a clone, or deep copy, of the cube texture
  71252. * @returns a new cube texture
  71253. */
  71254. clone(): CubeTexture;
  71255. }
  71256. }
  71257. declare module BABYLON {
  71258. /**
  71259. * Manages the defines for the Material
  71260. */
  71261. export class MaterialDefines {
  71262. /** @hidden */
  71263. protected _keys: string[];
  71264. private _isDirty;
  71265. /** @hidden */
  71266. _renderId: number;
  71267. /** @hidden */
  71268. _areLightsDirty: boolean;
  71269. /** @hidden */
  71270. _areAttributesDirty: boolean;
  71271. /** @hidden */
  71272. _areTexturesDirty: boolean;
  71273. /** @hidden */
  71274. _areFresnelDirty: boolean;
  71275. /** @hidden */
  71276. _areMiscDirty: boolean;
  71277. /** @hidden */
  71278. _areImageProcessingDirty: boolean;
  71279. /** @hidden */
  71280. _normals: boolean;
  71281. /** @hidden */
  71282. _uvs: boolean;
  71283. /** @hidden */
  71284. _needNormals: boolean;
  71285. /** @hidden */
  71286. _needUVs: boolean;
  71287. [id: string]: any;
  71288. /**
  71289. * Specifies if the material needs to be re-calculated
  71290. */
  71291. readonly isDirty: boolean;
  71292. /**
  71293. * Marks the material to indicate that it has been re-calculated
  71294. */
  71295. markAsProcessed(): void;
  71296. /**
  71297. * Marks the material to indicate that it needs to be re-calculated
  71298. */
  71299. markAsUnprocessed(): void;
  71300. /**
  71301. * Marks the material to indicate all of its defines need to be re-calculated
  71302. */
  71303. markAllAsDirty(): void;
  71304. /**
  71305. * Marks the material to indicate that image processing needs to be re-calculated
  71306. */
  71307. markAsImageProcessingDirty(): void;
  71308. /**
  71309. * Marks the material to indicate the lights need to be re-calculated
  71310. */
  71311. markAsLightDirty(): void;
  71312. /**
  71313. * Marks the attribute state as changed
  71314. */
  71315. markAsAttributesDirty(): void;
  71316. /**
  71317. * Marks the texture state as changed
  71318. */
  71319. markAsTexturesDirty(): void;
  71320. /**
  71321. * Marks the fresnel state as changed
  71322. */
  71323. markAsFresnelDirty(): void;
  71324. /**
  71325. * Marks the misc state as changed
  71326. */
  71327. markAsMiscDirty(): void;
  71328. /**
  71329. * Rebuilds the material defines
  71330. */
  71331. rebuild(): void;
  71332. /**
  71333. * Specifies if two material defines are equal
  71334. * @param other - A material define instance to compare to
  71335. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  71336. */
  71337. isEqual(other: MaterialDefines): boolean;
  71338. /**
  71339. * Clones this instance's defines to another instance
  71340. * @param other - material defines to clone values to
  71341. */
  71342. cloneTo(other: MaterialDefines): void;
  71343. /**
  71344. * Resets the material define values
  71345. */
  71346. reset(): void;
  71347. /**
  71348. * Converts the material define values to a string
  71349. * @returns - String of material define information
  71350. */
  71351. toString(): string;
  71352. }
  71353. }
  71354. declare module BABYLON {
  71355. /**
  71356. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  71357. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  71358. * 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;
  71359. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  71360. */
  71361. export class ColorCurves {
  71362. private _dirty;
  71363. private _tempColor;
  71364. private _globalCurve;
  71365. private _highlightsCurve;
  71366. private _midtonesCurve;
  71367. private _shadowsCurve;
  71368. private _positiveCurve;
  71369. private _negativeCurve;
  71370. private _globalHue;
  71371. private _globalDensity;
  71372. private _globalSaturation;
  71373. private _globalExposure;
  71374. /**
  71375. * Gets the global Hue value.
  71376. * 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).
  71377. */
  71378. /**
  71379. * Sets the global Hue value.
  71380. * 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).
  71381. */
  71382. globalHue: number;
  71383. /**
  71384. * Gets the global Density value.
  71385. * 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.
  71386. * Values less than zero provide a filter of opposite hue.
  71387. */
  71388. /**
  71389. * Sets the global Density value.
  71390. * 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.
  71391. * Values less than zero provide a filter of opposite hue.
  71392. */
  71393. globalDensity: number;
  71394. /**
  71395. * Gets the global Saturation value.
  71396. * 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.
  71397. */
  71398. /**
  71399. * Sets the global Saturation value.
  71400. * 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.
  71401. */
  71402. globalSaturation: number;
  71403. /**
  71404. * Gets the global Exposure value.
  71405. * 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.
  71406. */
  71407. /**
  71408. * Sets the global Exposure value.
  71409. * 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.
  71410. */
  71411. globalExposure: number;
  71412. private _highlightsHue;
  71413. private _highlightsDensity;
  71414. private _highlightsSaturation;
  71415. private _highlightsExposure;
  71416. /**
  71417. * Gets the highlights Hue value.
  71418. * 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).
  71419. */
  71420. /**
  71421. * Sets the highlights Hue value.
  71422. * 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).
  71423. */
  71424. highlightsHue: number;
  71425. /**
  71426. * Gets the highlights Density value.
  71427. * 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.
  71428. * Values less than zero provide a filter of opposite hue.
  71429. */
  71430. /**
  71431. * Sets the highlights Density value.
  71432. * 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.
  71433. * Values less than zero provide a filter of opposite hue.
  71434. */
  71435. highlightsDensity: number;
  71436. /**
  71437. * Gets the highlights Saturation value.
  71438. * 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.
  71439. */
  71440. /**
  71441. * Sets the highlights Saturation value.
  71442. * 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.
  71443. */
  71444. highlightsSaturation: number;
  71445. /**
  71446. * Gets the highlights Exposure value.
  71447. * 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.
  71448. */
  71449. /**
  71450. * Sets the highlights Exposure value.
  71451. * 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.
  71452. */
  71453. highlightsExposure: number;
  71454. private _midtonesHue;
  71455. private _midtonesDensity;
  71456. private _midtonesSaturation;
  71457. private _midtonesExposure;
  71458. /**
  71459. * Gets the midtones Hue value.
  71460. * 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).
  71461. */
  71462. /**
  71463. * Sets the midtones Hue value.
  71464. * 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).
  71465. */
  71466. midtonesHue: number;
  71467. /**
  71468. * Gets the midtones Density value.
  71469. * 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.
  71470. * Values less than zero provide a filter of opposite hue.
  71471. */
  71472. /**
  71473. * Sets the midtones Density value.
  71474. * 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.
  71475. * Values less than zero provide a filter of opposite hue.
  71476. */
  71477. midtonesDensity: number;
  71478. /**
  71479. * Gets the midtones Saturation value.
  71480. * 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.
  71481. */
  71482. /**
  71483. * Sets the midtones Saturation value.
  71484. * 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.
  71485. */
  71486. midtonesSaturation: number;
  71487. /**
  71488. * Gets the midtones Exposure value.
  71489. * 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.
  71490. */
  71491. /**
  71492. * Sets the midtones Exposure value.
  71493. * 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.
  71494. */
  71495. midtonesExposure: number;
  71496. private _shadowsHue;
  71497. private _shadowsDensity;
  71498. private _shadowsSaturation;
  71499. private _shadowsExposure;
  71500. /**
  71501. * Gets the shadows Hue value.
  71502. * 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).
  71503. */
  71504. /**
  71505. * Sets the shadows Hue value.
  71506. * 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).
  71507. */
  71508. shadowsHue: number;
  71509. /**
  71510. * Gets the shadows Density value.
  71511. * 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.
  71512. * Values less than zero provide a filter of opposite hue.
  71513. */
  71514. /**
  71515. * Sets the shadows Density value.
  71516. * 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.
  71517. * Values less than zero provide a filter of opposite hue.
  71518. */
  71519. shadowsDensity: number;
  71520. /**
  71521. * Gets the shadows Saturation value.
  71522. * 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.
  71523. */
  71524. /**
  71525. * Sets the shadows Saturation value.
  71526. * 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.
  71527. */
  71528. shadowsSaturation: number;
  71529. /**
  71530. * Gets the shadows Exposure value.
  71531. * 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.
  71532. */
  71533. /**
  71534. * Sets the shadows Exposure value.
  71535. * 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.
  71536. */
  71537. shadowsExposure: number;
  71538. /**
  71539. * Returns the class name
  71540. * @returns The class name
  71541. */
  71542. getClassName(): string;
  71543. /**
  71544. * Binds the color curves to the shader.
  71545. * @param colorCurves The color curve to bind
  71546. * @param effect The effect to bind to
  71547. * @param positiveUniform The positive uniform shader parameter
  71548. * @param neutralUniform The neutral uniform shader parameter
  71549. * @param negativeUniform The negative uniform shader parameter
  71550. */
  71551. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  71552. /**
  71553. * Prepare the list of uniforms associated with the ColorCurves effects.
  71554. * @param uniformsList The list of uniforms used in the effect
  71555. */
  71556. static PrepareUniforms(uniformsList: string[]): void;
  71557. /**
  71558. * Returns color grading data based on a hue, density, saturation and exposure value.
  71559. * @param filterHue The hue of the color filter.
  71560. * @param filterDensity The density of the color filter.
  71561. * @param saturation The saturation.
  71562. * @param exposure The exposure.
  71563. * @param result The result data container.
  71564. */
  71565. private getColorGradingDataToRef;
  71566. /**
  71567. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  71568. * @param value The input slider value in range [-100,100].
  71569. * @returns Adjusted value.
  71570. */
  71571. private static applyColorGradingSliderNonlinear;
  71572. /**
  71573. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  71574. * @param hue The hue (H) input.
  71575. * @param saturation The saturation (S) input.
  71576. * @param brightness The brightness (B) input.
  71577. * @result An RGBA color represented as Vector4.
  71578. */
  71579. private static fromHSBToRef;
  71580. /**
  71581. * Returns a value clamped between min and max
  71582. * @param value The value to clamp
  71583. * @param min The minimum of value
  71584. * @param max The maximum of value
  71585. * @returns The clamped value.
  71586. */
  71587. private static clamp;
  71588. /**
  71589. * Clones the current color curve instance.
  71590. * @return The cloned curves
  71591. */
  71592. clone(): ColorCurves;
  71593. /**
  71594. * Serializes the current color curve instance to a json representation.
  71595. * @return a JSON representation
  71596. */
  71597. serialize(): any;
  71598. /**
  71599. * Parses the color curve from a json representation.
  71600. * @param source the JSON source to parse
  71601. * @return The parsed curves
  71602. */
  71603. static Parse(source: any): ColorCurves;
  71604. }
  71605. }
  71606. declare module BABYLON {
  71607. /**
  71608. * Interface to follow in your material defines to integrate easily the
  71609. * Image proccessing functions.
  71610. * @hidden
  71611. */
  71612. export interface IImageProcessingConfigurationDefines {
  71613. IMAGEPROCESSING: boolean;
  71614. VIGNETTE: boolean;
  71615. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71616. VIGNETTEBLENDMODEOPAQUE: boolean;
  71617. TONEMAPPING: boolean;
  71618. TONEMAPPING_ACES: boolean;
  71619. CONTRAST: boolean;
  71620. EXPOSURE: boolean;
  71621. COLORCURVES: boolean;
  71622. COLORGRADING: boolean;
  71623. COLORGRADING3D: boolean;
  71624. SAMPLER3DGREENDEPTH: boolean;
  71625. SAMPLER3DBGRMAP: boolean;
  71626. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71627. }
  71628. /**
  71629. * @hidden
  71630. */
  71631. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  71632. IMAGEPROCESSING: boolean;
  71633. VIGNETTE: boolean;
  71634. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71635. VIGNETTEBLENDMODEOPAQUE: boolean;
  71636. TONEMAPPING: boolean;
  71637. TONEMAPPING_ACES: boolean;
  71638. CONTRAST: boolean;
  71639. COLORCURVES: boolean;
  71640. COLORGRADING: boolean;
  71641. COLORGRADING3D: boolean;
  71642. SAMPLER3DGREENDEPTH: boolean;
  71643. SAMPLER3DBGRMAP: boolean;
  71644. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71645. EXPOSURE: boolean;
  71646. constructor();
  71647. }
  71648. /**
  71649. * This groups together the common properties used for image processing either in direct forward pass
  71650. * or through post processing effect depending on the use of the image processing pipeline in your scene
  71651. * or not.
  71652. */
  71653. export class ImageProcessingConfiguration {
  71654. /**
  71655. * Default tone mapping applied in BabylonJS.
  71656. */
  71657. static readonly TONEMAPPING_STANDARD: number;
  71658. /**
  71659. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  71660. * to other engines rendering to increase portability.
  71661. */
  71662. static readonly TONEMAPPING_ACES: number;
  71663. /**
  71664. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  71665. */
  71666. colorCurves: Nullable<ColorCurves>;
  71667. private _colorCurvesEnabled;
  71668. /**
  71669. * Gets wether the color curves effect is enabled.
  71670. */
  71671. /**
  71672. * Sets wether the color curves effect is enabled.
  71673. */
  71674. colorCurvesEnabled: boolean;
  71675. private _colorGradingTexture;
  71676. /**
  71677. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71678. */
  71679. /**
  71680. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71681. */
  71682. colorGradingTexture: Nullable<BaseTexture>;
  71683. private _colorGradingEnabled;
  71684. /**
  71685. * Gets wether the color grading effect is enabled.
  71686. */
  71687. /**
  71688. * Sets wether the color grading effect is enabled.
  71689. */
  71690. colorGradingEnabled: boolean;
  71691. private _colorGradingWithGreenDepth;
  71692. /**
  71693. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  71694. */
  71695. /**
  71696. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  71697. */
  71698. colorGradingWithGreenDepth: boolean;
  71699. private _colorGradingBGR;
  71700. /**
  71701. * Gets wether the color grading texture contains BGR values.
  71702. */
  71703. /**
  71704. * Sets wether the color grading texture contains BGR values.
  71705. */
  71706. colorGradingBGR: boolean;
  71707. /** @hidden */
  71708. _exposure: number;
  71709. /**
  71710. * Gets the Exposure used in the effect.
  71711. */
  71712. /**
  71713. * Sets the Exposure used in the effect.
  71714. */
  71715. exposure: number;
  71716. private _toneMappingEnabled;
  71717. /**
  71718. * Gets wether the tone mapping effect is enabled.
  71719. */
  71720. /**
  71721. * Sets wether the tone mapping effect is enabled.
  71722. */
  71723. toneMappingEnabled: boolean;
  71724. private _toneMappingType;
  71725. /**
  71726. * Gets the type of tone mapping effect.
  71727. */
  71728. /**
  71729. * Sets the type of tone mapping effect used in BabylonJS.
  71730. */
  71731. toneMappingType: number;
  71732. protected _contrast: number;
  71733. /**
  71734. * Gets the contrast used in the effect.
  71735. */
  71736. /**
  71737. * Sets the contrast used in the effect.
  71738. */
  71739. contrast: number;
  71740. /**
  71741. * Vignette stretch size.
  71742. */
  71743. vignetteStretch: number;
  71744. /**
  71745. * Vignette centre X Offset.
  71746. */
  71747. vignetteCentreX: number;
  71748. /**
  71749. * Vignette centre Y Offset.
  71750. */
  71751. vignetteCentreY: number;
  71752. /**
  71753. * Vignette weight or intensity of the vignette effect.
  71754. */
  71755. vignetteWeight: number;
  71756. /**
  71757. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  71758. * if vignetteEnabled is set to true.
  71759. */
  71760. vignetteColor: Color4;
  71761. /**
  71762. * Camera field of view used by the Vignette effect.
  71763. */
  71764. vignetteCameraFov: number;
  71765. private _vignetteBlendMode;
  71766. /**
  71767. * Gets the vignette blend mode allowing different kind of effect.
  71768. */
  71769. /**
  71770. * Sets the vignette blend mode allowing different kind of effect.
  71771. */
  71772. vignetteBlendMode: number;
  71773. private _vignetteEnabled;
  71774. /**
  71775. * Gets wether the vignette effect is enabled.
  71776. */
  71777. /**
  71778. * Sets wether the vignette effect is enabled.
  71779. */
  71780. vignetteEnabled: boolean;
  71781. private _applyByPostProcess;
  71782. /**
  71783. * Gets wether the image processing is applied through a post process or not.
  71784. */
  71785. /**
  71786. * Sets wether the image processing is applied through a post process or not.
  71787. */
  71788. applyByPostProcess: boolean;
  71789. private _isEnabled;
  71790. /**
  71791. * Gets wether the image processing is enabled or not.
  71792. */
  71793. /**
  71794. * Sets wether the image processing is enabled or not.
  71795. */
  71796. isEnabled: boolean;
  71797. /**
  71798. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  71799. */
  71800. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  71801. /**
  71802. * Method called each time the image processing information changes requires to recompile the effect.
  71803. */
  71804. protected _updateParameters(): void;
  71805. /**
  71806. * Gets the current class name.
  71807. * @return "ImageProcessingConfiguration"
  71808. */
  71809. getClassName(): string;
  71810. /**
  71811. * Prepare the list of uniforms associated with the Image Processing effects.
  71812. * @param uniforms The list of uniforms used in the effect
  71813. * @param defines the list of defines currently in use
  71814. */
  71815. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  71816. /**
  71817. * Prepare the list of samplers associated with the Image Processing effects.
  71818. * @param samplersList The list of uniforms used in the effect
  71819. * @param defines the list of defines currently in use
  71820. */
  71821. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  71822. /**
  71823. * Prepare the list of defines associated to the shader.
  71824. * @param defines the list of defines to complete
  71825. * @param forPostProcess Define if we are currently in post process mode or not
  71826. */
  71827. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  71828. /**
  71829. * Returns true if all the image processing information are ready.
  71830. * @returns True if ready, otherwise, false
  71831. */
  71832. isReady(): boolean;
  71833. /**
  71834. * Binds the image processing to the shader.
  71835. * @param effect The effect to bind to
  71836. * @param aspectRatio Define the current aspect ratio of the effect
  71837. */
  71838. bind(effect: Effect, aspectRatio?: number): void;
  71839. /**
  71840. * Clones the current image processing instance.
  71841. * @return The cloned image processing
  71842. */
  71843. clone(): ImageProcessingConfiguration;
  71844. /**
  71845. * Serializes the current image processing instance to a json representation.
  71846. * @return a JSON representation
  71847. */
  71848. serialize(): any;
  71849. /**
  71850. * Parses the image processing from a json representation.
  71851. * @param source the JSON source to parse
  71852. * @return The parsed image processing
  71853. */
  71854. static Parse(source: any): ImageProcessingConfiguration;
  71855. private static _VIGNETTEMODE_MULTIPLY;
  71856. private static _VIGNETTEMODE_OPAQUE;
  71857. /**
  71858. * Used to apply the vignette as a mix with the pixel color.
  71859. */
  71860. static readonly VIGNETTEMODE_MULTIPLY: number;
  71861. /**
  71862. * Used to apply the vignette as a replacement of the pixel color.
  71863. */
  71864. static readonly VIGNETTEMODE_OPAQUE: number;
  71865. }
  71866. }
  71867. declare module BABYLON {
  71868. /** @hidden */
  71869. export var postprocessVertexShader: {
  71870. name: string;
  71871. shader: string;
  71872. };
  71873. }
  71874. declare module BABYLON {
  71875. /** Defines supported spaces */
  71876. export enum Space {
  71877. /** Local (object) space */
  71878. LOCAL = 0,
  71879. /** World space */
  71880. WORLD = 1,
  71881. /** Bone space */
  71882. BONE = 2
  71883. }
  71884. /** Defines the 3 main axes */
  71885. export class Axis {
  71886. /** X axis */
  71887. static X: Vector3;
  71888. /** Y axis */
  71889. static Y: Vector3;
  71890. /** Z axis */
  71891. static Z: Vector3;
  71892. }
  71893. }
  71894. declare module BABYLON {
  71895. /**
  71896. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  71897. * This is the base of the follow, arc rotate cameras and Free camera
  71898. * @see http://doc.babylonjs.com/features/cameras
  71899. */
  71900. export class TargetCamera extends Camera {
  71901. private static _RigCamTransformMatrix;
  71902. private static _TargetTransformMatrix;
  71903. private static _TargetFocalPoint;
  71904. /**
  71905. * Define the current direction the camera is moving to
  71906. */
  71907. cameraDirection: Vector3;
  71908. /**
  71909. * Define the current rotation the camera is rotating to
  71910. */
  71911. cameraRotation: Vector2;
  71912. /**
  71913. * When set, the up vector of the camera will be updated by the rotation of the camera
  71914. */
  71915. updateUpVectorFromRotation: boolean;
  71916. private _tmpQuaternion;
  71917. /**
  71918. * Define the current rotation of the camera
  71919. */
  71920. rotation: Vector3;
  71921. /**
  71922. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  71923. */
  71924. rotationQuaternion: Quaternion;
  71925. /**
  71926. * Define the current speed of the camera
  71927. */
  71928. speed: number;
  71929. /**
  71930. * Add cconstraint to the camera to prevent it to move freely in all directions and
  71931. * around all axis.
  71932. */
  71933. noRotationConstraint: boolean;
  71934. /**
  71935. * Define the current target of the camera as an object or a position.
  71936. */
  71937. lockedTarget: any;
  71938. /** @hidden */
  71939. _currentTarget: Vector3;
  71940. /** @hidden */
  71941. _initialFocalDistance: number;
  71942. /** @hidden */
  71943. _viewMatrix: Matrix;
  71944. /** @hidden */
  71945. _camMatrix: Matrix;
  71946. /** @hidden */
  71947. _cameraTransformMatrix: Matrix;
  71948. /** @hidden */
  71949. _cameraRotationMatrix: Matrix;
  71950. /** @hidden */
  71951. _referencePoint: Vector3;
  71952. /** @hidden */
  71953. _transformedReferencePoint: Vector3;
  71954. protected _globalCurrentTarget: Vector3;
  71955. protected _globalCurrentUpVector: Vector3;
  71956. /** @hidden */
  71957. _reset: () => void;
  71958. private _defaultUp;
  71959. /**
  71960. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  71961. * This is the base of the follow, arc rotate cameras and Free camera
  71962. * @see http://doc.babylonjs.com/features/cameras
  71963. * @param name Defines the name of the camera in the scene
  71964. * @param position Defines the start position of the camera in the scene
  71965. * @param scene Defines the scene the camera belongs to
  71966. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71967. */
  71968. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71969. /**
  71970. * Gets the position in front of the camera at a given distance.
  71971. * @param distance The distance from the camera we want the position to be
  71972. * @returns the position
  71973. */
  71974. getFrontPosition(distance: number): Vector3;
  71975. /** @hidden */
  71976. _getLockedTargetPosition(): Nullable<Vector3>;
  71977. private _storedPosition;
  71978. private _storedRotation;
  71979. private _storedRotationQuaternion;
  71980. /**
  71981. * Store current camera state of the camera (fov, position, rotation, etc..)
  71982. * @returns the camera
  71983. */
  71984. storeState(): Camera;
  71985. /**
  71986. * Restored camera state. You must call storeState() first
  71987. * @returns whether it was successful or not
  71988. * @hidden
  71989. */
  71990. _restoreStateValues(): boolean;
  71991. /** @hidden */
  71992. _initCache(): void;
  71993. /** @hidden */
  71994. _updateCache(ignoreParentClass?: boolean): void;
  71995. /** @hidden */
  71996. _isSynchronizedViewMatrix(): boolean;
  71997. /** @hidden */
  71998. _computeLocalCameraSpeed(): number;
  71999. /**
  72000. * Defines the target the camera should look at.
  72001. * @param target Defines the new target as a Vector or a mesh
  72002. */
  72003. setTarget(target: Vector3): void;
  72004. /**
  72005. * Return the current target position of the camera. This value is expressed in local space.
  72006. * @returns the target position
  72007. */
  72008. getTarget(): Vector3;
  72009. /** @hidden */
  72010. _decideIfNeedsToMove(): boolean;
  72011. /** @hidden */
  72012. _updatePosition(): void;
  72013. /** @hidden */
  72014. _checkInputs(): void;
  72015. protected _updateCameraRotationMatrix(): void;
  72016. /**
  72017. * 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)
  72018. * @returns the current camera
  72019. */
  72020. private _rotateUpVectorWithCameraRotationMatrix;
  72021. private _cachedRotationZ;
  72022. private _cachedQuaternionRotationZ;
  72023. /** @hidden */
  72024. _getViewMatrix(): Matrix;
  72025. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72026. /**
  72027. * @hidden
  72028. */
  72029. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72030. /**
  72031. * @hidden
  72032. */
  72033. _updateRigCameras(): void;
  72034. private _getRigCamPositionAndTarget;
  72035. /**
  72036. * Gets the current object class name.
  72037. * @return the class name
  72038. */
  72039. getClassName(): string;
  72040. }
  72041. }
  72042. declare module BABYLON {
  72043. /**
  72044. * Gather the list of keyboard event types as constants.
  72045. */
  72046. export class KeyboardEventTypes {
  72047. /**
  72048. * The keydown event is fired when a key becomes active (pressed).
  72049. */
  72050. static readonly KEYDOWN: number;
  72051. /**
  72052. * The keyup event is fired when a key has been released.
  72053. */
  72054. static readonly KEYUP: number;
  72055. }
  72056. /**
  72057. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72058. */
  72059. export class KeyboardInfo {
  72060. /**
  72061. * Defines the type of event (KeyboardEventTypes)
  72062. */
  72063. type: number;
  72064. /**
  72065. * Defines the related dom event
  72066. */
  72067. event: KeyboardEvent;
  72068. /**
  72069. * Instantiates a new keyboard info.
  72070. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72071. * @param type Defines the type of event (KeyboardEventTypes)
  72072. * @param event Defines the related dom event
  72073. */
  72074. constructor(
  72075. /**
  72076. * Defines the type of event (KeyboardEventTypes)
  72077. */
  72078. type: number,
  72079. /**
  72080. * Defines the related dom event
  72081. */
  72082. event: KeyboardEvent);
  72083. }
  72084. /**
  72085. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72086. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72087. */
  72088. export class KeyboardInfoPre extends KeyboardInfo {
  72089. /**
  72090. * Defines the type of event (KeyboardEventTypes)
  72091. */
  72092. type: number;
  72093. /**
  72094. * Defines the related dom event
  72095. */
  72096. event: KeyboardEvent;
  72097. /**
  72098. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72099. */
  72100. skipOnPointerObservable: boolean;
  72101. /**
  72102. * Instantiates a new keyboard pre info.
  72103. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72104. * @param type Defines the type of event (KeyboardEventTypes)
  72105. * @param event Defines the related dom event
  72106. */
  72107. constructor(
  72108. /**
  72109. * Defines the type of event (KeyboardEventTypes)
  72110. */
  72111. type: number,
  72112. /**
  72113. * Defines the related dom event
  72114. */
  72115. event: KeyboardEvent);
  72116. }
  72117. }
  72118. declare module BABYLON {
  72119. /**
  72120. * Manage the keyboard inputs to control the movement of a free camera.
  72121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72122. */
  72123. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72124. /**
  72125. * Defines the camera the input is attached to.
  72126. */
  72127. camera: FreeCamera;
  72128. /**
  72129. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72130. */
  72131. keysUp: number[];
  72132. /**
  72133. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72134. */
  72135. keysDown: number[];
  72136. /**
  72137. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72138. */
  72139. keysLeft: number[];
  72140. /**
  72141. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72142. */
  72143. keysRight: number[];
  72144. private _keys;
  72145. private _onCanvasBlurObserver;
  72146. private _onKeyboardObserver;
  72147. private _engine;
  72148. private _scene;
  72149. /**
  72150. * Attach the input controls to a specific dom element to get the input from.
  72151. * @param element Defines the element the controls should be listened from
  72152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72153. */
  72154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72155. /**
  72156. * Detach the current controls from the specified dom element.
  72157. * @param element Defines the element to stop listening the inputs from
  72158. */
  72159. detachControl(element: Nullable<HTMLElement>): void;
  72160. /**
  72161. * Update the current camera state depending on the inputs that have been used this frame.
  72162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72163. */
  72164. checkInputs(): void;
  72165. /**
  72166. * Gets the class name of the current intput.
  72167. * @returns the class name
  72168. */
  72169. getClassName(): string;
  72170. /** @hidden */
  72171. _onLostFocus(): void;
  72172. /**
  72173. * Get the friendly name associated with the input class.
  72174. * @returns the input friendly name
  72175. */
  72176. getSimpleName(): string;
  72177. }
  72178. }
  72179. declare module BABYLON {
  72180. /**
  72181. * Interface describing all the common properties and methods a shadow light needs to implement.
  72182. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  72183. * as well as binding the different shadow properties to the effects.
  72184. */
  72185. export interface IShadowLight extends Light {
  72186. /**
  72187. * The light id in the scene (used in scene.findLighById for instance)
  72188. */
  72189. id: string;
  72190. /**
  72191. * The position the shdow will be casted from.
  72192. */
  72193. position: Vector3;
  72194. /**
  72195. * In 2d mode (needCube being false), the direction used to cast the shadow.
  72196. */
  72197. direction: Vector3;
  72198. /**
  72199. * The transformed position. Position of the light in world space taking parenting in account.
  72200. */
  72201. transformedPosition: Vector3;
  72202. /**
  72203. * The transformed direction. Direction of the light in world space taking parenting in account.
  72204. */
  72205. transformedDirection: Vector3;
  72206. /**
  72207. * The friendly name of the light in the scene.
  72208. */
  72209. name: string;
  72210. /**
  72211. * Defines the shadow projection clipping minimum z value.
  72212. */
  72213. shadowMinZ: number;
  72214. /**
  72215. * Defines the shadow projection clipping maximum z value.
  72216. */
  72217. shadowMaxZ: number;
  72218. /**
  72219. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72220. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72221. */
  72222. computeTransformedInformation(): boolean;
  72223. /**
  72224. * Gets the scene the light belongs to.
  72225. * @returns The scene
  72226. */
  72227. getScene(): Scene;
  72228. /**
  72229. * Callback defining a custom Projection Matrix Builder.
  72230. * This can be used to override the default projection matrix computation.
  72231. */
  72232. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72233. /**
  72234. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72235. * @param matrix The materix to updated with the projection information
  72236. * @param viewMatrix The transform matrix of the light
  72237. * @param renderList The list of mesh to render in the map
  72238. * @returns The current light
  72239. */
  72240. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72241. /**
  72242. * Gets the current depth scale used in ESM.
  72243. * @returns The scale
  72244. */
  72245. getDepthScale(): number;
  72246. /**
  72247. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72248. * @returns true if a cube texture needs to be use
  72249. */
  72250. needCube(): boolean;
  72251. /**
  72252. * Detects if the projection matrix requires to be recomputed this frame.
  72253. * @returns true if it requires to be recomputed otherwise, false.
  72254. */
  72255. needProjectionMatrixCompute(): boolean;
  72256. /**
  72257. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72258. */
  72259. forceProjectionMatrixCompute(): void;
  72260. /**
  72261. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72262. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72263. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72264. */
  72265. getShadowDirection(faceIndex?: number): Vector3;
  72266. /**
  72267. * Gets the minZ used for shadow according to both the scene and the light.
  72268. * @param activeCamera The camera we are returning the min for
  72269. * @returns the depth min z
  72270. */
  72271. getDepthMinZ(activeCamera: Camera): number;
  72272. /**
  72273. * Gets the maxZ used for shadow according to both the scene and the light.
  72274. * @param activeCamera The camera we are returning the max for
  72275. * @returns the depth max z
  72276. */
  72277. getDepthMaxZ(activeCamera: Camera): number;
  72278. }
  72279. /**
  72280. * Base implementation IShadowLight
  72281. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  72282. */
  72283. export abstract class ShadowLight extends Light implements IShadowLight {
  72284. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  72285. protected _position: Vector3;
  72286. protected _setPosition(value: Vector3): void;
  72287. /**
  72288. * Sets the position the shadow will be casted from. Also use as the light position for both
  72289. * point and spot lights.
  72290. */
  72291. /**
  72292. * Sets the position the shadow will be casted from. Also use as the light position for both
  72293. * point and spot lights.
  72294. */
  72295. position: Vector3;
  72296. protected _direction: Vector3;
  72297. protected _setDirection(value: Vector3): void;
  72298. /**
  72299. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  72300. * Also use as the light direction on spot and directional lights.
  72301. */
  72302. /**
  72303. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  72304. * Also use as the light direction on spot and directional lights.
  72305. */
  72306. direction: Vector3;
  72307. private _shadowMinZ;
  72308. /**
  72309. * Gets the shadow projection clipping minimum z value.
  72310. */
  72311. /**
  72312. * Sets the shadow projection clipping minimum z value.
  72313. */
  72314. shadowMinZ: number;
  72315. private _shadowMaxZ;
  72316. /**
  72317. * Sets the shadow projection clipping maximum z value.
  72318. */
  72319. /**
  72320. * Gets the shadow projection clipping maximum z value.
  72321. */
  72322. shadowMaxZ: number;
  72323. /**
  72324. * Callback defining a custom Projection Matrix Builder.
  72325. * This can be used to override the default projection matrix computation.
  72326. */
  72327. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72328. /**
  72329. * The transformed position. Position of the light in world space taking parenting in account.
  72330. */
  72331. transformedPosition: Vector3;
  72332. /**
  72333. * The transformed direction. Direction of the light in world space taking parenting in account.
  72334. */
  72335. transformedDirection: Vector3;
  72336. private _needProjectionMatrixCompute;
  72337. /**
  72338. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72339. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72340. */
  72341. computeTransformedInformation(): boolean;
  72342. /**
  72343. * Return the depth scale used for the shadow map.
  72344. * @returns the depth scale.
  72345. */
  72346. getDepthScale(): number;
  72347. /**
  72348. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72349. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72350. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72351. */
  72352. getShadowDirection(faceIndex?: number): Vector3;
  72353. /**
  72354. * Returns the ShadowLight absolute position in the World.
  72355. * @returns the position vector in world space
  72356. */
  72357. getAbsolutePosition(): Vector3;
  72358. /**
  72359. * Sets the ShadowLight direction toward the passed target.
  72360. * @param target The point to target in local space
  72361. * @returns the updated ShadowLight direction
  72362. */
  72363. setDirectionToTarget(target: Vector3): Vector3;
  72364. /**
  72365. * Returns the light rotation in euler definition.
  72366. * @returns the x y z rotation in local space.
  72367. */
  72368. getRotation(): Vector3;
  72369. /**
  72370. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72371. * @returns true if a cube texture needs to be use
  72372. */
  72373. needCube(): boolean;
  72374. /**
  72375. * Detects if the projection matrix requires to be recomputed this frame.
  72376. * @returns true if it requires to be recomputed otherwise, false.
  72377. */
  72378. needProjectionMatrixCompute(): boolean;
  72379. /**
  72380. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72381. */
  72382. forceProjectionMatrixCompute(): void;
  72383. /** @hidden */
  72384. _initCache(): void;
  72385. /** @hidden */
  72386. _isSynchronized(): boolean;
  72387. /**
  72388. * Computes the world matrix of the node
  72389. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72390. * @returns the world matrix
  72391. */
  72392. computeWorldMatrix(force?: boolean): Matrix;
  72393. /**
  72394. * Gets the minZ used for shadow according to both the scene and the light.
  72395. * @param activeCamera The camera we are returning the min for
  72396. * @returns the depth min z
  72397. */
  72398. getDepthMinZ(activeCamera: Camera): number;
  72399. /**
  72400. * Gets the maxZ used for shadow according to both the scene and the light.
  72401. * @param activeCamera The camera we are returning the max for
  72402. * @returns the depth max z
  72403. */
  72404. getDepthMaxZ(activeCamera: Camera): number;
  72405. /**
  72406. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72407. * @param matrix The materix to updated with the projection information
  72408. * @param viewMatrix The transform matrix of the light
  72409. * @param renderList The list of mesh to render in the map
  72410. * @returns The current light
  72411. */
  72412. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72413. }
  72414. }
  72415. declare module BABYLON {
  72416. /**
  72417. * "Static Class" containing the most commonly used helper while dealing with material for
  72418. * rendering purpose.
  72419. *
  72420. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  72421. *
  72422. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  72423. */
  72424. export class MaterialHelper {
  72425. /**
  72426. * Bind the current view position to an effect.
  72427. * @param effect The effect to be bound
  72428. * @param scene The scene the eyes position is used from
  72429. */
  72430. static BindEyePosition(effect: Effect, scene: Scene): void;
  72431. /**
  72432. * Helps preparing the defines values about the UVs in used in the effect.
  72433. * UVs are shared as much as we can accross channels in the shaders.
  72434. * @param texture The texture we are preparing the UVs for
  72435. * @param defines The defines to update
  72436. * @param key The channel key "diffuse", "specular"... used in the shader
  72437. */
  72438. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  72439. /**
  72440. * Binds a texture matrix value to its corrsponding uniform
  72441. * @param texture The texture to bind the matrix for
  72442. * @param uniformBuffer The uniform buffer receivin the data
  72443. * @param key The channel key "diffuse", "specular"... used in the shader
  72444. */
  72445. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  72446. /**
  72447. * Gets the current status of the fog (should it be enabled?)
  72448. * @param mesh defines the mesh to evaluate for fog support
  72449. * @param scene defines the hosting scene
  72450. * @returns true if fog must be enabled
  72451. */
  72452. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  72453. /**
  72454. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  72455. * @param mesh defines the current mesh
  72456. * @param scene defines the current scene
  72457. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  72458. * @param pointsCloud defines if point cloud rendering has to be turned on
  72459. * @param fogEnabled defines if fog has to be turned on
  72460. * @param alphaTest defines if alpha testing has to be turned on
  72461. * @param defines defines the current list of defines
  72462. */
  72463. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  72464. /**
  72465. * Helper used to prepare the list of defines associated with frame values for shader compilation
  72466. * @param scene defines the current scene
  72467. * @param engine defines the current engine
  72468. * @param defines specifies the list of active defines
  72469. * @param useInstances defines if instances have to be turned on
  72470. * @param useClipPlane defines if clip plane have to be turned on
  72471. */
  72472. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  72473. /**
  72474. * Prepares the defines for bones
  72475. * @param mesh The mesh containing the geometry data we will draw
  72476. * @param defines The defines to update
  72477. */
  72478. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  72479. /**
  72480. * Prepares the defines for morph targets
  72481. * @param mesh The mesh containing the geometry data we will draw
  72482. * @param defines The defines to update
  72483. */
  72484. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  72485. /**
  72486. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  72487. * @param mesh The mesh containing the geometry data we will draw
  72488. * @param defines The defines to update
  72489. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  72490. * @param useBones Precise whether bones should be used or not (override mesh info)
  72491. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  72492. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  72493. * @returns false if defines are considered not dirty and have not been checked
  72494. */
  72495. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  72496. /**
  72497. * Prepares the defines related to multiview
  72498. * @param scene The scene we are intending to draw
  72499. * @param defines The defines to update
  72500. */
  72501. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  72502. /**
  72503. * Prepares the defines related to the light information passed in parameter
  72504. * @param scene The scene we are intending to draw
  72505. * @param mesh The mesh the effect is compiling for
  72506. * @param light The light the effect is compiling for
  72507. * @param lightIndex The index of the light
  72508. * @param defines The defines to update
  72509. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72510. * @param state Defines the current state regarding what is needed (normals, etc...)
  72511. */
  72512. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  72513. needNormals: boolean;
  72514. needRebuild: boolean;
  72515. shadowEnabled: boolean;
  72516. specularEnabled: boolean;
  72517. lightmapMode: boolean;
  72518. }): void;
  72519. /**
  72520. * Prepares the defines related to the light information passed in parameter
  72521. * @param scene The scene we are intending to draw
  72522. * @param mesh The mesh the effect is compiling for
  72523. * @param defines The defines to update
  72524. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72525. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  72526. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  72527. * @returns true if normals will be required for the rest of the effect
  72528. */
  72529. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  72530. /**
  72531. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  72532. * @param lightIndex defines the light index
  72533. * @param uniformsList The uniform list
  72534. * @param samplersList The sampler list
  72535. * @param projectedLightTexture defines if projected texture must be used
  72536. * @param uniformBuffersList defines an optional list of uniform buffers
  72537. */
  72538. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  72539. /**
  72540. * Prepares the uniforms and samplers list to be used in the effect
  72541. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  72542. * @param samplersList The sampler list
  72543. * @param defines The defines helping in the list generation
  72544. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  72545. */
  72546. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  72547. /**
  72548. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  72549. * @param defines The defines to update while falling back
  72550. * @param fallbacks The authorized effect fallbacks
  72551. * @param maxSimultaneousLights The maximum number of lights allowed
  72552. * @param rank the current rank of the Effect
  72553. * @returns The newly affected rank
  72554. */
  72555. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  72556. private static _TmpMorphInfluencers;
  72557. /**
  72558. * Prepares the list of attributes required for morph targets according to the effect defines.
  72559. * @param attribs The current list of supported attribs
  72560. * @param mesh The mesh to prepare the morph targets attributes for
  72561. * @param influencers The number of influencers
  72562. */
  72563. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  72564. /**
  72565. * Prepares the list of attributes required for morph targets according to the effect defines.
  72566. * @param attribs The current list of supported attribs
  72567. * @param mesh The mesh to prepare the morph targets attributes for
  72568. * @param defines The current Defines of the effect
  72569. */
  72570. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  72571. /**
  72572. * Prepares the list of attributes required for bones according to the effect defines.
  72573. * @param attribs The current list of supported attribs
  72574. * @param mesh The mesh to prepare the bones attributes for
  72575. * @param defines The current Defines of the effect
  72576. * @param fallbacks The current efffect fallback strategy
  72577. */
  72578. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  72579. /**
  72580. * Check and prepare the list of attributes required for instances according to the effect defines.
  72581. * @param attribs The current list of supported attribs
  72582. * @param defines The current MaterialDefines of the effect
  72583. */
  72584. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  72585. /**
  72586. * Add the list of attributes required for instances to the attribs array.
  72587. * @param attribs The current list of supported attribs
  72588. */
  72589. static PushAttributesForInstances(attribs: string[]): void;
  72590. /**
  72591. * Binds the light shadow information to the effect for the given mesh.
  72592. * @param light The light containing the generator
  72593. * @param scene The scene the lights belongs to
  72594. * @param mesh The mesh we are binding the information to render
  72595. * @param lightIndex The light index in the effect used to render the mesh
  72596. * @param effect The effect we are binding the data to
  72597. */
  72598. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  72599. /**
  72600. * Binds the light information to the effect.
  72601. * @param light The light containing the generator
  72602. * @param effect The effect we are binding the data to
  72603. * @param lightIndex The light index in the effect used to render
  72604. */
  72605. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  72606. /**
  72607. * Binds the lights information from the scene to the effect for the given mesh.
  72608. * @param light Light to bind
  72609. * @param lightIndex Light index
  72610. * @param scene The scene where the light belongs to
  72611. * @param mesh The mesh we are binding the information to render
  72612. * @param effect The effect we are binding the data to
  72613. * @param useSpecular Defines if specular is supported
  72614. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72615. */
  72616. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  72617. /**
  72618. * Binds the lights information from the scene to the effect for the given mesh.
  72619. * @param scene The scene the lights belongs to
  72620. * @param mesh The mesh we are binding the information to render
  72621. * @param effect The effect we are binding the data to
  72622. * @param defines The generated defines for the effect
  72623. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  72624. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72625. */
  72626. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  72627. private static _tempFogColor;
  72628. /**
  72629. * Binds the fog information from the scene to the effect for the given mesh.
  72630. * @param scene The scene the lights belongs to
  72631. * @param mesh The mesh we are binding the information to render
  72632. * @param effect The effect we are binding the data to
  72633. * @param linearSpace Defines if the fog effect is applied in linear space
  72634. */
  72635. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  72636. /**
  72637. * Binds the bones information from the mesh to the effect.
  72638. * @param mesh The mesh we are binding the information to render
  72639. * @param effect The effect we are binding the data to
  72640. */
  72641. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  72642. /**
  72643. * Binds the morph targets information from the mesh to the effect.
  72644. * @param abstractMesh The mesh we are binding the information to render
  72645. * @param effect The effect we are binding the data to
  72646. */
  72647. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  72648. /**
  72649. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  72650. * @param defines The generated defines used in the effect
  72651. * @param effect The effect we are binding the data to
  72652. * @param scene The scene we are willing to render with logarithmic scale for
  72653. */
  72654. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72655. /**
  72656. * Binds the clip plane information from the scene to the effect.
  72657. * @param scene The scene the clip plane information are extracted from
  72658. * @param effect The effect we are binding the data to
  72659. */
  72660. static BindClipPlane(effect: Effect, scene: Scene): void;
  72661. }
  72662. }
  72663. declare module BABYLON {
  72664. /** @hidden */
  72665. export var packingFunctions: {
  72666. name: string;
  72667. shader: string;
  72668. };
  72669. }
  72670. declare module BABYLON {
  72671. /** @hidden */
  72672. export var shadowMapPixelShader: {
  72673. name: string;
  72674. shader: string;
  72675. };
  72676. }
  72677. declare module BABYLON {
  72678. /** @hidden */
  72679. export var bonesDeclaration: {
  72680. name: string;
  72681. shader: string;
  72682. };
  72683. }
  72684. declare module BABYLON {
  72685. /** @hidden */
  72686. export var morphTargetsVertexGlobalDeclaration: {
  72687. name: string;
  72688. shader: string;
  72689. };
  72690. }
  72691. declare module BABYLON {
  72692. /** @hidden */
  72693. export var morphTargetsVertexDeclaration: {
  72694. name: string;
  72695. shader: string;
  72696. };
  72697. }
  72698. declare module BABYLON {
  72699. /** @hidden */
  72700. export var instancesDeclaration: {
  72701. name: string;
  72702. shader: string;
  72703. };
  72704. }
  72705. declare module BABYLON {
  72706. /** @hidden */
  72707. export var helperFunctions: {
  72708. name: string;
  72709. shader: string;
  72710. };
  72711. }
  72712. declare module BABYLON {
  72713. /** @hidden */
  72714. export var morphTargetsVertex: {
  72715. name: string;
  72716. shader: string;
  72717. };
  72718. }
  72719. declare module BABYLON {
  72720. /** @hidden */
  72721. export var instancesVertex: {
  72722. name: string;
  72723. shader: string;
  72724. };
  72725. }
  72726. declare module BABYLON {
  72727. /** @hidden */
  72728. export var bonesVertex: {
  72729. name: string;
  72730. shader: string;
  72731. };
  72732. }
  72733. declare module BABYLON {
  72734. /** @hidden */
  72735. export var shadowMapVertexShader: {
  72736. name: string;
  72737. shader: string;
  72738. };
  72739. }
  72740. declare module BABYLON {
  72741. /** @hidden */
  72742. export var depthBoxBlurPixelShader: {
  72743. name: string;
  72744. shader: string;
  72745. };
  72746. }
  72747. declare module BABYLON {
  72748. /**
  72749. * Defines the options associated with the creation of a custom shader for a shadow generator.
  72750. */
  72751. export interface ICustomShaderOptions {
  72752. /**
  72753. * Gets or sets the custom shader name to use
  72754. */
  72755. shaderName: string;
  72756. /**
  72757. * The list of attribute names used in the shader
  72758. */
  72759. attributes?: string[];
  72760. /**
  72761. * The list of unifrom names used in the shader
  72762. */
  72763. uniforms?: string[];
  72764. /**
  72765. * The list of sampler names used in the shader
  72766. */
  72767. samplers?: string[];
  72768. /**
  72769. * The list of defines used in the shader
  72770. */
  72771. defines?: string[];
  72772. }
  72773. /**
  72774. * Interface to implement to create a shadow generator compatible with BJS.
  72775. */
  72776. export interface IShadowGenerator {
  72777. /**
  72778. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72779. * @returns The render target texture if present otherwise, null
  72780. */
  72781. getShadowMap(): Nullable<RenderTargetTexture>;
  72782. /**
  72783. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72784. * @returns The render target texture if the shadow map is present otherwise, null
  72785. */
  72786. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72787. /**
  72788. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72789. * @param subMesh The submesh we want to render in the shadow map
  72790. * @param useInstances Defines wether will draw in the map using instances
  72791. * @returns true if ready otherwise, false
  72792. */
  72793. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72794. /**
  72795. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72796. * @param defines Defines of the material we want to update
  72797. * @param lightIndex Index of the light in the enabled light list of the material
  72798. */
  72799. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  72800. /**
  72801. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72802. * defined in the generator but impacting the effect).
  72803. * It implies the unifroms available on the materials are the standard BJS ones.
  72804. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72805. * @param effect The effect we are binfing the information for
  72806. */
  72807. bindShadowLight(lightIndex: string, effect: Effect): void;
  72808. /**
  72809. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72810. * (eq to shadow prjection matrix * light transform matrix)
  72811. * @returns The transform matrix used to create the shadow map
  72812. */
  72813. getTransformMatrix(): Matrix;
  72814. /**
  72815. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72816. * Cube and 2D textures for instance.
  72817. */
  72818. recreateShadowMap(): void;
  72819. /**
  72820. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72821. * @param onCompiled Callback triggered at the and of the effects compilation
  72822. * @param options Sets of optional options forcing the compilation with different modes
  72823. */
  72824. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72825. useInstances: boolean;
  72826. }>): void;
  72827. /**
  72828. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72829. * @param options Sets of optional options forcing the compilation with different modes
  72830. * @returns A promise that resolves when the compilation completes
  72831. */
  72832. forceCompilationAsync(options?: Partial<{
  72833. useInstances: boolean;
  72834. }>): Promise<void>;
  72835. /**
  72836. * Serializes the shadow generator setup to a json object.
  72837. * @returns The serialized JSON object
  72838. */
  72839. serialize(): any;
  72840. /**
  72841. * Disposes the Shadow map and related Textures and effects.
  72842. */
  72843. dispose(): void;
  72844. }
  72845. /**
  72846. * Default implementation IShadowGenerator.
  72847. * This is the main object responsible of generating shadows in the framework.
  72848. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  72849. */
  72850. export class ShadowGenerator implements IShadowGenerator {
  72851. /**
  72852. * Shadow generator mode None: no filtering applied.
  72853. */
  72854. static readonly FILTER_NONE: number;
  72855. /**
  72856. * Shadow generator mode ESM: Exponential Shadow Mapping.
  72857. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72858. */
  72859. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  72860. /**
  72861. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  72862. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  72863. */
  72864. static readonly FILTER_POISSONSAMPLING: number;
  72865. /**
  72866. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  72867. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72868. */
  72869. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  72870. /**
  72871. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  72872. * edge artifacts on steep falloff.
  72873. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72874. */
  72875. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  72876. /**
  72877. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  72878. * edge artifacts on steep falloff.
  72879. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72880. */
  72881. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  72882. /**
  72883. * Shadow generator mode PCF: Percentage Closer Filtering
  72884. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72885. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  72886. */
  72887. static readonly FILTER_PCF: number;
  72888. /**
  72889. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  72890. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72891. * Contact Hardening
  72892. */
  72893. static readonly FILTER_PCSS: number;
  72894. /**
  72895. * Reserved for PCF and PCSS
  72896. * Highest Quality.
  72897. *
  72898. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  72899. *
  72900. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  72901. */
  72902. static readonly QUALITY_HIGH: number;
  72903. /**
  72904. * Reserved for PCF and PCSS
  72905. * Good tradeoff for quality/perf cross devices
  72906. *
  72907. * Execute PCF on a 3*3 kernel.
  72908. *
  72909. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  72910. */
  72911. static readonly QUALITY_MEDIUM: number;
  72912. /**
  72913. * Reserved for PCF and PCSS
  72914. * The lowest quality but the fastest.
  72915. *
  72916. * Execute PCF on a 1*1 kernel.
  72917. *
  72918. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  72919. */
  72920. static readonly QUALITY_LOW: number;
  72921. /** Gets or sets the custom shader name to use */
  72922. customShaderOptions: ICustomShaderOptions;
  72923. /**
  72924. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  72925. */
  72926. onBeforeShadowMapRenderObservable: Observable<Effect>;
  72927. /**
  72928. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  72929. */
  72930. onAfterShadowMapRenderObservable: Observable<Effect>;
  72931. /**
  72932. * Observable triggered before a mesh is rendered in the shadow map.
  72933. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  72934. */
  72935. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  72936. /**
  72937. * Observable triggered after a mesh is rendered in the shadow map.
  72938. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  72939. */
  72940. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  72941. private _bias;
  72942. /**
  72943. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  72944. */
  72945. /**
  72946. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  72947. */
  72948. bias: number;
  72949. private _normalBias;
  72950. /**
  72951. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72952. */
  72953. /**
  72954. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72955. */
  72956. normalBias: number;
  72957. private _blurBoxOffset;
  72958. /**
  72959. * Gets the blur box offset: offset applied during the blur pass.
  72960. * Only useful if useKernelBlur = false
  72961. */
  72962. /**
  72963. * Sets the blur box offset: offset applied during the blur pass.
  72964. * Only useful if useKernelBlur = false
  72965. */
  72966. blurBoxOffset: number;
  72967. private _blurScale;
  72968. /**
  72969. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  72970. * 2 means half of the size.
  72971. */
  72972. /**
  72973. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  72974. * 2 means half of the size.
  72975. */
  72976. blurScale: number;
  72977. private _blurKernel;
  72978. /**
  72979. * Gets the blur kernel: kernel size of the blur pass.
  72980. * Only useful if useKernelBlur = true
  72981. */
  72982. /**
  72983. * Sets the blur kernel: kernel size of the blur pass.
  72984. * Only useful if useKernelBlur = true
  72985. */
  72986. blurKernel: number;
  72987. private _useKernelBlur;
  72988. /**
  72989. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  72990. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72991. */
  72992. /**
  72993. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  72994. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72995. */
  72996. useKernelBlur: boolean;
  72997. private _depthScale;
  72998. /**
  72999. * Gets the depth scale used in ESM mode.
  73000. */
  73001. /**
  73002. * Sets the depth scale used in ESM mode.
  73003. * This can override the scale stored on the light.
  73004. */
  73005. depthScale: number;
  73006. private _filter;
  73007. /**
  73008. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73009. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73010. */
  73011. /**
  73012. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73013. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73014. */
  73015. filter: number;
  73016. /**
  73017. * Gets if the current filter is set to Poisson Sampling.
  73018. */
  73019. /**
  73020. * Sets the current filter to Poisson Sampling.
  73021. */
  73022. usePoissonSampling: boolean;
  73023. /**
  73024. * Gets if the current filter is set to ESM.
  73025. */
  73026. /**
  73027. * Sets the current filter is to ESM.
  73028. */
  73029. useExponentialShadowMap: boolean;
  73030. /**
  73031. * Gets if the current filter is set to filtered ESM.
  73032. */
  73033. /**
  73034. * Gets if the current filter is set to filtered ESM.
  73035. */
  73036. useBlurExponentialShadowMap: boolean;
  73037. /**
  73038. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73039. * exponential to prevent steep falloff artifacts).
  73040. */
  73041. /**
  73042. * Sets the current filter to "close ESM" (using the inverse of the
  73043. * exponential to prevent steep falloff artifacts).
  73044. */
  73045. useCloseExponentialShadowMap: boolean;
  73046. /**
  73047. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73048. * exponential to prevent steep falloff artifacts).
  73049. */
  73050. /**
  73051. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73052. * exponential to prevent steep falloff artifacts).
  73053. */
  73054. useBlurCloseExponentialShadowMap: boolean;
  73055. /**
  73056. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73057. */
  73058. /**
  73059. * Sets the current filter to "PCF" (percentage closer filtering).
  73060. */
  73061. usePercentageCloserFiltering: boolean;
  73062. private _filteringQuality;
  73063. /**
  73064. * Gets the PCF or PCSS Quality.
  73065. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73066. */
  73067. /**
  73068. * Sets the PCF or PCSS Quality.
  73069. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73070. */
  73071. filteringQuality: number;
  73072. /**
  73073. * Gets if the current filter is set to "PCSS" (contact hardening).
  73074. */
  73075. /**
  73076. * Sets the current filter to "PCSS" (contact hardening).
  73077. */
  73078. useContactHardeningShadow: boolean;
  73079. private _contactHardeningLightSizeUVRatio;
  73080. /**
  73081. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73082. * Using a ratio helps keeping shape stability independently of the map size.
  73083. *
  73084. * It does not account for the light projection as it was having too much
  73085. * instability during the light setup or during light position changes.
  73086. *
  73087. * Only valid if useContactHardeningShadow is true.
  73088. */
  73089. /**
  73090. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73091. * Using a ratio helps keeping shape stability independently of the map size.
  73092. *
  73093. * It does not account for the light projection as it was having too much
  73094. * instability during the light setup or during light position changes.
  73095. *
  73096. * Only valid if useContactHardeningShadow is true.
  73097. */
  73098. contactHardeningLightSizeUVRatio: number;
  73099. private _darkness;
  73100. /** Gets or sets the actual darkness of a shadow */
  73101. darkness: number;
  73102. /**
  73103. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73104. * 0 means strongest and 1 would means no shadow.
  73105. * @returns the darkness.
  73106. */
  73107. getDarkness(): number;
  73108. /**
  73109. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73110. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73111. * @returns the shadow generator allowing fluent coding.
  73112. */
  73113. setDarkness(darkness: number): ShadowGenerator;
  73114. private _transparencyShadow;
  73115. /** Gets or sets the ability to have transparent shadow */
  73116. transparencyShadow: boolean;
  73117. /**
  73118. * Sets the ability to have transparent shadow (boolean).
  73119. * @param transparent True if transparent else False
  73120. * @returns the shadow generator allowing fluent coding
  73121. */
  73122. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73123. private _shadowMap;
  73124. private _shadowMap2;
  73125. /**
  73126. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73127. * @returns The render target texture if present otherwise, null
  73128. */
  73129. getShadowMap(): Nullable<RenderTargetTexture>;
  73130. /**
  73131. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73132. * @returns The render target texture if the shadow map is present otherwise, null
  73133. */
  73134. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73135. /**
  73136. * Gets the class name of that object
  73137. * @returns "ShadowGenerator"
  73138. */
  73139. getClassName(): string;
  73140. /**
  73141. * Helper function to add a mesh and its descendants to the list of shadow casters.
  73142. * @param mesh Mesh to add
  73143. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  73144. * @returns the Shadow Generator itself
  73145. */
  73146. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73147. /**
  73148. * Helper function to remove a mesh and its descendants from the list of shadow casters
  73149. * @param mesh Mesh to remove
  73150. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  73151. * @returns the Shadow Generator itself
  73152. */
  73153. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73154. /**
  73155. * Controls the extent to which the shadows fade out at the edge of the frustum
  73156. * Used only by directionals and spots
  73157. */
  73158. frustumEdgeFalloff: number;
  73159. private _light;
  73160. /**
  73161. * Returns the associated light object.
  73162. * @returns the light generating the shadow
  73163. */
  73164. getLight(): IShadowLight;
  73165. /**
  73166. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  73167. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  73168. * It might on the other hand introduce peter panning.
  73169. */
  73170. forceBackFacesOnly: boolean;
  73171. private _scene;
  73172. private _lightDirection;
  73173. private _effect;
  73174. private _viewMatrix;
  73175. private _projectionMatrix;
  73176. private _transformMatrix;
  73177. private _cachedPosition;
  73178. private _cachedDirection;
  73179. private _cachedDefines;
  73180. private _currentRenderID;
  73181. private _boxBlurPostprocess;
  73182. private _kernelBlurXPostprocess;
  73183. private _kernelBlurYPostprocess;
  73184. private _blurPostProcesses;
  73185. private _mapSize;
  73186. private _currentFaceIndex;
  73187. private _currentFaceIndexCache;
  73188. private _textureType;
  73189. private _defaultTextureMatrix;
  73190. /** @hidden */
  73191. static _SceneComponentInitialization: (scene: Scene) => void;
  73192. /**
  73193. * Creates a ShadowGenerator object.
  73194. * A ShadowGenerator is the required tool to use the shadows.
  73195. * Each light casting shadows needs to use its own ShadowGenerator.
  73196. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  73197. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  73198. * @param light The light object generating the shadows.
  73199. * @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.
  73200. */
  73201. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  73202. private _initializeGenerator;
  73203. private _initializeShadowMap;
  73204. private _initializeBlurRTTAndPostProcesses;
  73205. private _renderForShadowMap;
  73206. private _renderSubMeshForShadowMap;
  73207. private _applyFilterValues;
  73208. /**
  73209. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73210. * @param onCompiled Callback triggered at the and of the effects compilation
  73211. * @param options Sets of optional options forcing the compilation with different modes
  73212. */
  73213. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73214. useInstances: boolean;
  73215. }>): void;
  73216. /**
  73217. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73218. * @param options Sets of optional options forcing the compilation with different modes
  73219. * @returns A promise that resolves when the compilation completes
  73220. */
  73221. forceCompilationAsync(options?: Partial<{
  73222. useInstances: boolean;
  73223. }>): Promise<void>;
  73224. /**
  73225. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73226. * @param subMesh The submesh we want to render in the shadow map
  73227. * @param useInstances Defines wether will draw in the map using instances
  73228. * @returns true if ready otherwise, false
  73229. */
  73230. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73231. /**
  73232. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73233. * @param defines Defines of the material we want to update
  73234. * @param lightIndex Index of the light in the enabled light list of the material
  73235. */
  73236. prepareDefines(defines: any, lightIndex: number): void;
  73237. /**
  73238. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73239. * defined in the generator but impacting the effect).
  73240. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73241. * @param effect The effect we are binfing the information for
  73242. */
  73243. bindShadowLight(lightIndex: string, effect: Effect): void;
  73244. /**
  73245. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73246. * (eq to shadow prjection matrix * light transform matrix)
  73247. * @returns The transform matrix used to create the shadow map
  73248. */
  73249. getTransformMatrix(): Matrix;
  73250. /**
  73251. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73252. * Cube and 2D textures for instance.
  73253. */
  73254. recreateShadowMap(): void;
  73255. private _disposeBlurPostProcesses;
  73256. private _disposeRTTandPostProcesses;
  73257. /**
  73258. * Disposes the ShadowGenerator.
  73259. * Returns nothing.
  73260. */
  73261. dispose(): void;
  73262. /**
  73263. * Serializes the shadow generator setup to a json object.
  73264. * @returns The serialized JSON object
  73265. */
  73266. serialize(): any;
  73267. /**
  73268. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  73269. * @param parsedShadowGenerator The JSON object to parse
  73270. * @param scene The scene to create the shadow map for
  73271. * @returns The parsed shadow generator
  73272. */
  73273. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  73274. }
  73275. }
  73276. declare module BABYLON {
  73277. /**
  73278. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  73279. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  73280. * 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.
  73281. */
  73282. export abstract class Light extends Node {
  73283. /**
  73284. * Falloff Default: light is falling off following the material specification:
  73285. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  73286. */
  73287. static readonly FALLOFF_DEFAULT: number;
  73288. /**
  73289. * Falloff Physical: light is falling off following the inverse squared distance law.
  73290. */
  73291. static readonly FALLOFF_PHYSICAL: number;
  73292. /**
  73293. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  73294. * to enhance interoperability with other engines.
  73295. */
  73296. static readonly FALLOFF_GLTF: number;
  73297. /**
  73298. * Falloff Standard: light is falling off like in the standard material
  73299. * to enhance interoperability with other materials.
  73300. */
  73301. static readonly FALLOFF_STANDARD: number;
  73302. /**
  73303. * If every light affecting the material is in this lightmapMode,
  73304. * material.lightmapTexture adds or multiplies
  73305. * (depends on material.useLightmapAsShadowmap)
  73306. * after every other light calculations.
  73307. */
  73308. static readonly LIGHTMAP_DEFAULT: number;
  73309. /**
  73310. * material.lightmapTexture as only diffuse lighting from this light
  73311. * adds only specular lighting from this light
  73312. * adds dynamic shadows
  73313. */
  73314. static readonly LIGHTMAP_SPECULAR: number;
  73315. /**
  73316. * material.lightmapTexture as only lighting
  73317. * no light calculation from this light
  73318. * only adds dynamic shadows from this light
  73319. */
  73320. static readonly LIGHTMAP_SHADOWSONLY: number;
  73321. /**
  73322. * Each light type uses the default quantity according to its type:
  73323. * point/spot lights use luminous intensity
  73324. * directional lights use illuminance
  73325. */
  73326. static readonly INTENSITYMODE_AUTOMATIC: number;
  73327. /**
  73328. * lumen (lm)
  73329. */
  73330. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  73331. /**
  73332. * candela (lm/sr)
  73333. */
  73334. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  73335. /**
  73336. * lux (lm/m^2)
  73337. */
  73338. static readonly INTENSITYMODE_ILLUMINANCE: number;
  73339. /**
  73340. * nit (cd/m^2)
  73341. */
  73342. static readonly INTENSITYMODE_LUMINANCE: number;
  73343. /**
  73344. * Light type const id of the point light.
  73345. */
  73346. static readonly LIGHTTYPEID_POINTLIGHT: number;
  73347. /**
  73348. * Light type const id of the directional light.
  73349. */
  73350. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  73351. /**
  73352. * Light type const id of the spot light.
  73353. */
  73354. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  73355. /**
  73356. * Light type const id of the hemispheric light.
  73357. */
  73358. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  73359. /**
  73360. * Diffuse gives the basic color to an object.
  73361. */
  73362. diffuse: Color3;
  73363. /**
  73364. * Specular produces a highlight color on an object.
  73365. * Note: This is note affecting PBR materials.
  73366. */
  73367. specular: Color3;
  73368. /**
  73369. * Defines the falloff type for this light. This lets overrriding how punctual light are
  73370. * falling off base on range or angle.
  73371. * This can be set to any values in Light.FALLOFF_x.
  73372. *
  73373. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  73374. * other types of materials.
  73375. */
  73376. falloffType: number;
  73377. /**
  73378. * Strength of the light.
  73379. * Note: By default it is define in the framework own unit.
  73380. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  73381. */
  73382. intensity: number;
  73383. private _range;
  73384. protected _inverseSquaredRange: number;
  73385. /**
  73386. * Defines how far from the source the light is impacting in scene units.
  73387. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73388. */
  73389. /**
  73390. * Defines how far from the source the light is impacting in scene units.
  73391. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73392. */
  73393. range: number;
  73394. /**
  73395. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  73396. * of light.
  73397. */
  73398. private _photometricScale;
  73399. private _intensityMode;
  73400. /**
  73401. * Gets the photometric scale used to interpret the intensity.
  73402. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73403. */
  73404. /**
  73405. * Sets the photometric scale used to interpret the intensity.
  73406. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73407. */
  73408. intensityMode: number;
  73409. private _radius;
  73410. /**
  73411. * Gets the light radius used by PBR Materials to simulate soft area lights.
  73412. */
  73413. /**
  73414. * sets the light radius used by PBR Materials to simulate soft area lights.
  73415. */
  73416. radius: number;
  73417. private _renderPriority;
  73418. /**
  73419. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  73420. * exceeding the number allowed of the materials.
  73421. */
  73422. renderPriority: number;
  73423. private _shadowEnabled;
  73424. /**
  73425. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73426. * the current shadow generator.
  73427. */
  73428. /**
  73429. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73430. * the current shadow generator.
  73431. */
  73432. shadowEnabled: boolean;
  73433. private _includedOnlyMeshes;
  73434. /**
  73435. * Gets the only meshes impacted by this light.
  73436. */
  73437. /**
  73438. * Sets the only meshes impacted by this light.
  73439. */
  73440. includedOnlyMeshes: AbstractMesh[];
  73441. private _excludedMeshes;
  73442. /**
  73443. * Gets the meshes not impacted by this light.
  73444. */
  73445. /**
  73446. * Sets the meshes not impacted by this light.
  73447. */
  73448. excludedMeshes: AbstractMesh[];
  73449. private _excludeWithLayerMask;
  73450. /**
  73451. * Gets the layer id use to find what meshes are not impacted by the light.
  73452. * Inactive if 0
  73453. */
  73454. /**
  73455. * Sets the layer id use to find what meshes are not impacted by the light.
  73456. * Inactive if 0
  73457. */
  73458. excludeWithLayerMask: number;
  73459. private _includeOnlyWithLayerMask;
  73460. /**
  73461. * Gets the layer id use to find what meshes are impacted by the light.
  73462. * Inactive if 0
  73463. */
  73464. /**
  73465. * Sets the layer id use to find what meshes are impacted by the light.
  73466. * Inactive if 0
  73467. */
  73468. includeOnlyWithLayerMask: number;
  73469. private _lightmapMode;
  73470. /**
  73471. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73472. */
  73473. /**
  73474. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73475. */
  73476. lightmapMode: number;
  73477. /**
  73478. * Shadow generator associted to the light.
  73479. * @hidden Internal use only.
  73480. */
  73481. _shadowGenerator: Nullable<IShadowGenerator>;
  73482. /**
  73483. * @hidden Internal use only.
  73484. */
  73485. _excludedMeshesIds: string[];
  73486. /**
  73487. * @hidden Internal use only.
  73488. */
  73489. _includedOnlyMeshesIds: string[];
  73490. /**
  73491. * The current light unifom buffer.
  73492. * @hidden Internal use only.
  73493. */
  73494. _uniformBuffer: UniformBuffer;
  73495. /**
  73496. * Creates a Light object in the scene.
  73497. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73498. * @param name The firendly name of the light
  73499. * @param scene The scene the light belongs too
  73500. */
  73501. constructor(name: string, scene: Scene);
  73502. protected abstract _buildUniformLayout(): void;
  73503. /**
  73504. * Sets the passed Effect "effect" with the Light information.
  73505. * @param effect The effect to update
  73506. * @param lightIndex The index of the light in the effect to update
  73507. * @returns The light
  73508. */
  73509. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  73510. /**
  73511. * Returns the string "Light".
  73512. * @returns the class name
  73513. */
  73514. getClassName(): string;
  73515. /** @hidden */
  73516. readonly _isLight: boolean;
  73517. /**
  73518. * Converts the light information to a readable string for debug purpose.
  73519. * @param fullDetails Supports for multiple levels of logging within scene loading
  73520. * @returns the human readable light info
  73521. */
  73522. toString(fullDetails?: boolean): string;
  73523. /** @hidden */
  73524. protected _syncParentEnabledState(): void;
  73525. /**
  73526. * Set the enabled state of this node.
  73527. * @param value - the new enabled state
  73528. */
  73529. setEnabled(value: boolean): void;
  73530. /**
  73531. * Returns the Light associated shadow generator if any.
  73532. * @return the associated shadow generator.
  73533. */
  73534. getShadowGenerator(): Nullable<IShadowGenerator>;
  73535. /**
  73536. * Returns a Vector3, the absolute light position in the World.
  73537. * @returns the world space position of the light
  73538. */
  73539. getAbsolutePosition(): Vector3;
  73540. /**
  73541. * Specifies if the light will affect the passed mesh.
  73542. * @param mesh The mesh to test against the light
  73543. * @return true the mesh is affected otherwise, false.
  73544. */
  73545. canAffectMesh(mesh: AbstractMesh): boolean;
  73546. /**
  73547. * Sort function to order lights for rendering.
  73548. * @param a First Light object to compare to second.
  73549. * @param b Second Light object to compare first.
  73550. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73551. */
  73552. static CompareLightsPriority(a: Light, b: Light): number;
  73553. /**
  73554. * Releases resources associated with this node.
  73555. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73556. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73557. */
  73558. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73559. /**
  73560. * Returns the light type ID (integer).
  73561. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73562. */
  73563. getTypeID(): number;
  73564. /**
  73565. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73566. * @returns the scaled intensity in intensity mode unit
  73567. */
  73568. getScaledIntensity(): number;
  73569. /**
  73570. * Returns a new Light object, named "name", from the current one.
  73571. * @param name The name of the cloned light
  73572. * @returns the new created light
  73573. */
  73574. clone(name: string): Nullable<Light>;
  73575. /**
  73576. * Serializes the current light into a Serialization object.
  73577. * @returns the serialized object.
  73578. */
  73579. serialize(): any;
  73580. /**
  73581. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73582. * This new light is named "name" and added to the passed scene.
  73583. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73584. * @param name The friendly name of the light
  73585. * @param scene The scene the new light will belong to
  73586. * @returns the constructor function
  73587. */
  73588. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73589. /**
  73590. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73591. * @param parsedLight The JSON representation of the light
  73592. * @param scene The scene to create the parsed light in
  73593. * @returns the created light after parsing
  73594. */
  73595. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73596. private _hookArrayForExcluded;
  73597. private _hookArrayForIncludedOnly;
  73598. private _resyncMeshes;
  73599. /**
  73600. * Forces the meshes to update their light related information in their rendering used effects
  73601. * @hidden Internal Use Only
  73602. */
  73603. _markMeshesAsLightDirty(): void;
  73604. /**
  73605. * Recomputes the cached photometric scale if needed.
  73606. */
  73607. private _computePhotometricScale;
  73608. /**
  73609. * Returns the Photometric Scale according to the light type and intensity mode.
  73610. */
  73611. private _getPhotometricScale;
  73612. /**
  73613. * Reorder the light in the scene according to their defined priority.
  73614. * @hidden Internal Use Only
  73615. */
  73616. _reorderLightsInScene(): void;
  73617. /**
  73618. * Prepares the list of defines specific to the light type.
  73619. * @param defines the list of defines
  73620. * @param lightIndex defines the index of the light for the effect
  73621. */
  73622. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73623. }
  73624. }
  73625. declare module BABYLON {
  73626. /**
  73627. * Interface used to define Action
  73628. */
  73629. export interface IAction {
  73630. /**
  73631. * Trigger for the action
  73632. */
  73633. trigger: number;
  73634. /** Options of the trigger */
  73635. triggerOptions: any;
  73636. /**
  73637. * Gets the trigger parameters
  73638. * @returns the trigger parameters
  73639. */
  73640. getTriggerParameter(): any;
  73641. /**
  73642. * Internal only - executes current action event
  73643. * @hidden
  73644. */
  73645. _executeCurrent(evt?: ActionEvent): void;
  73646. /**
  73647. * Serialize placeholder for child classes
  73648. * @param parent of child
  73649. * @returns the serialized object
  73650. */
  73651. serialize(parent: any): any;
  73652. /**
  73653. * Internal only
  73654. * @hidden
  73655. */
  73656. _prepare(): void;
  73657. /**
  73658. * Internal only - manager for action
  73659. * @hidden
  73660. */
  73661. _actionManager: AbstractActionManager;
  73662. /**
  73663. * Adds action to chain of actions, may be a DoNothingAction
  73664. * @param action defines the next action to execute
  73665. * @returns The action passed in
  73666. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73667. */
  73668. then(action: IAction): IAction;
  73669. }
  73670. /**
  73671. * The action to be carried out following a trigger
  73672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73673. */
  73674. export class Action implements IAction {
  73675. /** the trigger, with or without parameters, for the action */
  73676. triggerOptions: any;
  73677. /**
  73678. * Trigger for the action
  73679. */
  73680. trigger: number;
  73681. /**
  73682. * Internal only - manager for action
  73683. * @hidden
  73684. */
  73685. _actionManager: ActionManager;
  73686. private _nextActiveAction;
  73687. private _child;
  73688. private _condition?;
  73689. private _triggerParameter;
  73690. /**
  73691. * An event triggered prior to action being executed.
  73692. */
  73693. onBeforeExecuteObservable: Observable<Action>;
  73694. /**
  73695. * Creates a new Action
  73696. * @param triggerOptions the trigger, with or without parameters, for the action
  73697. * @param condition an optional determinant of action
  73698. */
  73699. constructor(
  73700. /** the trigger, with or without parameters, for the action */
  73701. triggerOptions: any, condition?: Condition);
  73702. /**
  73703. * Internal only
  73704. * @hidden
  73705. */
  73706. _prepare(): void;
  73707. /**
  73708. * Gets the trigger parameters
  73709. * @returns the trigger parameters
  73710. */
  73711. getTriggerParameter(): any;
  73712. /**
  73713. * Internal only - executes current action event
  73714. * @hidden
  73715. */
  73716. _executeCurrent(evt?: ActionEvent): void;
  73717. /**
  73718. * Execute placeholder for child classes
  73719. * @param evt optional action event
  73720. */
  73721. execute(evt?: ActionEvent): void;
  73722. /**
  73723. * Skips to next active action
  73724. */
  73725. skipToNextActiveAction(): void;
  73726. /**
  73727. * Adds action to chain of actions, may be a DoNothingAction
  73728. * @param action defines the next action to execute
  73729. * @returns The action passed in
  73730. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73731. */
  73732. then(action: Action): Action;
  73733. /**
  73734. * Internal only
  73735. * @hidden
  73736. */
  73737. _getProperty(propertyPath: string): string;
  73738. /**
  73739. * Internal only
  73740. * @hidden
  73741. */
  73742. _getEffectiveTarget(target: any, propertyPath: string): any;
  73743. /**
  73744. * Serialize placeholder for child classes
  73745. * @param parent of child
  73746. * @returns the serialized object
  73747. */
  73748. serialize(parent: any): any;
  73749. /**
  73750. * Internal only called by serialize
  73751. * @hidden
  73752. */
  73753. protected _serialize(serializedAction: any, parent?: any): any;
  73754. /**
  73755. * Internal only
  73756. * @hidden
  73757. */
  73758. static _SerializeValueAsString: (value: any) => string;
  73759. /**
  73760. * Internal only
  73761. * @hidden
  73762. */
  73763. static _GetTargetProperty: (target: Node | Scene) => {
  73764. name: string;
  73765. targetType: string;
  73766. value: string;
  73767. };
  73768. }
  73769. }
  73770. declare module BABYLON {
  73771. /**
  73772. * A Condition applied to an Action
  73773. */
  73774. export class Condition {
  73775. /**
  73776. * Internal only - manager for action
  73777. * @hidden
  73778. */
  73779. _actionManager: ActionManager;
  73780. /**
  73781. * Internal only
  73782. * @hidden
  73783. */
  73784. _evaluationId: number;
  73785. /**
  73786. * Internal only
  73787. * @hidden
  73788. */
  73789. _currentResult: boolean;
  73790. /**
  73791. * Creates a new Condition
  73792. * @param actionManager the manager of the action the condition is applied to
  73793. */
  73794. constructor(actionManager: ActionManager);
  73795. /**
  73796. * Check if the current condition is valid
  73797. * @returns a boolean
  73798. */
  73799. isValid(): boolean;
  73800. /**
  73801. * Internal only
  73802. * @hidden
  73803. */
  73804. _getProperty(propertyPath: string): string;
  73805. /**
  73806. * Internal only
  73807. * @hidden
  73808. */
  73809. _getEffectiveTarget(target: any, propertyPath: string): any;
  73810. /**
  73811. * Serialize placeholder for child classes
  73812. * @returns the serialized object
  73813. */
  73814. serialize(): any;
  73815. /**
  73816. * Internal only
  73817. * @hidden
  73818. */
  73819. protected _serialize(serializedCondition: any): any;
  73820. }
  73821. /**
  73822. * Defines specific conditional operators as extensions of Condition
  73823. */
  73824. export class ValueCondition extends Condition {
  73825. /** path to specify the property of the target the conditional operator uses */
  73826. propertyPath: string;
  73827. /** the value compared by the conditional operator against the current value of the property */
  73828. value: any;
  73829. /** the conditional operator, default ValueCondition.IsEqual */
  73830. operator: number;
  73831. /**
  73832. * Internal only
  73833. * @hidden
  73834. */
  73835. private static _IsEqual;
  73836. /**
  73837. * Internal only
  73838. * @hidden
  73839. */
  73840. private static _IsDifferent;
  73841. /**
  73842. * Internal only
  73843. * @hidden
  73844. */
  73845. private static _IsGreater;
  73846. /**
  73847. * Internal only
  73848. * @hidden
  73849. */
  73850. private static _IsLesser;
  73851. /**
  73852. * returns the number for IsEqual
  73853. */
  73854. static readonly IsEqual: number;
  73855. /**
  73856. * Returns the number for IsDifferent
  73857. */
  73858. static readonly IsDifferent: number;
  73859. /**
  73860. * Returns the number for IsGreater
  73861. */
  73862. static readonly IsGreater: number;
  73863. /**
  73864. * Returns the number for IsLesser
  73865. */
  73866. static readonly IsLesser: number;
  73867. /**
  73868. * Internal only The action manager for the condition
  73869. * @hidden
  73870. */
  73871. _actionManager: ActionManager;
  73872. /**
  73873. * Internal only
  73874. * @hidden
  73875. */
  73876. private _target;
  73877. /**
  73878. * Internal only
  73879. * @hidden
  73880. */
  73881. private _effectiveTarget;
  73882. /**
  73883. * Internal only
  73884. * @hidden
  73885. */
  73886. private _property;
  73887. /**
  73888. * Creates a new ValueCondition
  73889. * @param actionManager manager for the action the condition applies to
  73890. * @param target for the action
  73891. * @param propertyPath path to specify the property of the target the conditional operator uses
  73892. * @param value the value compared by the conditional operator against the current value of the property
  73893. * @param operator the conditional operator, default ValueCondition.IsEqual
  73894. */
  73895. constructor(actionManager: ActionManager, target: any,
  73896. /** path to specify the property of the target the conditional operator uses */
  73897. propertyPath: string,
  73898. /** the value compared by the conditional operator against the current value of the property */
  73899. value: any,
  73900. /** the conditional operator, default ValueCondition.IsEqual */
  73901. operator?: number);
  73902. /**
  73903. * Compares the given value with the property value for the specified conditional operator
  73904. * @returns the result of the comparison
  73905. */
  73906. isValid(): boolean;
  73907. /**
  73908. * Serialize the ValueCondition into a JSON compatible object
  73909. * @returns serialization object
  73910. */
  73911. serialize(): any;
  73912. /**
  73913. * Gets the name of the conditional operator for the ValueCondition
  73914. * @param operator the conditional operator
  73915. * @returns the name
  73916. */
  73917. static GetOperatorName(operator: number): string;
  73918. }
  73919. /**
  73920. * Defines a predicate condition as an extension of Condition
  73921. */
  73922. export class PredicateCondition extends Condition {
  73923. /** defines the predicate function used to validate the condition */
  73924. predicate: () => boolean;
  73925. /**
  73926. * Internal only - manager for action
  73927. * @hidden
  73928. */
  73929. _actionManager: ActionManager;
  73930. /**
  73931. * Creates a new PredicateCondition
  73932. * @param actionManager manager for the action the condition applies to
  73933. * @param predicate defines the predicate function used to validate the condition
  73934. */
  73935. constructor(actionManager: ActionManager,
  73936. /** defines the predicate function used to validate the condition */
  73937. predicate: () => boolean);
  73938. /**
  73939. * @returns the validity of the predicate condition
  73940. */
  73941. isValid(): boolean;
  73942. }
  73943. /**
  73944. * Defines a state condition as an extension of Condition
  73945. */
  73946. export class StateCondition extends Condition {
  73947. /** Value to compare with target state */
  73948. value: string;
  73949. /**
  73950. * Internal only - manager for action
  73951. * @hidden
  73952. */
  73953. _actionManager: ActionManager;
  73954. /**
  73955. * Internal only
  73956. * @hidden
  73957. */
  73958. private _target;
  73959. /**
  73960. * Creates a new StateCondition
  73961. * @param actionManager manager for the action the condition applies to
  73962. * @param target of the condition
  73963. * @param value to compare with target state
  73964. */
  73965. constructor(actionManager: ActionManager, target: any,
  73966. /** Value to compare with target state */
  73967. value: string);
  73968. /**
  73969. * Gets a boolean indicating if the current condition is met
  73970. * @returns the validity of the state
  73971. */
  73972. isValid(): boolean;
  73973. /**
  73974. * Serialize the StateCondition into a JSON compatible object
  73975. * @returns serialization object
  73976. */
  73977. serialize(): any;
  73978. }
  73979. }
  73980. declare module BABYLON {
  73981. /**
  73982. * This defines an action responsible to toggle a boolean once triggered.
  73983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73984. */
  73985. export class SwitchBooleanAction extends Action {
  73986. /**
  73987. * The path to the boolean property in the target object
  73988. */
  73989. propertyPath: string;
  73990. private _target;
  73991. private _effectiveTarget;
  73992. private _property;
  73993. /**
  73994. * Instantiate the action
  73995. * @param triggerOptions defines the trigger options
  73996. * @param target defines the object containing the boolean
  73997. * @param propertyPath defines the path to the boolean property in the target object
  73998. * @param condition defines the trigger related conditions
  73999. */
  74000. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74001. /** @hidden */
  74002. _prepare(): void;
  74003. /**
  74004. * Execute the action toggle the boolean value.
  74005. */
  74006. execute(): void;
  74007. /**
  74008. * Serializes the actions and its related information.
  74009. * @param parent defines the object to serialize in
  74010. * @returns the serialized object
  74011. */
  74012. serialize(parent: any): any;
  74013. }
  74014. /**
  74015. * This defines an action responsible to set a the state field of the target
  74016. * to a desired value once triggered.
  74017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74018. */
  74019. export class SetStateAction extends Action {
  74020. /**
  74021. * The value to store in the state field.
  74022. */
  74023. value: string;
  74024. private _target;
  74025. /**
  74026. * Instantiate the action
  74027. * @param triggerOptions defines the trigger options
  74028. * @param target defines the object containing the state property
  74029. * @param value defines the value to store in the state field
  74030. * @param condition defines the trigger related conditions
  74031. */
  74032. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74033. /**
  74034. * Execute the action and store the value on the target state property.
  74035. */
  74036. execute(): void;
  74037. /**
  74038. * Serializes the actions and its related information.
  74039. * @param parent defines the object to serialize in
  74040. * @returns the serialized object
  74041. */
  74042. serialize(parent: any): any;
  74043. }
  74044. /**
  74045. * This defines an action responsible to set a property of the target
  74046. * to a desired value once triggered.
  74047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74048. */
  74049. export class SetValueAction extends Action {
  74050. /**
  74051. * The path of the property to set in the target.
  74052. */
  74053. propertyPath: string;
  74054. /**
  74055. * The value to set in the property
  74056. */
  74057. value: any;
  74058. private _target;
  74059. private _effectiveTarget;
  74060. private _property;
  74061. /**
  74062. * Instantiate the action
  74063. * @param triggerOptions defines the trigger options
  74064. * @param target defines the object containing the property
  74065. * @param propertyPath defines the path of the property to set in the target
  74066. * @param value defines the value to set in the property
  74067. * @param condition defines the trigger related conditions
  74068. */
  74069. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74070. /** @hidden */
  74071. _prepare(): void;
  74072. /**
  74073. * Execute the action and set the targetted property to the desired value.
  74074. */
  74075. execute(): void;
  74076. /**
  74077. * Serializes the actions and its related information.
  74078. * @param parent defines the object to serialize in
  74079. * @returns the serialized object
  74080. */
  74081. serialize(parent: any): any;
  74082. }
  74083. /**
  74084. * This defines an action responsible to increment the target value
  74085. * to a desired value once triggered.
  74086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74087. */
  74088. export class IncrementValueAction extends Action {
  74089. /**
  74090. * The path of the property to increment in the target.
  74091. */
  74092. propertyPath: string;
  74093. /**
  74094. * The value we should increment the property by.
  74095. */
  74096. value: any;
  74097. private _target;
  74098. private _effectiveTarget;
  74099. private _property;
  74100. /**
  74101. * Instantiate the action
  74102. * @param triggerOptions defines the trigger options
  74103. * @param target defines the object containing the property
  74104. * @param propertyPath defines the path of the property to increment in the target
  74105. * @param value defines the value value we should increment the property by
  74106. * @param condition defines the trigger related conditions
  74107. */
  74108. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74109. /** @hidden */
  74110. _prepare(): void;
  74111. /**
  74112. * Execute the action and increment the target of the value amount.
  74113. */
  74114. execute(): void;
  74115. /**
  74116. * Serializes the actions and its related information.
  74117. * @param parent defines the object to serialize in
  74118. * @returns the serialized object
  74119. */
  74120. serialize(parent: any): any;
  74121. }
  74122. /**
  74123. * This defines an action responsible to start an animation once triggered.
  74124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74125. */
  74126. export class PlayAnimationAction extends Action {
  74127. /**
  74128. * Where the animation should start (animation frame)
  74129. */
  74130. from: number;
  74131. /**
  74132. * Where the animation should stop (animation frame)
  74133. */
  74134. to: number;
  74135. /**
  74136. * Define if the animation should loop or stop after the first play.
  74137. */
  74138. loop?: boolean;
  74139. private _target;
  74140. /**
  74141. * Instantiate the action
  74142. * @param triggerOptions defines the trigger options
  74143. * @param target defines the target animation or animation name
  74144. * @param from defines from where the animation should start (animation frame)
  74145. * @param end defines where the animation should stop (animation frame)
  74146. * @param loop defines if the animation should loop or stop after the first play
  74147. * @param condition defines the trigger related conditions
  74148. */
  74149. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  74150. /** @hidden */
  74151. _prepare(): void;
  74152. /**
  74153. * Execute the action and play the animation.
  74154. */
  74155. execute(): void;
  74156. /**
  74157. * Serializes the actions and its related information.
  74158. * @param parent defines the object to serialize in
  74159. * @returns the serialized object
  74160. */
  74161. serialize(parent: any): any;
  74162. }
  74163. /**
  74164. * This defines an action responsible to stop an animation once triggered.
  74165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74166. */
  74167. export class StopAnimationAction extends Action {
  74168. private _target;
  74169. /**
  74170. * Instantiate the action
  74171. * @param triggerOptions defines the trigger options
  74172. * @param target defines the target animation or animation name
  74173. * @param condition defines the trigger related conditions
  74174. */
  74175. constructor(triggerOptions: any, target: any, condition?: Condition);
  74176. /** @hidden */
  74177. _prepare(): void;
  74178. /**
  74179. * Execute the action and stop the animation.
  74180. */
  74181. execute(): void;
  74182. /**
  74183. * Serializes the actions and its related information.
  74184. * @param parent defines the object to serialize in
  74185. * @returns the serialized object
  74186. */
  74187. serialize(parent: any): any;
  74188. }
  74189. /**
  74190. * This defines an action responsible that does nothing once triggered.
  74191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74192. */
  74193. export class DoNothingAction extends Action {
  74194. /**
  74195. * Instantiate the action
  74196. * @param triggerOptions defines the trigger options
  74197. * @param condition defines the trigger related conditions
  74198. */
  74199. constructor(triggerOptions?: any, condition?: Condition);
  74200. /**
  74201. * Execute the action and do nothing.
  74202. */
  74203. execute(): void;
  74204. /**
  74205. * Serializes the actions and its related information.
  74206. * @param parent defines the object to serialize in
  74207. * @returns the serialized object
  74208. */
  74209. serialize(parent: any): any;
  74210. }
  74211. /**
  74212. * This defines an action responsible to trigger several actions once triggered.
  74213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74214. */
  74215. export class CombineAction extends Action {
  74216. /**
  74217. * The list of aggregated animations to run.
  74218. */
  74219. children: Action[];
  74220. /**
  74221. * Instantiate the action
  74222. * @param triggerOptions defines the trigger options
  74223. * @param children defines the list of aggregated animations to run
  74224. * @param condition defines the trigger related conditions
  74225. */
  74226. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  74227. /** @hidden */
  74228. _prepare(): void;
  74229. /**
  74230. * Execute the action and executes all the aggregated actions.
  74231. */
  74232. execute(evt: ActionEvent): void;
  74233. /**
  74234. * Serializes the actions and its related information.
  74235. * @param parent defines the object to serialize in
  74236. * @returns the serialized object
  74237. */
  74238. serialize(parent: any): any;
  74239. }
  74240. /**
  74241. * This defines an action responsible to run code (external event) once triggered.
  74242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74243. */
  74244. export class ExecuteCodeAction extends Action {
  74245. /**
  74246. * The callback function to run.
  74247. */
  74248. func: (evt: ActionEvent) => void;
  74249. /**
  74250. * Instantiate the action
  74251. * @param triggerOptions defines the trigger options
  74252. * @param func defines the callback function to run
  74253. * @param condition defines the trigger related conditions
  74254. */
  74255. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  74256. /**
  74257. * Execute the action and run the attached code.
  74258. */
  74259. execute(evt: ActionEvent): void;
  74260. }
  74261. /**
  74262. * This defines an action responsible to set the parent property of the target once triggered.
  74263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74264. */
  74265. export class SetParentAction extends Action {
  74266. private _parent;
  74267. private _target;
  74268. /**
  74269. * Instantiate the action
  74270. * @param triggerOptions defines the trigger options
  74271. * @param target defines the target containing the parent property
  74272. * @param parent defines from where the animation should start (animation frame)
  74273. * @param condition defines the trigger related conditions
  74274. */
  74275. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  74276. /** @hidden */
  74277. _prepare(): void;
  74278. /**
  74279. * Execute the action and set the parent property.
  74280. */
  74281. execute(): void;
  74282. /**
  74283. * Serializes the actions and its related information.
  74284. * @param parent defines the object to serialize in
  74285. * @returns the serialized object
  74286. */
  74287. serialize(parent: any): any;
  74288. }
  74289. }
  74290. declare module BABYLON {
  74291. /**
  74292. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  74293. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  74294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74295. */
  74296. export class ActionManager extends AbstractActionManager {
  74297. /**
  74298. * Nothing
  74299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74300. */
  74301. static readonly NothingTrigger: number;
  74302. /**
  74303. * On pick
  74304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74305. */
  74306. static readonly OnPickTrigger: number;
  74307. /**
  74308. * On left pick
  74309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74310. */
  74311. static readonly OnLeftPickTrigger: number;
  74312. /**
  74313. * On right pick
  74314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74315. */
  74316. static readonly OnRightPickTrigger: number;
  74317. /**
  74318. * On center pick
  74319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74320. */
  74321. static readonly OnCenterPickTrigger: number;
  74322. /**
  74323. * On pick down
  74324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74325. */
  74326. static readonly OnPickDownTrigger: number;
  74327. /**
  74328. * On double pick
  74329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74330. */
  74331. static readonly OnDoublePickTrigger: number;
  74332. /**
  74333. * On pick up
  74334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74335. */
  74336. static readonly OnPickUpTrigger: number;
  74337. /**
  74338. * On pick out.
  74339. * This trigger will only be raised if you also declared a OnPickDown
  74340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74341. */
  74342. static readonly OnPickOutTrigger: number;
  74343. /**
  74344. * On long press
  74345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74346. */
  74347. static readonly OnLongPressTrigger: number;
  74348. /**
  74349. * On pointer over
  74350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74351. */
  74352. static readonly OnPointerOverTrigger: number;
  74353. /**
  74354. * On pointer out
  74355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74356. */
  74357. static readonly OnPointerOutTrigger: number;
  74358. /**
  74359. * On every frame
  74360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74361. */
  74362. static readonly OnEveryFrameTrigger: number;
  74363. /**
  74364. * On intersection enter
  74365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74366. */
  74367. static readonly OnIntersectionEnterTrigger: number;
  74368. /**
  74369. * On intersection exit
  74370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74371. */
  74372. static readonly OnIntersectionExitTrigger: number;
  74373. /**
  74374. * On key down
  74375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74376. */
  74377. static readonly OnKeyDownTrigger: number;
  74378. /**
  74379. * On key up
  74380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74381. */
  74382. static readonly OnKeyUpTrigger: number;
  74383. private _scene;
  74384. /**
  74385. * Creates a new action manager
  74386. * @param scene defines the hosting scene
  74387. */
  74388. constructor(scene: Scene);
  74389. /**
  74390. * Releases all associated resources
  74391. */
  74392. dispose(): void;
  74393. /**
  74394. * Gets hosting scene
  74395. * @returns the hosting scene
  74396. */
  74397. getScene(): Scene;
  74398. /**
  74399. * Does this action manager handles actions of any of the given triggers
  74400. * @param triggers defines the triggers to be tested
  74401. * @return a boolean indicating whether one (or more) of the triggers is handled
  74402. */
  74403. hasSpecificTriggers(triggers: number[]): boolean;
  74404. /**
  74405. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  74406. * speed.
  74407. * @param triggerA defines the trigger to be tested
  74408. * @param triggerB defines the trigger to be tested
  74409. * @return a boolean indicating whether one (or more) of the triggers is handled
  74410. */
  74411. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  74412. /**
  74413. * Does this action manager handles actions of a given trigger
  74414. * @param trigger defines the trigger to be tested
  74415. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  74416. * @return whether the trigger is handled
  74417. */
  74418. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  74419. /**
  74420. * Does this action manager has pointer triggers
  74421. */
  74422. readonly hasPointerTriggers: boolean;
  74423. /**
  74424. * Does this action manager has pick triggers
  74425. */
  74426. readonly hasPickTriggers: boolean;
  74427. /**
  74428. * Registers an action to this action manager
  74429. * @param action defines the action to be registered
  74430. * @return the action amended (prepared) after registration
  74431. */
  74432. registerAction(action: IAction): Nullable<IAction>;
  74433. /**
  74434. * Unregisters an action to this action manager
  74435. * @param action defines the action to be unregistered
  74436. * @return a boolean indicating whether the action has been unregistered
  74437. */
  74438. unregisterAction(action: IAction): Boolean;
  74439. /**
  74440. * Process a specific trigger
  74441. * @param trigger defines the trigger to process
  74442. * @param evt defines the event details to be processed
  74443. */
  74444. processTrigger(trigger: number, evt?: IActionEvent): void;
  74445. /** @hidden */
  74446. _getEffectiveTarget(target: any, propertyPath: string): any;
  74447. /** @hidden */
  74448. _getProperty(propertyPath: string): string;
  74449. /**
  74450. * Serialize this manager to a JSON object
  74451. * @param name defines the property name to store this manager
  74452. * @returns a JSON representation of this manager
  74453. */
  74454. serialize(name: string): any;
  74455. /**
  74456. * Creates a new ActionManager from a JSON data
  74457. * @param parsedActions defines the JSON data to read from
  74458. * @param object defines the hosting mesh
  74459. * @param scene defines the hosting scene
  74460. */
  74461. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  74462. /**
  74463. * Get a trigger name by index
  74464. * @param trigger defines the trigger index
  74465. * @returns a trigger name
  74466. */
  74467. static GetTriggerName(trigger: number): string;
  74468. }
  74469. }
  74470. declare module BABYLON {
  74471. /**
  74472. * Class representing a ray with position and direction
  74473. */
  74474. export class Ray {
  74475. /** origin point */
  74476. origin: Vector3;
  74477. /** direction */
  74478. direction: Vector3;
  74479. /** length of the ray */
  74480. length: number;
  74481. private static readonly TmpVector3;
  74482. private _tmpRay;
  74483. /**
  74484. * Creates a new ray
  74485. * @param origin origin point
  74486. * @param direction direction
  74487. * @param length length of the ray
  74488. */
  74489. constructor(
  74490. /** origin point */
  74491. origin: Vector3,
  74492. /** direction */
  74493. direction: Vector3,
  74494. /** length of the ray */
  74495. length?: number);
  74496. /**
  74497. * Checks if the ray intersects a box
  74498. * @param minimum bound of the box
  74499. * @param maximum bound of the box
  74500. * @param intersectionTreshold extra extend to be added to the box in all direction
  74501. * @returns if the box was hit
  74502. */
  74503. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  74504. /**
  74505. * Checks if the ray intersects a box
  74506. * @param box the bounding box to check
  74507. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  74508. * @returns if the box was hit
  74509. */
  74510. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  74511. /**
  74512. * If the ray hits a sphere
  74513. * @param sphere the bounding sphere to check
  74514. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  74515. * @returns true if it hits the sphere
  74516. */
  74517. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  74518. /**
  74519. * If the ray hits a triange
  74520. * @param vertex0 triangle vertex
  74521. * @param vertex1 triangle vertex
  74522. * @param vertex2 triangle vertex
  74523. * @returns intersection information if hit
  74524. */
  74525. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  74526. /**
  74527. * Checks if ray intersects a plane
  74528. * @param plane the plane to check
  74529. * @returns the distance away it was hit
  74530. */
  74531. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  74532. /**
  74533. * Calculate the intercept of a ray on a given axis
  74534. * @param axis to check 'x' | 'y' | 'z'
  74535. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  74536. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  74537. */
  74538. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  74539. /**
  74540. * Checks if ray intersects a mesh
  74541. * @param mesh the mesh to check
  74542. * @param fastCheck if only the bounding box should checked
  74543. * @returns picking info of the intersecton
  74544. */
  74545. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  74546. /**
  74547. * Checks if ray intersects a mesh
  74548. * @param meshes the meshes to check
  74549. * @param fastCheck if only the bounding box should checked
  74550. * @param results array to store result in
  74551. * @returns Array of picking infos
  74552. */
  74553. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74554. private _comparePickingInfo;
  74555. private static smallnum;
  74556. private static rayl;
  74557. /**
  74558. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74559. * @param sega the first point of the segment to test the intersection against
  74560. * @param segb the second point of the segment to test the intersection against
  74561. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74562. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74563. */
  74564. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74565. /**
  74566. * Update the ray from viewport position
  74567. * @param x position
  74568. * @param y y position
  74569. * @param viewportWidth viewport width
  74570. * @param viewportHeight viewport height
  74571. * @param world world matrix
  74572. * @param view view matrix
  74573. * @param projection projection matrix
  74574. * @returns this ray updated
  74575. */
  74576. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74577. /**
  74578. * Creates a ray with origin and direction of 0,0,0
  74579. * @returns the new ray
  74580. */
  74581. static Zero(): Ray;
  74582. /**
  74583. * Creates a new ray from screen space and viewport
  74584. * @param x position
  74585. * @param y y position
  74586. * @param viewportWidth viewport width
  74587. * @param viewportHeight viewport height
  74588. * @param world world matrix
  74589. * @param view view matrix
  74590. * @param projection projection matrix
  74591. * @returns new ray
  74592. */
  74593. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74594. /**
  74595. * 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
  74596. * transformed to the given world matrix.
  74597. * @param origin The origin point
  74598. * @param end The end point
  74599. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74600. * @returns the new ray
  74601. */
  74602. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74603. /**
  74604. * Transforms a ray by a matrix
  74605. * @param ray ray to transform
  74606. * @param matrix matrix to apply
  74607. * @returns the resulting new ray
  74608. */
  74609. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74610. /**
  74611. * Transforms a ray by a matrix
  74612. * @param ray ray to transform
  74613. * @param matrix matrix to apply
  74614. * @param result ray to store result in
  74615. */
  74616. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74617. /**
  74618. * Unproject a ray from screen space to object space
  74619. * @param sourceX defines the screen space x coordinate to use
  74620. * @param sourceY defines the screen space y coordinate to use
  74621. * @param viewportWidth defines the current width of the viewport
  74622. * @param viewportHeight defines the current height of the viewport
  74623. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74624. * @param view defines the view matrix to use
  74625. * @param projection defines the projection matrix to use
  74626. */
  74627. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74628. }
  74629. /**
  74630. * Type used to define predicate used to select faces when a mesh intersection is detected
  74631. */
  74632. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74633. interface Scene {
  74634. /** @hidden */
  74635. _tempPickingRay: Nullable<Ray>;
  74636. /** @hidden */
  74637. _cachedRayForTransform: Ray;
  74638. /** @hidden */
  74639. _pickWithRayInverseMatrix: Matrix;
  74640. /** @hidden */
  74641. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74642. /** @hidden */
  74643. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74644. }
  74645. }
  74646. declare module BABYLON {
  74647. /**
  74648. * Groups all the scene component constants in one place to ease maintenance.
  74649. * @hidden
  74650. */
  74651. export class SceneComponentConstants {
  74652. static readonly NAME_EFFECTLAYER: string;
  74653. static readonly NAME_LAYER: string;
  74654. static readonly NAME_LENSFLARESYSTEM: string;
  74655. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74656. static readonly NAME_PARTICLESYSTEM: string;
  74657. static readonly NAME_GAMEPAD: string;
  74658. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74659. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74660. static readonly NAME_DEPTHRENDERER: string;
  74661. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74662. static readonly NAME_SPRITE: string;
  74663. static readonly NAME_OUTLINERENDERER: string;
  74664. static readonly NAME_PROCEDURALTEXTURE: string;
  74665. static readonly NAME_SHADOWGENERATOR: string;
  74666. static readonly NAME_OCTREE: string;
  74667. static readonly NAME_PHYSICSENGINE: string;
  74668. static readonly NAME_AUDIO: string;
  74669. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74670. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74671. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74672. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74673. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74674. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74675. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74676. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74677. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74678. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74679. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74680. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74681. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74682. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74683. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74684. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74685. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74686. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74687. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74688. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  74689. static readonly STEP_AFTERRENDER_AUDIO: number;
  74690. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  74691. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  74692. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  74693. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  74694. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  74695. static readonly STEP_POINTERMOVE_SPRITE: number;
  74696. static readonly STEP_POINTERDOWN_SPRITE: number;
  74697. static readonly STEP_POINTERUP_SPRITE: number;
  74698. }
  74699. /**
  74700. * This represents a scene component.
  74701. *
  74702. * This is used to decouple the dependency the scene is having on the different workloads like
  74703. * layers, post processes...
  74704. */
  74705. export interface ISceneComponent {
  74706. /**
  74707. * The name of the component. Each component must have a unique name.
  74708. */
  74709. name: string;
  74710. /**
  74711. * The scene the component belongs to.
  74712. */
  74713. scene: Scene;
  74714. /**
  74715. * Register the component to one instance of a scene.
  74716. */
  74717. register(): void;
  74718. /**
  74719. * Rebuilds the elements related to this component in case of
  74720. * context lost for instance.
  74721. */
  74722. rebuild(): void;
  74723. /**
  74724. * Disposes the component and the associated ressources.
  74725. */
  74726. dispose(): void;
  74727. }
  74728. /**
  74729. * This represents a SERIALIZABLE scene component.
  74730. *
  74731. * This extends Scene Component to add Serialization methods on top.
  74732. */
  74733. export interface ISceneSerializableComponent extends ISceneComponent {
  74734. /**
  74735. * Adds all the elements from the container to the scene
  74736. * @param container the container holding the elements
  74737. */
  74738. addFromContainer(container: AbstractScene): void;
  74739. /**
  74740. * Removes all the elements in the container from the scene
  74741. * @param container contains the elements to remove
  74742. * @param dispose if the removed element should be disposed (default: false)
  74743. */
  74744. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74745. /**
  74746. * Serializes the component data to the specified json object
  74747. * @param serializationObject The object to serialize to
  74748. */
  74749. serialize(serializationObject: any): void;
  74750. }
  74751. /**
  74752. * Strong typing of a Mesh related stage step action
  74753. */
  74754. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  74755. /**
  74756. * Strong typing of a Evaluate Sub Mesh related stage step action
  74757. */
  74758. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  74759. /**
  74760. * Strong typing of a Active Mesh related stage step action
  74761. */
  74762. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  74763. /**
  74764. * Strong typing of a Camera related stage step action
  74765. */
  74766. export type CameraStageAction = (camera: Camera) => void;
  74767. /**
  74768. * Strong typing of a Camera Frame buffer related stage step action
  74769. */
  74770. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  74771. /**
  74772. * Strong typing of a Render Target related stage step action
  74773. */
  74774. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  74775. /**
  74776. * Strong typing of a RenderingGroup related stage step action
  74777. */
  74778. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  74779. /**
  74780. * Strong typing of a Mesh Render related stage step action
  74781. */
  74782. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  74783. /**
  74784. * Strong typing of a simple stage step action
  74785. */
  74786. export type SimpleStageAction = () => void;
  74787. /**
  74788. * Strong typing of a render target action.
  74789. */
  74790. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  74791. /**
  74792. * Strong typing of a pointer move action.
  74793. */
  74794. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  74795. /**
  74796. * Strong typing of a pointer up/down action.
  74797. */
  74798. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  74799. /**
  74800. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  74801. * @hidden
  74802. */
  74803. export class Stage<T extends Function> extends Array<{
  74804. index: number;
  74805. component: ISceneComponent;
  74806. action: T;
  74807. }> {
  74808. /**
  74809. * Hide ctor from the rest of the world.
  74810. * @param items The items to add.
  74811. */
  74812. private constructor();
  74813. /**
  74814. * Creates a new Stage.
  74815. * @returns A new instance of a Stage
  74816. */
  74817. static Create<T extends Function>(): Stage<T>;
  74818. /**
  74819. * Registers a step in an ordered way in the targeted stage.
  74820. * @param index Defines the position to register the step in
  74821. * @param component Defines the component attached to the step
  74822. * @param action Defines the action to launch during the step
  74823. */
  74824. registerStep(index: number, component: ISceneComponent, action: T): void;
  74825. /**
  74826. * Clears all the steps from the stage.
  74827. */
  74828. clear(): void;
  74829. }
  74830. }
  74831. declare module BABYLON {
  74832. interface Scene {
  74833. /** @hidden */
  74834. _pointerOverSprite: Nullable<Sprite>;
  74835. /** @hidden */
  74836. _pickedDownSprite: Nullable<Sprite>;
  74837. /** @hidden */
  74838. _tempSpritePickingRay: Nullable<Ray>;
  74839. /**
  74840. * All of the sprite managers added to this scene
  74841. * @see http://doc.babylonjs.com/babylon101/sprites
  74842. */
  74843. spriteManagers: Array<ISpriteManager>;
  74844. /**
  74845. * An event triggered when sprites rendering is about to start
  74846. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74847. */
  74848. onBeforeSpritesRenderingObservable: Observable<Scene>;
  74849. /**
  74850. * An event triggered when sprites rendering is done
  74851. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74852. */
  74853. onAfterSpritesRenderingObservable: Observable<Scene>;
  74854. /** @hidden */
  74855. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74856. /** Launch a ray to try to pick a sprite in the scene
  74857. * @param x position on screen
  74858. * @param y position on screen
  74859. * @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
  74860. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74861. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  74862. * @returns a PickingInfo
  74863. */
  74864. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74865. /** Use the given ray to pick a sprite in the scene
  74866. * @param ray The ray (in world space) to use to pick meshes
  74867. * @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
  74868. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74869. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  74870. * @returns a PickingInfo
  74871. */
  74872. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74873. /**
  74874. * Force the sprite under the pointer
  74875. * @param sprite defines the sprite to use
  74876. */
  74877. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  74878. /**
  74879. * Gets the sprite under the pointer
  74880. * @returns a Sprite or null if no sprite is under the pointer
  74881. */
  74882. getPointerOverSprite(): Nullable<Sprite>;
  74883. }
  74884. /**
  74885. * Defines the sprite scene component responsible to manage sprites
  74886. * in a given scene.
  74887. */
  74888. export class SpriteSceneComponent implements ISceneComponent {
  74889. /**
  74890. * The component name helpfull to identify the component in the list of scene components.
  74891. */
  74892. readonly name: string;
  74893. /**
  74894. * The scene the component belongs to.
  74895. */
  74896. scene: Scene;
  74897. /** @hidden */
  74898. private _spritePredicate;
  74899. /**
  74900. * Creates a new instance of the component for the given scene
  74901. * @param scene Defines the scene to register the component in
  74902. */
  74903. constructor(scene: Scene);
  74904. /**
  74905. * Registers the component in a given scene
  74906. */
  74907. register(): void;
  74908. /**
  74909. * Rebuilds the elements related to this component in case of
  74910. * context lost for instance.
  74911. */
  74912. rebuild(): void;
  74913. /**
  74914. * Disposes the component and the associated ressources.
  74915. */
  74916. dispose(): void;
  74917. private _pickSpriteButKeepRay;
  74918. private _pointerMove;
  74919. private _pointerDown;
  74920. private _pointerUp;
  74921. }
  74922. }
  74923. declare module BABYLON {
  74924. /** @hidden */
  74925. export var fogFragmentDeclaration: {
  74926. name: string;
  74927. shader: string;
  74928. };
  74929. }
  74930. declare module BABYLON {
  74931. /** @hidden */
  74932. export var fogFragment: {
  74933. name: string;
  74934. shader: string;
  74935. };
  74936. }
  74937. declare module BABYLON {
  74938. /** @hidden */
  74939. export var spritesPixelShader: {
  74940. name: string;
  74941. shader: string;
  74942. };
  74943. }
  74944. declare module BABYLON {
  74945. /** @hidden */
  74946. export var fogVertexDeclaration: {
  74947. name: string;
  74948. shader: string;
  74949. };
  74950. }
  74951. declare module BABYLON {
  74952. /** @hidden */
  74953. export var spritesVertexShader: {
  74954. name: string;
  74955. shader: string;
  74956. };
  74957. }
  74958. declare module BABYLON {
  74959. /**
  74960. * Defines the minimum interface to fullfil in order to be a sprite manager.
  74961. */
  74962. export interface ISpriteManager extends IDisposable {
  74963. /**
  74964. * Restricts the camera to viewing objects with the same layerMask.
  74965. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  74966. */
  74967. layerMask: number;
  74968. /**
  74969. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  74970. */
  74971. isPickable: boolean;
  74972. /**
  74973. * Specifies the rendering group id for this mesh (0 by default)
  74974. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  74975. */
  74976. renderingGroupId: number;
  74977. /**
  74978. * Defines the list of sprites managed by the manager.
  74979. */
  74980. sprites: Array<Sprite>;
  74981. /**
  74982. * Tests the intersection of a sprite with a specific ray.
  74983. * @param ray The ray we are sending to test the collision
  74984. * @param camera The camera space we are sending rays in
  74985. * @param predicate A predicate allowing excluding sprites from the list of object to test
  74986. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  74987. * @returns picking info or null.
  74988. */
  74989. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74990. /**
  74991. * Renders the list of sprites on screen.
  74992. */
  74993. render(): void;
  74994. }
  74995. /**
  74996. * Class used to manage multiple sprites on the same spritesheet
  74997. * @see http://doc.babylonjs.com/babylon101/sprites
  74998. */
  74999. export class SpriteManager implements ISpriteManager {
  75000. /** defines the manager's name */
  75001. name: string;
  75002. /** Gets the list of sprites */
  75003. sprites: Sprite[];
  75004. /** Gets or sets the rendering group id (0 by default) */
  75005. renderingGroupId: number;
  75006. /** Gets or sets camera layer mask */
  75007. layerMask: number;
  75008. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75009. fogEnabled: boolean;
  75010. /** Gets or sets a boolean indicating if the sprites are pickable */
  75011. isPickable: boolean;
  75012. /** Defines the default width of a cell in the spritesheet */
  75013. cellWidth: number;
  75014. /** Defines the default height of a cell in the spritesheet */
  75015. cellHeight: number;
  75016. /**
  75017. * An event triggered when the manager is disposed.
  75018. */
  75019. onDisposeObservable: Observable<SpriteManager>;
  75020. private _onDisposeObserver;
  75021. /**
  75022. * Callback called when the manager is disposed
  75023. */
  75024. onDispose: () => void;
  75025. private _capacity;
  75026. private _spriteTexture;
  75027. private _epsilon;
  75028. private _scene;
  75029. private _vertexData;
  75030. private _buffer;
  75031. private _vertexBuffers;
  75032. private _indexBuffer;
  75033. private _effectBase;
  75034. private _effectFog;
  75035. /**
  75036. * Gets or sets the spritesheet texture
  75037. */
  75038. texture: Texture;
  75039. /**
  75040. * Creates a new sprite manager
  75041. * @param name defines the manager's name
  75042. * @param imgUrl defines the sprite sheet url
  75043. * @param capacity defines the maximum allowed number of sprites
  75044. * @param cellSize defines the size of a sprite cell
  75045. * @param scene defines the hosting scene
  75046. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75047. * @param samplingMode defines the smapling mode to use with spritesheet
  75048. */
  75049. constructor(
  75050. /** defines the manager's name */
  75051. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  75052. private _appendSpriteVertex;
  75053. /**
  75054. * Intersects the sprites with a ray
  75055. * @param ray defines the ray to intersect with
  75056. * @param camera defines the current active camera
  75057. * @param predicate defines a predicate used to select candidate sprites
  75058. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75059. * @returns null if no hit or a PickingInfo
  75060. */
  75061. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75062. /**
  75063. * Render all child sprites
  75064. */
  75065. render(): void;
  75066. /**
  75067. * Release associated resources
  75068. */
  75069. dispose(): void;
  75070. }
  75071. }
  75072. declare module BABYLON {
  75073. /**
  75074. * Class used to represent a sprite
  75075. * @see http://doc.babylonjs.com/babylon101/sprites
  75076. */
  75077. export class Sprite {
  75078. /** defines the name */
  75079. name: string;
  75080. /** Gets or sets the current world position */
  75081. position: Vector3;
  75082. /** Gets or sets the main color */
  75083. color: Color4;
  75084. /** Gets or sets the width */
  75085. width: number;
  75086. /** Gets or sets the height */
  75087. height: number;
  75088. /** Gets or sets rotation angle */
  75089. angle: number;
  75090. /** Gets or sets the cell index in the sprite sheet */
  75091. cellIndex: number;
  75092. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75093. invertU: number;
  75094. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75095. invertV: number;
  75096. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75097. disposeWhenFinishedAnimating: boolean;
  75098. /** Gets the list of attached animations */
  75099. animations: Animation[];
  75100. /** Gets or sets a boolean indicating if the sprite can be picked */
  75101. isPickable: boolean;
  75102. /**
  75103. * Gets or sets the associated action manager
  75104. */
  75105. actionManager: Nullable<ActionManager>;
  75106. private _animationStarted;
  75107. private _loopAnimation;
  75108. private _fromIndex;
  75109. private _toIndex;
  75110. private _delay;
  75111. private _direction;
  75112. private _manager;
  75113. private _time;
  75114. private _onAnimationEnd;
  75115. /**
  75116. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  75117. */
  75118. isVisible: boolean;
  75119. /**
  75120. * Gets or sets the sprite size
  75121. */
  75122. size: number;
  75123. /**
  75124. * Creates a new Sprite
  75125. * @param name defines the name
  75126. * @param manager defines the manager
  75127. */
  75128. constructor(
  75129. /** defines the name */
  75130. name: string, manager: ISpriteManager);
  75131. /**
  75132. * Starts an animation
  75133. * @param from defines the initial key
  75134. * @param to defines the end key
  75135. * @param loop defines if the animation must loop
  75136. * @param delay defines the start delay (in ms)
  75137. * @param onAnimationEnd defines a callback to call when animation ends
  75138. */
  75139. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  75140. /** Stops current animation (if any) */
  75141. stopAnimation(): void;
  75142. /** @hidden */
  75143. _animate(deltaTime: number): void;
  75144. /** Release associated resources */
  75145. dispose(): void;
  75146. }
  75147. }
  75148. declare module BABYLON {
  75149. /**
  75150. * Information about the result of picking within a scene
  75151. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  75152. */
  75153. export class PickingInfo {
  75154. /** @hidden */
  75155. _pickingUnavailable: boolean;
  75156. /**
  75157. * If the pick collided with an object
  75158. */
  75159. hit: boolean;
  75160. /**
  75161. * Distance away where the pick collided
  75162. */
  75163. distance: number;
  75164. /**
  75165. * The location of pick collision
  75166. */
  75167. pickedPoint: Nullable<Vector3>;
  75168. /**
  75169. * The mesh corresponding the the pick collision
  75170. */
  75171. pickedMesh: Nullable<AbstractMesh>;
  75172. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  75173. bu: number;
  75174. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  75175. bv: number;
  75176. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  75177. faceId: number;
  75178. /** Id of the the submesh that was picked */
  75179. subMeshId: number;
  75180. /** If a sprite was picked, this will be the sprite the pick collided with */
  75181. pickedSprite: Nullable<Sprite>;
  75182. /**
  75183. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  75184. */
  75185. originMesh: Nullable<AbstractMesh>;
  75186. /**
  75187. * The ray that was used to perform the picking.
  75188. */
  75189. ray: Nullable<Ray>;
  75190. /**
  75191. * Gets the normal correspodning to the face the pick collided with
  75192. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  75193. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  75194. * @returns The normal correspodning to the face the pick collided with
  75195. */
  75196. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  75197. /**
  75198. * Gets the texture coordinates of where the pick occured
  75199. * @returns the vector containing the coordnates of the texture
  75200. */
  75201. getTextureCoordinates(): Nullable<Vector2>;
  75202. }
  75203. }
  75204. declare module BABYLON {
  75205. /**
  75206. * Gather the list of pointer event types as constants.
  75207. */
  75208. export class PointerEventTypes {
  75209. /**
  75210. * 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.
  75211. */
  75212. static readonly POINTERDOWN: number;
  75213. /**
  75214. * The pointerup event is fired when a pointer is no longer active.
  75215. */
  75216. static readonly POINTERUP: number;
  75217. /**
  75218. * The pointermove event is fired when a pointer changes coordinates.
  75219. */
  75220. static readonly POINTERMOVE: number;
  75221. /**
  75222. * The pointerwheel event is fired when a mouse wheel has been rotated.
  75223. */
  75224. static readonly POINTERWHEEL: number;
  75225. /**
  75226. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  75227. */
  75228. static readonly POINTERPICK: number;
  75229. /**
  75230. * The pointertap event is fired when a the object has been touched and released without drag.
  75231. */
  75232. static readonly POINTERTAP: number;
  75233. /**
  75234. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  75235. */
  75236. static readonly POINTERDOUBLETAP: number;
  75237. }
  75238. /**
  75239. * Base class of pointer info types.
  75240. */
  75241. export class PointerInfoBase {
  75242. /**
  75243. * Defines the type of event (PointerEventTypes)
  75244. */
  75245. type: number;
  75246. /**
  75247. * Defines the related dom event
  75248. */
  75249. event: PointerEvent | MouseWheelEvent;
  75250. /**
  75251. * Instantiates the base class of pointers info.
  75252. * @param type Defines the type of event (PointerEventTypes)
  75253. * @param event Defines the related dom event
  75254. */
  75255. constructor(
  75256. /**
  75257. * Defines the type of event (PointerEventTypes)
  75258. */
  75259. type: number,
  75260. /**
  75261. * Defines the related dom event
  75262. */
  75263. event: PointerEvent | MouseWheelEvent);
  75264. }
  75265. /**
  75266. * This class is used to store pointer related info for the onPrePointerObservable event.
  75267. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  75268. */
  75269. export class PointerInfoPre extends PointerInfoBase {
  75270. /**
  75271. * Ray from a pointer if availible (eg. 6dof controller)
  75272. */
  75273. ray: Nullable<Ray>;
  75274. /**
  75275. * Defines the local position of the pointer on the canvas.
  75276. */
  75277. localPosition: Vector2;
  75278. /**
  75279. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  75280. */
  75281. skipOnPointerObservable: boolean;
  75282. /**
  75283. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  75284. * @param type Defines the type of event (PointerEventTypes)
  75285. * @param event Defines the related dom event
  75286. * @param localX Defines the local x coordinates of the pointer when the event occured
  75287. * @param localY Defines the local y coordinates of the pointer when the event occured
  75288. */
  75289. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  75290. }
  75291. /**
  75292. * This type contains all the data related to a pointer event in Babylon.js.
  75293. * 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.
  75294. */
  75295. export class PointerInfo extends PointerInfoBase {
  75296. /**
  75297. * Defines the picking info associated to the info (if any)\
  75298. */
  75299. pickInfo: Nullable<PickingInfo>;
  75300. /**
  75301. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  75302. * @param type Defines the type of event (PointerEventTypes)
  75303. * @param event Defines the related dom event
  75304. * @param pickInfo Defines the picking info associated to the info (if any)\
  75305. */
  75306. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  75307. /**
  75308. * Defines the picking info associated to the info (if any)\
  75309. */
  75310. pickInfo: Nullable<PickingInfo>);
  75311. }
  75312. /**
  75313. * Data relating to a touch event on the screen.
  75314. */
  75315. export interface PointerTouch {
  75316. /**
  75317. * X coordinate of touch.
  75318. */
  75319. x: number;
  75320. /**
  75321. * Y coordinate of touch.
  75322. */
  75323. y: number;
  75324. /**
  75325. * Id of touch. Unique for each finger.
  75326. */
  75327. pointerId: number;
  75328. /**
  75329. * Event type passed from DOM.
  75330. */
  75331. type: any;
  75332. }
  75333. }
  75334. declare module BABYLON {
  75335. /**
  75336. * Manage the mouse inputs to control the movement of a free camera.
  75337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75338. */
  75339. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  75340. /**
  75341. * Define if touch is enabled in the mouse input
  75342. */
  75343. touchEnabled: boolean;
  75344. /**
  75345. * Defines the camera the input is attached to.
  75346. */
  75347. camera: FreeCamera;
  75348. /**
  75349. * Defines the buttons associated with the input to handle camera move.
  75350. */
  75351. buttons: number[];
  75352. /**
  75353. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  75354. */
  75355. angularSensibility: number;
  75356. private _pointerInput;
  75357. private _onMouseMove;
  75358. private _observer;
  75359. private previousPosition;
  75360. /**
  75361. * Observable for when a pointer move event occurs containing the move offset
  75362. */
  75363. onPointerMovedObservable: Observable<{
  75364. offsetX: number;
  75365. offsetY: number;
  75366. }>;
  75367. /**
  75368. * @hidden
  75369. * If the camera should be rotated automatically based on pointer movement
  75370. */
  75371. _allowCameraRotation: boolean;
  75372. /**
  75373. * Manage the mouse inputs to control the movement of a free camera.
  75374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75375. * @param touchEnabled Defines if touch is enabled or not
  75376. */
  75377. constructor(
  75378. /**
  75379. * Define if touch is enabled in the mouse input
  75380. */
  75381. touchEnabled?: boolean);
  75382. /**
  75383. * Attach the input controls to a specific dom element to get the input from.
  75384. * @param element Defines the element the controls should be listened from
  75385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75386. */
  75387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75388. /**
  75389. * Called on JS contextmenu event.
  75390. * Override this method to provide functionality.
  75391. */
  75392. protected onContextMenu(evt: PointerEvent): void;
  75393. /**
  75394. * Detach the current controls from the specified dom element.
  75395. * @param element Defines the element to stop listening the inputs from
  75396. */
  75397. detachControl(element: Nullable<HTMLElement>): void;
  75398. /**
  75399. * Gets the class name of the current intput.
  75400. * @returns the class name
  75401. */
  75402. getClassName(): string;
  75403. /**
  75404. * Get the friendly name associated with the input class.
  75405. * @returns the input friendly name
  75406. */
  75407. getSimpleName(): string;
  75408. }
  75409. }
  75410. declare module BABYLON {
  75411. /**
  75412. * Manage the touch inputs to control the movement of a free camera.
  75413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75414. */
  75415. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  75416. /**
  75417. * Defines the camera the input is attached to.
  75418. */
  75419. camera: FreeCamera;
  75420. /**
  75421. * Defines the touch sensibility for rotation.
  75422. * The higher the faster.
  75423. */
  75424. touchAngularSensibility: number;
  75425. /**
  75426. * Defines the touch sensibility for move.
  75427. * The higher the faster.
  75428. */
  75429. touchMoveSensibility: number;
  75430. private _offsetX;
  75431. private _offsetY;
  75432. private _pointerPressed;
  75433. private _pointerInput;
  75434. private _observer;
  75435. private _onLostFocus;
  75436. /**
  75437. * Attach the input controls to a specific dom element to get the input from.
  75438. * @param element Defines the element the controls should be listened from
  75439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75440. */
  75441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75442. /**
  75443. * Detach the current controls from the specified dom element.
  75444. * @param element Defines the element to stop listening the inputs from
  75445. */
  75446. detachControl(element: Nullable<HTMLElement>): void;
  75447. /**
  75448. * Update the current camera state depending on the inputs that have been used this frame.
  75449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75450. */
  75451. checkInputs(): void;
  75452. /**
  75453. * Gets the class name of the current intput.
  75454. * @returns the class name
  75455. */
  75456. getClassName(): string;
  75457. /**
  75458. * Get the friendly name associated with the input class.
  75459. * @returns the input friendly name
  75460. */
  75461. getSimpleName(): string;
  75462. }
  75463. }
  75464. declare module BABYLON {
  75465. /**
  75466. * Default Inputs manager for the FreeCamera.
  75467. * It groups all the default supported inputs for ease of use.
  75468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75469. */
  75470. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  75471. /**
  75472. * @hidden
  75473. */
  75474. _mouseInput: Nullable<FreeCameraMouseInput>;
  75475. /**
  75476. * Instantiates a new FreeCameraInputsManager.
  75477. * @param camera Defines the camera the inputs belong to
  75478. */
  75479. constructor(camera: FreeCamera);
  75480. /**
  75481. * Add keyboard input support to the input manager.
  75482. * @returns the current input manager
  75483. */
  75484. addKeyboard(): FreeCameraInputsManager;
  75485. /**
  75486. * Add mouse input support to the input manager.
  75487. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  75488. * @returns the current input manager
  75489. */
  75490. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  75491. /**
  75492. * Removes the mouse input support from the manager
  75493. * @returns the current input manager
  75494. */
  75495. removeMouse(): FreeCameraInputsManager;
  75496. /**
  75497. * Add touch input support to the input manager.
  75498. * @returns the current input manager
  75499. */
  75500. addTouch(): FreeCameraInputsManager;
  75501. /**
  75502. * Remove all attached input methods from a camera
  75503. */
  75504. clear(): void;
  75505. }
  75506. }
  75507. declare module BABYLON {
  75508. /**
  75509. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75510. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  75511. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75512. */
  75513. export class FreeCamera extends TargetCamera {
  75514. /**
  75515. * Define the collision ellipsoid of the camera.
  75516. * This is helpful to simulate a camera body like the player body around the camera
  75517. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  75518. */
  75519. ellipsoid: Vector3;
  75520. /**
  75521. * Define an offset for the position of the ellipsoid around the camera.
  75522. * This can be helpful to determine the center of the body near the gravity center of the body
  75523. * instead of its head.
  75524. */
  75525. ellipsoidOffset: Vector3;
  75526. /**
  75527. * Enable or disable collisions of the camera with the rest of the scene objects.
  75528. */
  75529. checkCollisions: boolean;
  75530. /**
  75531. * Enable or disable gravity on the camera.
  75532. */
  75533. applyGravity: boolean;
  75534. /**
  75535. * Define the input manager associated to the camera.
  75536. */
  75537. inputs: FreeCameraInputsManager;
  75538. /**
  75539. * Gets the input sensibility for a mouse input. (default is 2000.0)
  75540. * Higher values reduce sensitivity.
  75541. */
  75542. /**
  75543. * Sets the input sensibility for a mouse input. (default is 2000.0)
  75544. * Higher values reduce sensitivity.
  75545. */
  75546. angularSensibility: number;
  75547. /**
  75548. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75549. */
  75550. keysUp: number[];
  75551. /**
  75552. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75553. */
  75554. keysDown: number[];
  75555. /**
  75556. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75557. */
  75558. keysLeft: number[];
  75559. /**
  75560. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75561. */
  75562. keysRight: number[];
  75563. /**
  75564. * Event raised when the camera collide with a mesh in the scene.
  75565. */
  75566. onCollide: (collidedMesh: AbstractMesh) => void;
  75567. private _collider;
  75568. private _needMoveForGravity;
  75569. private _oldPosition;
  75570. private _diffPosition;
  75571. private _newPosition;
  75572. /** @hidden */
  75573. _localDirection: Vector3;
  75574. /** @hidden */
  75575. _transformedDirection: Vector3;
  75576. /**
  75577. * Instantiates a Free Camera.
  75578. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75579. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75580. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75581. * @param name Define the name of the camera in the scene
  75582. * @param position Define the start position of the camera in the scene
  75583. * @param scene Define the scene the camera belongs to
  75584. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75585. */
  75586. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75587. /**
  75588. * Attached controls to the current camera.
  75589. * @param element Defines the element the controls should be listened from
  75590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75591. */
  75592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75593. /**
  75594. * Detach the current controls from the camera.
  75595. * The camera will stop reacting to inputs.
  75596. * @param element Defines the element to stop listening the inputs from
  75597. */
  75598. detachControl(element: HTMLElement): void;
  75599. private _collisionMask;
  75600. /**
  75601. * Define a collision mask to limit the list of object the camera can collide with
  75602. */
  75603. collisionMask: number;
  75604. /** @hidden */
  75605. _collideWithWorld(displacement: Vector3): void;
  75606. private _onCollisionPositionChange;
  75607. /** @hidden */
  75608. _checkInputs(): void;
  75609. /** @hidden */
  75610. _decideIfNeedsToMove(): boolean;
  75611. /** @hidden */
  75612. _updatePosition(): void;
  75613. /**
  75614. * Destroy the camera and release the current resources hold by it.
  75615. */
  75616. dispose(): void;
  75617. /**
  75618. * Gets the current object class name.
  75619. * @return the class name
  75620. */
  75621. getClassName(): string;
  75622. }
  75623. }
  75624. declare module BABYLON {
  75625. /**
  75626. * Represents a gamepad control stick position
  75627. */
  75628. export class StickValues {
  75629. /**
  75630. * The x component of the control stick
  75631. */
  75632. x: number;
  75633. /**
  75634. * The y component of the control stick
  75635. */
  75636. y: number;
  75637. /**
  75638. * Initializes the gamepad x and y control stick values
  75639. * @param x The x component of the gamepad control stick value
  75640. * @param y The y component of the gamepad control stick value
  75641. */
  75642. constructor(
  75643. /**
  75644. * The x component of the control stick
  75645. */
  75646. x: number,
  75647. /**
  75648. * The y component of the control stick
  75649. */
  75650. y: number);
  75651. }
  75652. /**
  75653. * An interface which manages callbacks for gamepad button changes
  75654. */
  75655. export interface GamepadButtonChanges {
  75656. /**
  75657. * Called when a gamepad has been changed
  75658. */
  75659. changed: boolean;
  75660. /**
  75661. * Called when a gamepad press event has been triggered
  75662. */
  75663. pressChanged: boolean;
  75664. /**
  75665. * Called when a touch event has been triggered
  75666. */
  75667. touchChanged: boolean;
  75668. /**
  75669. * Called when a value has changed
  75670. */
  75671. valueChanged: boolean;
  75672. }
  75673. /**
  75674. * Represents a gamepad
  75675. */
  75676. export class Gamepad {
  75677. /**
  75678. * The id of the gamepad
  75679. */
  75680. id: string;
  75681. /**
  75682. * The index of the gamepad
  75683. */
  75684. index: number;
  75685. /**
  75686. * The browser gamepad
  75687. */
  75688. browserGamepad: any;
  75689. /**
  75690. * Specifies what type of gamepad this represents
  75691. */
  75692. type: number;
  75693. private _leftStick;
  75694. private _rightStick;
  75695. /** @hidden */
  75696. _isConnected: boolean;
  75697. private _leftStickAxisX;
  75698. private _leftStickAxisY;
  75699. private _rightStickAxisX;
  75700. private _rightStickAxisY;
  75701. /**
  75702. * Triggered when the left control stick has been changed
  75703. */
  75704. private _onleftstickchanged;
  75705. /**
  75706. * Triggered when the right control stick has been changed
  75707. */
  75708. private _onrightstickchanged;
  75709. /**
  75710. * Represents a gamepad controller
  75711. */
  75712. static GAMEPAD: number;
  75713. /**
  75714. * Represents a generic controller
  75715. */
  75716. static GENERIC: number;
  75717. /**
  75718. * Represents an XBox controller
  75719. */
  75720. static XBOX: number;
  75721. /**
  75722. * Represents a pose-enabled controller
  75723. */
  75724. static POSE_ENABLED: number;
  75725. /**
  75726. * Specifies whether the left control stick should be Y-inverted
  75727. */
  75728. protected _invertLeftStickY: boolean;
  75729. /**
  75730. * Specifies if the gamepad has been connected
  75731. */
  75732. readonly isConnected: boolean;
  75733. /**
  75734. * Initializes the gamepad
  75735. * @param id The id of the gamepad
  75736. * @param index The index of the gamepad
  75737. * @param browserGamepad The browser gamepad
  75738. * @param leftStickX The x component of the left joystick
  75739. * @param leftStickY The y component of the left joystick
  75740. * @param rightStickX The x component of the right joystick
  75741. * @param rightStickY The y component of the right joystick
  75742. */
  75743. constructor(
  75744. /**
  75745. * The id of the gamepad
  75746. */
  75747. id: string,
  75748. /**
  75749. * The index of the gamepad
  75750. */
  75751. index: number,
  75752. /**
  75753. * The browser gamepad
  75754. */
  75755. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  75756. /**
  75757. * Callback triggered when the left joystick has changed
  75758. * @param callback
  75759. */
  75760. onleftstickchanged(callback: (values: StickValues) => void): void;
  75761. /**
  75762. * Callback triggered when the right joystick has changed
  75763. * @param callback
  75764. */
  75765. onrightstickchanged(callback: (values: StickValues) => void): void;
  75766. /**
  75767. * Gets the left joystick
  75768. */
  75769. /**
  75770. * Sets the left joystick values
  75771. */
  75772. leftStick: StickValues;
  75773. /**
  75774. * Gets the right joystick
  75775. */
  75776. /**
  75777. * Sets the right joystick value
  75778. */
  75779. rightStick: StickValues;
  75780. /**
  75781. * Updates the gamepad joystick positions
  75782. */
  75783. update(): void;
  75784. /**
  75785. * Disposes the gamepad
  75786. */
  75787. dispose(): void;
  75788. }
  75789. /**
  75790. * Represents a generic gamepad
  75791. */
  75792. export class GenericPad extends Gamepad {
  75793. private _buttons;
  75794. private _onbuttondown;
  75795. private _onbuttonup;
  75796. /**
  75797. * Observable triggered when a button has been pressed
  75798. */
  75799. onButtonDownObservable: Observable<number>;
  75800. /**
  75801. * Observable triggered when a button has been released
  75802. */
  75803. onButtonUpObservable: Observable<number>;
  75804. /**
  75805. * Callback triggered when a button has been pressed
  75806. * @param callback Called when a button has been pressed
  75807. */
  75808. onbuttondown(callback: (buttonPressed: number) => void): void;
  75809. /**
  75810. * Callback triggered when a button has been released
  75811. * @param callback Called when a button has been released
  75812. */
  75813. onbuttonup(callback: (buttonReleased: number) => void): void;
  75814. /**
  75815. * Initializes the generic gamepad
  75816. * @param id The id of the generic gamepad
  75817. * @param index The index of the generic gamepad
  75818. * @param browserGamepad The browser gamepad
  75819. */
  75820. constructor(id: string, index: number, browserGamepad: any);
  75821. private _setButtonValue;
  75822. /**
  75823. * Updates the generic gamepad
  75824. */
  75825. update(): void;
  75826. /**
  75827. * Disposes the generic gamepad
  75828. */
  75829. dispose(): void;
  75830. }
  75831. }
  75832. declare module BABYLON {
  75833. interface Engine {
  75834. /**
  75835. * Creates a raw texture
  75836. * @param data defines the data to store in the texture
  75837. * @param width defines the width of the texture
  75838. * @param height defines the height of the texture
  75839. * @param format defines the format of the data
  75840. * @param generateMipMaps defines if the engine should generate the mip levels
  75841. * @param invertY defines if data must be stored with Y axis inverted
  75842. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75843. * @param compression defines the compression used (null by default)
  75844. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75845. * @returns the raw texture inside an InternalTexture
  75846. */
  75847. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  75848. /**
  75849. * Update a raw texture
  75850. * @param texture defines the texture to update
  75851. * @param data defines the data to store in the texture
  75852. * @param format defines the format of the data
  75853. * @param invertY defines if data must be stored with Y axis inverted
  75854. */
  75855. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  75856. /**
  75857. * Update a raw texture
  75858. * @param texture defines the texture to update
  75859. * @param data defines the data to store in the texture
  75860. * @param format defines the format of the data
  75861. * @param invertY defines if data must be stored with Y axis inverted
  75862. * @param compression defines the compression used (null by default)
  75863. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75864. */
  75865. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  75866. /**
  75867. * Creates a new raw cube texture
  75868. * @param data defines the array of data to use to create each face
  75869. * @param size defines the size of the textures
  75870. * @param format defines the format of the data
  75871. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  75872. * @param generateMipMaps defines if the engine should generate the mip levels
  75873. * @param invertY defines if data must be stored with Y axis inverted
  75874. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  75875. * @param compression defines the compression used (null by default)
  75876. * @returns the cube texture as an InternalTexture
  75877. */
  75878. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  75879. /**
  75880. * Update a raw cube texture
  75881. * @param texture defines the texture to udpdate
  75882. * @param data defines the data to store
  75883. * @param format defines the data format
  75884. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75885. * @param invertY defines if data must be stored with Y axis inverted
  75886. */
  75887. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  75888. /**
  75889. * Update a raw cube texture
  75890. * @param texture defines the texture to udpdate
  75891. * @param data defines the data to store
  75892. * @param format defines the data format
  75893. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75894. * @param invertY defines if data must be stored with Y axis inverted
  75895. * @param compression defines the compression used (null by default)
  75896. */
  75897. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  75898. /**
  75899. * Update a raw cube texture
  75900. * @param texture defines the texture to udpdate
  75901. * @param data defines the data to store
  75902. * @param format defines the data format
  75903. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75904. * @param invertY defines if data must be stored with Y axis inverted
  75905. * @param compression defines the compression used (null by default)
  75906. * @param level defines which level of the texture to update
  75907. */
  75908. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  75909. /**
  75910. * Creates a new raw cube texture from a specified url
  75911. * @param url defines the url where the data is located
  75912. * @param scene defines the current scene
  75913. * @param size defines the size of the textures
  75914. * @param format defines the format of the data
  75915. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  75916. * @param noMipmap defines if the engine should avoid generating the mip levels
  75917. * @param callback defines a callback used to extract texture data from loaded data
  75918. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  75919. * @param onLoad defines a callback called when texture is loaded
  75920. * @param onError defines a callback called if there is an error
  75921. * @returns the cube texture as an InternalTexture
  75922. */
  75923. 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;
  75924. /**
  75925. * Creates a new raw cube texture from a specified url
  75926. * @param url defines the url where the data is located
  75927. * @param scene defines the current scene
  75928. * @param size defines the size of the textures
  75929. * @param format defines the format of the data
  75930. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  75931. * @param noMipmap defines if the engine should avoid generating the mip levels
  75932. * @param callback defines a callback used to extract texture data from loaded data
  75933. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  75934. * @param onLoad defines a callback called when texture is loaded
  75935. * @param onError defines a callback called if there is an error
  75936. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  75937. * @param invertY defines if data must be stored with Y axis inverted
  75938. * @returns the cube texture as an InternalTexture
  75939. */
  75940. 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;
  75941. /**
  75942. * Creates a new raw 3D texture
  75943. * @param data defines the data used to create the texture
  75944. * @param width defines the width of the texture
  75945. * @param height defines the height of the texture
  75946. * @param depth defines the depth of the texture
  75947. * @param format defines the format of the texture
  75948. * @param generateMipMaps defines if the engine must generate mip levels
  75949. * @param invertY defines if data must be stored with Y axis inverted
  75950. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  75951. * @param compression defines the compressed used (can be null)
  75952. * @param textureType defines the compressed used (can be null)
  75953. * @returns a new raw 3D texture (stored in an InternalTexture)
  75954. */
  75955. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  75956. /**
  75957. * Update a raw 3D texture
  75958. * @param texture defines the texture to update
  75959. * @param data defines the data to store
  75960. * @param format defines the data format
  75961. * @param invertY defines if data must be stored with Y axis inverted
  75962. */
  75963. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  75964. /**
  75965. * Update a raw 3D texture
  75966. * @param texture defines the texture to update
  75967. * @param data defines the data to store
  75968. * @param format defines the data format
  75969. * @param invertY defines if data must be stored with Y axis inverted
  75970. * @param compression defines the used compression (can be null)
  75971. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  75972. */
  75973. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  75974. }
  75975. }
  75976. declare module BABYLON {
  75977. /**
  75978. * Raw texture can help creating a texture directly from an array of data.
  75979. * This can be super useful if you either get the data from an uncompressed source or
  75980. * if you wish to create your texture pixel by pixel.
  75981. */
  75982. export class RawTexture extends Texture {
  75983. /**
  75984. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75985. */
  75986. format: number;
  75987. private _engine;
  75988. /**
  75989. * Instantiates a new RawTexture.
  75990. * Raw texture can help creating a texture directly from an array of data.
  75991. * This can be super useful if you either get the data from an uncompressed source or
  75992. * if you wish to create your texture pixel by pixel.
  75993. * @param data define the array of data to use to create the texture
  75994. * @param width define the width of the texture
  75995. * @param height define the height of the texture
  75996. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75997. * @param scene define the scene the texture belongs to
  75998. * @param generateMipMaps define whether mip maps should be generated or not
  75999. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76000. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76001. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76002. */
  76003. constructor(data: ArrayBufferView, width: number, height: number,
  76004. /**
  76005. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76006. */
  76007. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76008. /**
  76009. * Updates the texture underlying data.
  76010. * @param data Define the new data of the texture
  76011. */
  76012. update(data: ArrayBufferView): void;
  76013. /**
  76014. * Creates a luminance texture from some data.
  76015. * @param data Define the texture data
  76016. * @param width Define the width of the texture
  76017. * @param height Define the height of the texture
  76018. * @param scene Define the scene the texture belongs to
  76019. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76020. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76021. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76022. * @returns the luminance texture
  76023. */
  76024. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76025. /**
  76026. * Creates a luminance alpha texture from some data.
  76027. * @param data Define the texture data
  76028. * @param width Define the width of the texture
  76029. * @param height Define the height of the texture
  76030. * @param scene Define the scene the texture belongs to
  76031. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76032. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76033. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76034. * @returns the luminance alpha texture
  76035. */
  76036. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76037. /**
  76038. * Creates an alpha texture from some data.
  76039. * @param data Define the texture data
  76040. * @param width Define the width of the texture
  76041. * @param height Define the height of the texture
  76042. * @param scene Define the scene the texture belongs to
  76043. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76044. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76045. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76046. * @returns the alpha texture
  76047. */
  76048. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76049. /**
  76050. * Creates a RGB texture from some data.
  76051. * @param data Define the texture data
  76052. * @param width Define the width of the texture
  76053. * @param height Define the height of the texture
  76054. * @param scene Define the scene the texture belongs to
  76055. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76056. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76057. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76058. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76059. * @returns the RGB alpha texture
  76060. */
  76061. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76062. /**
  76063. * Creates a RGBA texture from some data.
  76064. * @param data Define the texture data
  76065. * @param width Define the width of the texture
  76066. * @param height Define the height of the texture
  76067. * @param scene Define the scene the texture belongs to
  76068. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76069. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76070. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76071. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76072. * @returns the RGBA texture
  76073. */
  76074. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76075. /**
  76076. * Creates a R texture from some data.
  76077. * @param data Define the texture data
  76078. * @param width Define the width of the texture
  76079. * @param height Define the height of the texture
  76080. * @param scene Define the scene the texture belongs to
  76081. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76082. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76083. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76084. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76085. * @returns the R texture
  76086. */
  76087. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76088. }
  76089. }
  76090. declare module BABYLON {
  76091. /**
  76092. * Interface for the size containing width and height
  76093. */
  76094. export interface ISize {
  76095. /**
  76096. * Width
  76097. */
  76098. width: number;
  76099. /**
  76100. * Heighht
  76101. */
  76102. height: number;
  76103. }
  76104. /**
  76105. * Size containing widht and height
  76106. */
  76107. export class Size implements ISize {
  76108. /**
  76109. * Width
  76110. */
  76111. width: number;
  76112. /**
  76113. * Height
  76114. */
  76115. height: number;
  76116. /**
  76117. * Creates a Size object from the given width and height (floats).
  76118. * @param width width of the new size
  76119. * @param height height of the new size
  76120. */
  76121. constructor(width: number, height: number);
  76122. /**
  76123. * Returns a string with the Size width and height
  76124. * @returns a string with the Size width and height
  76125. */
  76126. toString(): string;
  76127. /**
  76128. * "Size"
  76129. * @returns the string "Size"
  76130. */
  76131. getClassName(): string;
  76132. /**
  76133. * Returns the Size hash code.
  76134. * @returns a hash code for a unique width and height
  76135. */
  76136. getHashCode(): number;
  76137. /**
  76138. * Updates the current size from the given one.
  76139. * @param src the given size
  76140. */
  76141. copyFrom(src: Size): void;
  76142. /**
  76143. * Updates in place the current Size from the given floats.
  76144. * @param width width of the new size
  76145. * @param height height of the new size
  76146. * @returns the updated Size.
  76147. */
  76148. copyFromFloats(width: number, height: number): Size;
  76149. /**
  76150. * Updates in place the current Size from the given floats.
  76151. * @param width width to set
  76152. * @param height height to set
  76153. * @returns the updated Size.
  76154. */
  76155. set(width: number, height: number): Size;
  76156. /**
  76157. * Multiplies the width and height by numbers
  76158. * @param w factor to multiple the width by
  76159. * @param h factor to multiple the height by
  76160. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76161. */
  76162. multiplyByFloats(w: number, h: number): Size;
  76163. /**
  76164. * Clones the size
  76165. * @returns a new Size copied from the given one.
  76166. */
  76167. clone(): Size;
  76168. /**
  76169. * True if the current Size and the given one width and height are strictly equal.
  76170. * @param other the other size to compare against
  76171. * @returns True if the current Size and the given one width and height are strictly equal.
  76172. */
  76173. equals(other: Size): boolean;
  76174. /**
  76175. * The surface of the Size : width * height (float).
  76176. */
  76177. readonly surface: number;
  76178. /**
  76179. * Create a new size of zero
  76180. * @returns a new Size set to (0.0, 0.0)
  76181. */
  76182. static Zero(): Size;
  76183. /**
  76184. * Sums the width and height of two sizes
  76185. * @param otherSize size to add to this size
  76186. * @returns a new Size set as the addition result of the current Size and the given one.
  76187. */
  76188. add(otherSize: Size): Size;
  76189. /**
  76190. * Subtracts the width and height of two
  76191. * @param otherSize size to subtract to this size
  76192. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76193. */
  76194. subtract(otherSize: Size): Size;
  76195. /**
  76196. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76197. * @param start starting size to lerp between
  76198. * @param end end size to lerp between
  76199. * @param amount amount to lerp between the start and end values
  76200. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76201. */
  76202. static Lerp(start: Size, end: Size, amount: number): Size;
  76203. }
  76204. }
  76205. declare module BABYLON {
  76206. /**
  76207. * Defines a runtime animation
  76208. */
  76209. export class RuntimeAnimation {
  76210. private _events;
  76211. /**
  76212. * The current frame of the runtime animation
  76213. */
  76214. private _currentFrame;
  76215. /**
  76216. * The animation used by the runtime animation
  76217. */
  76218. private _animation;
  76219. /**
  76220. * The target of the runtime animation
  76221. */
  76222. private _target;
  76223. /**
  76224. * The initiating animatable
  76225. */
  76226. private _host;
  76227. /**
  76228. * The original value of the runtime animation
  76229. */
  76230. private _originalValue;
  76231. /**
  76232. * The original blend value of the runtime animation
  76233. */
  76234. private _originalBlendValue;
  76235. /**
  76236. * The offsets cache of the runtime animation
  76237. */
  76238. private _offsetsCache;
  76239. /**
  76240. * The high limits cache of the runtime animation
  76241. */
  76242. private _highLimitsCache;
  76243. /**
  76244. * Specifies if the runtime animation has been stopped
  76245. */
  76246. private _stopped;
  76247. /**
  76248. * The blending factor of the runtime animation
  76249. */
  76250. private _blendingFactor;
  76251. /**
  76252. * The BabylonJS scene
  76253. */
  76254. private _scene;
  76255. /**
  76256. * The current value of the runtime animation
  76257. */
  76258. private _currentValue;
  76259. /** @hidden */
  76260. _animationState: _IAnimationState;
  76261. /**
  76262. * The active target of the runtime animation
  76263. */
  76264. private _activeTargets;
  76265. private _currentActiveTarget;
  76266. private _directTarget;
  76267. /**
  76268. * The target path of the runtime animation
  76269. */
  76270. private _targetPath;
  76271. /**
  76272. * The weight of the runtime animation
  76273. */
  76274. private _weight;
  76275. /**
  76276. * The ratio offset of the runtime animation
  76277. */
  76278. private _ratioOffset;
  76279. /**
  76280. * The previous delay of the runtime animation
  76281. */
  76282. private _previousDelay;
  76283. /**
  76284. * The previous ratio of the runtime animation
  76285. */
  76286. private _previousRatio;
  76287. private _enableBlending;
  76288. private _keys;
  76289. private _minFrame;
  76290. private _maxFrame;
  76291. private _minValue;
  76292. private _maxValue;
  76293. private _targetIsArray;
  76294. /**
  76295. * Gets the current frame of the runtime animation
  76296. */
  76297. readonly currentFrame: number;
  76298. /**
  76299. * Gets the weight of the runtime animation
  76300. */
  76301. readonly weight: number;
  76302. /**
  76303. * Gets the current value of the runtime animation
  76304. */
  76305. readonly currentValue: any;
  76306. /**
  76307. * Gets the target path of the runtime animation
  76308. */
  76309. readonly targetPath: string;
  76310. /**
  76311. * Gets the actual target of the runtime animation
  76312. */
  76313. readonly target: any;
  76314. /** @hidden */
  76315. _onLoop: () => void;
  76316. /**
  76317. * Create a new RuntimeAnimation object
  76318. * @param target defines the target of the animation
  76319. * @param animation defines the source animation object
  76320. * @param scene defines the hosting scene
  76321. * @param host defines the initiating Animatable
  76322. */
  76323. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76324. private _preparePath;
  76325. /**
  76326. * Gets the animation from the runtime animation
  76327. */
  76328. readonly animation: Animation;
  76329. /**
  76330. * Resets the runtime animation to the beginning
  76331. * @param restoreOriginal defines whether to restore the target property to the original value
  76332. */
  76333. reset(restoreOriginal?: boolean): void;
  76334. /**
  76335. * Specifies if the runtime animation is stopped
  76336. * @returns Boolean specifying if the runtime animation is stopped
  76337. */
  76338. isStopped(): boolean;
  76339. /**
  76340. * Disposes of the runtime animation
  76341. */
  76342. dispose(): void;
  76343. /**
  76344. * Apply the interpolated value to the target
  76345. * @param currentValue defines the value computed by the animation
  76346. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76347. */
  76348. setValue(currentValue: any, weight: number): void;
  76349. private _getOriginalValues;
  76350. private _setValue;
  76351. /**
  76352. * Gets the loop pmode of the runtime animation
  76353. * @returns Loop Mode
  76354. */
  76355. private _getCorrectLoopMode;
  76356. /**
  76357. * Move the current animation to a given frame
  76358. * @param frame defines the frame to move to
  76359. */
  76360. goToFrame(frame: number): void;
  76361. /**
  76362. * @hidden Internal use only
  76363. */
  76364. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76365. /**
  76366. * Execute the current animation
  76367. * @param delay defines the delay to add to the current frame
  76368. * @param from defines the lower bound of the animation range
  76369. * @param to defines the upper bound of the animation range
  76370. * @param loop defines if the current animation must loop
  76371. * @param speedRatio defines the current speed ratio
  76372. * @param weight defines the weight of the animation (default is -1 so no weight)
  76373. * @param onLoop optional callback called when animation loops
  76374. * @returns a boolean indicating if the animation is running
  76375. */
  76376. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  76377. }
  76378. }
  76379. declare module BABYLON {
  76380. /**
  76381. * Class used to store an actual running animation
  76382. */
  76383. export class Animatable {
  76384. /** defines the target object */
  76385. target: any;
  76386. /** defines the starting frame number (default is 0) */
  76387. fromFrame: number;
  76388. /** defines the ending frame number (default is 100) */
  76389. toFrame: number;
  76390. /** defines if the animation must loop (default is false) */
  76391. loopAnimation: boolean;
  76392. /** defines a callback to call when animation ends if it is not looping */
  76393. onAnimationEnd?: (() => void) | null | undefined;
  76394. /** defines a callback to call when animation loops */
  76395. onAnimationLoop?: (() => void) | null | undefined;
  76396. private _localDelayOffset;
  76397. private _pausedDelay;
  76398. private _runtimeAnimations;
  76399. private _paused;
  76400. private _scene;
  76401. private _speedRatio;
  76402. private _weight;
  76403. private _syncRoot;
  76404. /**
  76405. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76406. * This will only apply for non looping animation (default is true)
  76407. */
  76408. disposeOnEnd: boolean;
  76409. /**
  76410. * Gets a boolean indicating if the animation has started
  76411. */
  76412. animationStarted: boolean;
  76413. /**
  76414. * Observer raised when the animation ends
  76415. */
  76416. onAnimationEndObservable: Observable<Animatable>;
  76417. /**
  76418. * Observer raised when the animation loops
  76419. */
  76420. onAnimationLoopObservable: Observable<Animatable>;
  76421. /**
  76422. * Gets the root Animatable used to synchronize and normalize animations
  76423. */
  76424. readonly syncRoot: Nullable<Animatable>;
  76425. /**
  76426. * Gets the current frame of the first RuntimeAnimation
  76427. * Used to synchronize Animatables
  76428. */
  76429. readonly masterFrame: number;
  76430. /**
  76431. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76432. */
  76433. weight: number;
  76434. /**
  76435. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76436. */
  76437. speedRatio: number;
  76438. /**
  76439. * Creates a new Animatable
  76440. * @param scene defines the hosting scene
  76441. * @param target defines the target object
  76442. * @param fromFrame defines the starting frame number (default is 0)
  76443. * @param toFrame defines the ending frame number (default is 100)
  76444. * @param loopAnimation defines if the animation must loop (default is false)
  76445. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76446. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76447. * @param animations defines a group of animation to add to the new Animatable
  76448. * @param onAnimationLoop defines a callback to call when animation loops
  76449. */
  76450. constructor(scene: Scene,
  76451. /** defines the target object */
  76452. target: any,
  76453. /** defines the starting frame number (default is 0) */
  76454. fromFrame?: number,
  76455. /** defines the ending frame number (default is 100) */
  76456. toFrame?: number,
  76457. /** defines if the animation must loop (default is false) */
  76458. loopAnimation?: boolean, speedRatio?: number,
  76459. /** defines a callback to call when animation ends if it is not looping */
  76460. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76461. /** defines a callback to call when animation loops */
  76462. onAnimationLoop?: (() => void) | null | undefined);
  76463. /**
  76464. * Synchronize and normalize current Animatable with a source Animatable
  76465. * This is useful when using animation weights and when animations are not of the same length
  76466. * @param root defines the root Animatable to synchronize with
  76467. * @returns the current Animatable
  76468. */
  76469. syncWith(root: Animatable): Animatable;
  76470. /**
  76471. * Gets the list of runtime animations
  76472. * @returns an array of RuntimeAnimation
  76473. */
  76474. getAnimations(): RuntimeAnimation[];
  76475. /**
  76476. * Adds more animations to the current animatable
  76477. * @param target defines the target of the animations
  76478. * @param animations defines the new animations to add
  76479. */
  76480. appendAnimations(target: any, animations: Animation[]): void;
  76481. /**
  76482. * Gets the source animation for a specific property
  76483. * @param property defines the propertyu to look for
  76484. * @returns null or the source animation for the given property
  76485. */
  76486. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76487. /**
  76488. * Gets the runtime animation for a specific property
  76489. * @param property defines the propertyu to look for
  76490. * @returns null or the runtime animation for the given property
  76491. */
  76492. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76493. /**
  76494. * Resets the animatable to its original state
  76495. */
  76496. reset(): void;
  76497. /**
  76498. * Allows the animatable to blend with current running animations
  76499. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76500. * @param blendingSpeed defines the blending speed to use
  76501. */
  76502. enableBlending(blendingSpeed: number): void;
  76503. /**
  76504. * Disable animation blending
  76505. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76506. */
  76507. disableBlending(): void;
  76508. /**
  76509. * Jump directly to a given frame
  76510. * @param frame defines the frame to jump to
  76511. */
  76512. goToFrame(frame: number): void;
  76513. /**
  76514. * Pause the animation
  76515. */
  76516. pause(): void;
  76517. /**
  76518. * Restart the animation
  76519. */
  76520. restart(): void;
  76521. private _raiseOnAnimationEnd;
  76522. /**
  76523. * Stop and delete the current animation
  76524. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76525. * @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)
  76526. */
  76527. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76528. /**
  76529. * Wait asynchronously for the animation to end
  76530. * @returns a promise which will be fullfilled when the animation ends
  76531. */
  76532. waitAsync(): Promise<Animatable>;
  76533. /** @hidden */
  76534. _animate(delay: number): boolean;
  76535. }
  76536. interface Scene {
  76537. /** @hidden */
  76538. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76539. /** @hidden */
  76540. _processLateAnimationBindingsForMatrices(holder: {
  76541. totalWeight: number;
  76542. animations: RuntimeAnimation[];
  76543. originalValue: Matrix;
  76544. }): any;
  76545. /** @hidden */
  76546. _processLateAnimationBindingsForQuaternions(holder: {
  76547. totalWeight: number;
  76548. animations: RuntimeAnimation[];
  76549. originalValue: Quaternion;
  76550. }, refQuaternion: Quaternion): Quaternion;
  76551. /** @hidden */
  76552. _processLateAnimationBindings(): void;
  76553. /**
  76554. * Will start the animation sequence of a given target
  76555. * @param target defines the target
  76556. * @param from defines from which frame should animation start
  76557. * @param to defines until which frame should animation run.
  76558. * @param weight defines the weight to apply to the animation (1.0 by default)
  76559. * @param loop defines if the animation loops
  76560. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76561. * @param onAnimationEnd defines the function to be executed when the animation ends
  76562. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76563. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76564. * @param onAnimationLoop defines the callback to call when an animation loops
  76565. * @returns the animatable object created for this animation
  76566. */
  76567. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76568. /**
  76569. * Will start the animation sequence of a given target
  76570. * @param target defines the target
  76571. * @param from defines from which frame should animation start
  76572. * @param to defines until which frame should animation run.
  76573. * @param loop defines if the animation loops
  76574. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76575. * @param onAnimationEnd defines the function to be executed when the animation ends
  76576. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76577. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76578. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76579. * @param onAnimationLoop defines the callback to call when an animation loops
  76580. * @returns the animatable object created for this animation
  76581. */
  76582. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76583. /**
  76584. * Will start the animation sequence of a given target and its hierarchy
  76585. * @param target defines the target
  76586. * @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.
  76587. * @param from defines from which frame should animation start
  76588. * @param to defines until which frame should animation run.
  76589. * @param loop defines if the animation loops
  76590. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76591. * @param onAnimationEnd defines the function to be executed when the animation ends
  76592. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76593. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76594. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76595. * @param onAnimationLoop defines the callback to call when an animation loops
  76596. * @returns the list of created animatables
  76597. */
  76598. 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[];
  76599. /**
  76600. * Begin a new animation on a given node
  76601. * @param target defines the target where the animation will take place
  76602. * @param animations defines the list of animations to start
  76603. * @param from defines the initial value
  76604. * @param to defines the final value
  76605. * @param loop defines if you want animation to loop (off by default)
  76606. * @param speedRatio defines the speed ratio to apply to all animations
  76607. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76608. * @param onAnimationLoop defines the callback to call when an animation loops
  76609. * @returns the list of created animatables
  76610. */
  76611. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76612. /**
  76613. * Begin a new animation on a given node and its hierarchy
  76614. * @param target defines the root node where the animation will take place
  76615. * @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.
  76616. * @param animations defines the list of animations to start
  76617. * @param from defines the initial value
  76618. * @param to defines the final value
  76619. * @param loop defines if you want animation to loop (off by default)
  76620. * @param speedRatio defines the speed ratio to apply to all animations
  76621. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76622. * @param onAnimationLoop defines the callback to call when an animation loops
  76623. * @returns the list of animatables created for all nodes
  76624. */
  76625. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76626. /**
  76627. * Gets the animatable associated with a specific target
  76628. * @param target defines the target of the animatable
  76629. * @returns the required animatable if found
  76630. */
  76631. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76632. /**
  76633. * Gets all animatables associated with a given target
  76634. * @param target defines the target to look animatables for
  76635. * @returns an array of Animatables
  76636. */
  76637. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76638. /**
  76639. * Stops and removes all animations that have been applied to the scene
  76640. */
  76641. stopAllAnimations(): void;
  76642. }
  76643. interface Bone {
  76644. /**
  76645. * Copy an animation range from another bone
  76646. * @param source defines the source bone
  76647. * @param rangeName defines the range name to copy
  76648. * @param frameOffset defines the frame offset
  76649. * @param rescaleAsRequired defines if rescaling must be applied if required
  76650. * @param skelDimensionsRatio defines the scaling ratio
  76651. * @returns true if operation was successful
  76652. */
  76653. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76654. }
  76655. }
  76656. declare module BABYLON {
  76657. /**
  76658. * Class used to override all child animations of a given target
  76659. */
  76660. export class AnimationPropertiesOverride {
  76661. /**
  76662. * Gets or sets a value indicating if animation blending must be used
  76663. */
  76664. enableBlending: boolean;
  76665. /**
  76666. * Gets or sets the blending speed to use when enableBlending is true
  76667. */
  76668. blendingSpeed: number;
  76669. /**
  76670. * Gets or sets the default loop mode to use
  76671. */
  76672. loopMode: number;
  76673. }
  76674. }
  76675. declare module BABYLON {
  76676. /**
  76677. * Class used to handle skinning animations
  76678. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76679. */
  76680. export class Skeleton implements IAnimatable {
  76681. /** defines the skeleton name */
  76682. name: string;
  76683. /** defines the skeleton Id */
  76684. id: string;
  76685. /**
  76686. * Defines the list of child bones
  76687. */
  76688. bones: Bone[];
  76689. /**
  76690. * Defines an estimate of the dimension of the skeleton at rest
  76691. */
  76692. dimensionsAtRest: Vector3;
  76693. /**
  76694. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76695. */
  76696. needInitialSkinMatrix: boolean;
  76697. /**
  76698. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76699. */
  76700. overrideMesh: Nullable<AbstractMesh>;
  76701. /**
  76702. * Gets the list of animations attached to this skeleton
  76703. */
  76704. animations: Array<Animation>;
  76705. private _scene;
  76706. private _isDirty;
  76707. private _transformMatrices;
  76708. private _transformMatrixTexture;
  76709. private _meshesWithPoseMatrix;
  76710. private _animatables;
  76711. private _identity;
  76712. private _synchronizedWithMesh;
  76713. private _ranges;
  76714. private _lastAbsoluteTransformsUpdateId;
  76715. private _canUseTextureForBones;
  76716. private _uniqueId;
  76717. /** @hidden */
  76718. _numBonesWithLinkedTransformNode: number;
  76719. /** @hidden */
  76720. _hasWaitingData: Nullable<boolean>;
  76721. /**
  76722. * Specifies if the skeleton should be serialized
  76723. */
  76724. doNotSerialize: boolean;
  76725. private _useTextureToStoreBoneMatrices;
  76726. /**
  76727. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76728. * Please note that this option is not available if the hardware does not support it
  76729. */
  76730. useTextureToStoreBoneMatrices: boolean;
  76731. private _animationPropertiesOverride;
  76732. /**
  76733. * Gets or sets the animation properties override
  76734. */
  76735. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76736. /**
  76737. * List of inspectable custom properties (used by the Inspector)
  76738. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76739. */
  76740. inspectableCustomProperties: IInspectable[];
  76741. /**
  76742. * An observable triggered before computing the skeleton's matrices
  76743. */
  76744. onBeforeComputeObservable: Observable<Skeleton>;
  76745. /**
  76746. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76747. */
  76748. readonly isUsingTextureForMatrices: boolean;
  76749. /**
  76750. * Gets the unique ID of this skeleton
  76751. */
  76752. readonly uniqueId: number;
  76753. /**
  76754. * Creates a new skeleton
  76755. * @param name defines the skeleton name
  76756. * @param id defines the skeleton Id
  76757. * @param scene defines the hosting scene
  76758. */
  76759. constructor(
  76760. /** defines the skeleton name */
  76761. name: string,
  76762. /** defines the skeleton Id */
  76763. id: string, scene: Scene);
  76764. /**
  76765. * Gets the current object class name.
  76766. * @return the class name
  76767. */
  76768. getClassName(): string;
  76769. /**
  76770. * Returns an array containing the root bones
  76771. * @returns an array containing the root bones
  76772. */
  76773. getChildren(): Array<Bone>;
  76774. /**
  76775. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76776. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76777. * @returns a Float32Array containing matrices data
  76778. */
  76779. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76780. /**
  76781. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76782. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76783. * @returns a raw texture containing the data
  76784. */
  76785. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  76786. /**
  76787. * Gets the current hosting scene
  76788. * @returns a scene object
  76789. */
  76790. getScene(): Scene;
  76791. /**
  76792. * Gets a string representing the current skeleton data
  76793. * @param fullDetails defines a boolean indicating if we want a verbose version
  76794. * @returns a string representing the current skeleton data
  76795. */
  76796. toString(fullDetails?: boolean): string;
  76797. /**
  76798. * Get bone's index searching by name
  76799. * @param name defines bone's name to search for
  76800. * @return the indice of the bone. Returns -1 if not found
  76801. */
  76802. getBoneIndexByName(name: string): number;
  76803. /**
  76804. * Creater a new animation range
  76805. * @param name defines the name of the range
  76806. * @param from defines the start key
  76807. * @param to defines the end key
  76808. */
  76809. createAnimationRange(name: string, from: number, to: number): void;
  76810. /**
  76811. * Delete a specific animation range
  76812. * @param name defines the name of the range
  76813. * @param deleteFrames defines if frames must be removed as well
  76814. */
  76815. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76816. /**
  76817. * Gets a specific animation range
  76818. * @param name defines the name of the range to look for
  76819. * @returns the requested animation range or null if not found
  76820. */
  76821. getAnimationRange(name: string): Nullable<AnimationRange>;
  76822. /**
  76823. * Gets the list of all animation ranges defined on this skeleton
  76824. * @returns an array
  76825. */
  76826. getAnimationRanges(): Nullable<AnimationRange>[];
  76827. /**
  76828. * Copy animation range from a source skeleton.
  76829. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76830. * @param source defines the source skeleton
  76831. * @param name defines the name of the range to copy
  76832. * @param rescaleAsRequired defines if rescaling must be applied if required
  76833. * @returns true if operation was successful
  76834. */
  76835. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76836. /**
  76837. * Forces the skeleton to go to rest pose
  76838. */
  76839. returnToRest(): void;
  76840. private _getHighestAnimationFrame;
  76841. /**
  76842. * Begin a specific animation range
  76843. * @param name defines the name of the range to start
  76844. * @param loop defines if looping must be turned on (false by default)
  76845. * @param speedRatio defines the speed ratio to apply (1 by default)
  76846. * @param onAnimationEnd defines a callback which will be called when animation will end
  76847. * @returns a new animatable
  76848. */
  76849. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76850. /** @hidden */
  76851. _markAsDirty(): void;
  76852. /** @hidden */
  76853. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76854. /** @hidden */
  76855. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76856. private _computeTransformMatrices;
  76857. /**
  76858. * Build all resources required to render a skeleton
  76859. */
  76860. prepare(): void;
  76861. /**
  76862. * Gets the list of animatables currently running for this skeleton
  76863. * @returns an array of animatables
  76864. */
  76865. getAnimatables(): IAnimatable[];
  76866. /**
  76867. * Clone the current skeleton
  76868. * @param name defines the name of the new skeleton
  76869. * @param id defines the id of the new skeleton
  76870. * @returns the new skeleton
  76871. */
  76872. clone(name: string, id: string): Skeleton;
  76873. /**
  76874. * Enable animation blending for this skeleton
  76875. * @param blendingSpeed defines the blending speed to apply
  76876. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76877. */
  76878. enableBlending(blendingSpeed?: number): void;
  76879. /**
  76880. * Releases all resources associated with the current skeleton
  76881. */
  76882. dispose(): void;
  76883. /**
  76884. * Serialize the skeleton in a JSON object
  76885. * @returns a JSON object
  76886. */
  76887. serialize(): any;
  76888. /**
  76889. * Creates a new skeleton from serialized data
  76890. * @param parsedSkeleton defines the serialized data
  76891. * @param scene defines the hosting scene
  76892. * @returns a new skeleton
  76893. */
  76894. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76895. /**
  76896. * Compute all node absolute transforms
  76897. * @param forceUpdate defines if computation must be done even if cache is up to date
  76898. */
  76899. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76900. /**
  76901. * Gets the root pose matrix
  76902. * @returns a matrix
  76903. */
  76904. getPoseMatrix(): Nullable<Matrix>;
  76905. /**
  76906. * Sorts bones per internal index
  76907. */
  76908. sortBones(): void;
  76909. private _sortBones;
  76910. }
  76911. }
  76912. declare module BABYLON {
  76913. /**
  76914. * Class used to store bone information
  76915. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76916. */
  76917. export class Bone extends Node {
  76918. /**
  76919. * defines the bone name
  76920. */
  76921. name: string;
  76922. private static _tmpVecs;
  76923. private static _tmpQuat;
  76924. private static _tmpMats;
  76925. /**
  76926. * Gets the list of child bones
  76927. */
  76928. children: Bone[];
  76929. /** Gets the animations associated with this bone */
  76930. animations: Animation[];
  76931. /**
  76932. * Gets or sets bone length
  76933. */
  76934. length: number;
  76935. /**
  76936. * @hidden Internal only
  76937. * Set this value to map this bone to a different index in the transform matrices
  76938. * Set this value to -1 to exclude the bone from the transform matrices
  76939. */
  76940. _index: Nullable<number>;
  76941. private _skeleton;
  76942. private _localMatrix;
  76943. private _restPose;
  76944. private _baseMatrix;
  76945. private _absoluteTransform;
  76946. private _invertedAbsoluteTransform;
  76947. private _parent;
  76948. private _scalingDeterminant;
  76949. private _worldTransform;
  76950. private _localScaling;
  76951. private _localRotation;
  76952. private _localPosition;
  76953. private _needToDecompose;
  76954. private _needToCompose;
  76955. /** @hidden */
  76956. _linkedTransformNode: Nullable<TransformNode>;
  76957. /** @hidden */
  76958. _waitingTransformNodeId: Nullable<string>;
  76959. /** @hidden */
  76960. /** @hidden */
  76961. _matrix: Matrix;
  76962. /**
  76963. * Create a new bone
  76964. * @param name defines the bone name
  76965. * @param skeleton defines the parent skeleton
  76966. * @param parentBone defines the parent (can be null if the bone is the root)
  76967. * @param localMatrix defines the local matrix
  76968. * @param restPose defines the rest pose matrix
  76969. * @param baseMatrix defines the base matrix
  76970. * @param index defines index of the bone in the hiearchy
  76971. */
  76972. constructor(
  76973. /**
  76974. * defines the bone name
  76975. */
  76976. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  76977. /**
  76978. * Gets the current object class name.
  76979. * @return the class name
  76980. */
  76981. getClassName(): string;
  76982. /**
  76983. * Gets the parent skeleton
  76984. * @returns a skeleton
  76985. */
  76986. getSkeleton(): Skeleton;
  76987. /**
  76988. * Gets parent bone
  76989. * @returns a bone or null if the bone is the root of the bone hierarchy
  76990. */
  76991. getParent(): Nullable<Bone>;
  76992. /**
  76993. * Returns an array containing the root bones
  76994. * @returns an array containing the root bones
  76995. */
  76996. getChildren(): Array<Bone>;
  76997. /**
  76998. * Sets the parent bone
  76999. * @param parent defines the parent (can be null if the bone is the root)
  77000. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77001. */
  77002. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77003. /**
  77004. * Gets the local matrix
  77005. * @returns a matrix
  77006. */
  77007. getLocalMatrix(): Matrix;
  77008. /**
  77009. * Gets the base matrix (initial matrix which remains unchanged)
  77010. * @returns a matrix
  77011. */
  77012. getBaseMatrix(): Matrix;
  77013. /**
  77014. * Gets the rest pose matrix
  77015. * @returns a matrix
  77016. */
  77017. getRestPose(): Matrix;
  77018. /**
  77019. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77020. */
  77021. getWorldMatrix(): Matrix;
  77022. /**
  77023. * Sets the local matrix to rest pose matrix
  77024. */
  77025. returnToRest(): void;
  77026. /**
  77027. * Gets the inverse of the absolute transform matrix.
  77028. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77029. * @returns a matrix
  77030. */
  77031. getInvertedAbsoluteTransform(): Matrix;
  77032. /**
  77033. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77034. * @returns a matrix
  77035. */
  77036. getAbsoluteTransform(): Matrix;
  77037. /**
  77038. * Links with the given transform node.
  77039. * The local matrix of this bone is copied from the transform node every frame.
  77040. * @param transformNode defines the transform node to link to
  77041. */
  77042. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77043. /** Gets or sets current position (in local space) */
  77044. position: Vector3;
  77045. /** Gets or sets current rotation (in local space) */
  77046. rotation: Vector3;
  77047. /** Gets or sets current rotation quaternion (in local space) */
  77048. rotationQuaternion: Quaternion;
  77049. /** Gets or sets current scaling (in local space) */
  77050. scaling: Vector3;
  77051. /**
  77052. * Gets the animation properties override
  77053. */
  77054. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77055. private _decompose;
  77056. private _compose;
  77057. /**
  77058. * Update the base and local matrices
  77059. * @param matrix defines the new base or local matrix
  77060. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77061. * @param updateLocalMatrix defines if the local matrix should be updated
  77062. */
  77063. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77064. /** @hidden */
  77065. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77066. /**
  77067. * Flag the bone as dirty (Forcing it to update everything)
  77068. */
  77069. markAsDirty(): void;
  77070. /** @hidden */
  77071. _markAsDirtyAndCompose(): void;
  77072. private _markAsDirtyAndDecompose;
  77073. /**
  77074. * Translate the bone in local or world space
  77075. * @param vec The amount to translate the bone
  77076. * @param space The space that the translation is in
  77077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77078. */
  77079. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77080. /**
  77081. * Set the postion of the bone in local or world space
  77082. * @param position The position to set the bone
  77083. * @param space The space that the position is in
  77084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77085. */
  77086. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77087. /**
  77088. * Set the absolute position of the bone (world space)
  77089. * @param position The position to set the bone
  77090. * @param mesh The mesh that this bone is attached to
  77091. */
  77092. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77093. /**
  77094. * Scale the bone on the x, y and z axes (in local space)
  77095. * @param x The amount to scale the bone on the x axis
  77096. * @param y The amount to scale the bone on the y axis
  77097. * @param z The amount to scale the bone on the z axis
  77098. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77099. */
  77100. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77101. /**
  77102. * Set the bone scaling in local space
  77103. * @param scale defines the scaling vector
  77104. */
  77105. setScale(scale: Vector3): void;
  77106. /**
  77107. * Gets the current scaling in local space
  77108. * @returns the current scaling vector
  77109. */
  77110. getScale(): Vector3;
  77111. /**
  77112. * Gets the current scaling in local space and stores it in a target vector
  77113. * @param result defines the target vector
  77114. */
  77115. getScaleToRef(result: Vector3): void;
  77116. /**
  77117. * Set the yaw, pitch, and roll of the bone in local or world space
  77118. * @param yaw The rotation of the bone on the y axis
  77119. * @param pitch The rotation of the bone on the x axis
  77120. * @param roll The rotation of the bone on the z axis
  77121. * @param space The space that the axes of rotation are in
  77122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77123. */
  77124. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  77125. /**
  77126. * Add a rotation to the bone on an axis in local or world space
  77127. * @param axis The axis to rotate the bone on
  77128. * @param amount The amount to rotate the bone
  77129. * @param space The space that the axis is in
  77130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77131. */
  77132. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  77133. /**
  77134. * Set the rotation of the bone to a particular axis angle in local or world space
  77135. * @param axis The axis to rotate the bone on
  77136. * @param angle The angle that the bone should be rotated to
  77137. * @param space The space that the axis is in
  77138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77139. */
  77140. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  77141. /**
  77142. * Set the euler rotation of the bone in local of world space
  77143. * @param rotation The euler rotation that the bone should be set to
  77144. * @param space The space that the rotation is in
  77145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77146. */
  77147. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77148. /**
  77149. * Set the quaternion rotation of the bone in local of world space
  77150. * @param quat The quaternion rotation that the bone should be set to
  77151. * @param space The space that the rotation is in
  77152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77153. */
  77154. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  77155. /**
  77156. * Set the rotation matrix of the bone in local of world space
  77157. * @param rotMat The rotation matrix that the bone should be set to
  77158. * @param space The space that the rotation is in
  77159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77160. */
  77161. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  77162. private _rotateWithMatrix;
  77163. private _getNegativeRotationToRef;
  77164. /**
  77165. * Get the position of the bone in local or world space
  77166. * @param space The space that the returned position is in
  77167. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77168. * @returns The position of the bone
  77169. */
  77170. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77171. /**
  77172. * Copy the position of the bone to a vector3 in local or world space
  77173. * @param space The space that the returned position is in
  77174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77175. * @param result The vector3 to copy the position to
  77176. */
  77177. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  77178. /**
  77179. * Get the absolute position of the bone (world space)
  77180. * @param mesh The mesh that this bone is attached to
  77181. * @returns The absolute position of the bone
  77182. */
  77183. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  77184. /**
  77185. * Copy the absolute position of the bone (world space) to the result param
  77186. * @param mesh The mesh that this bone is attached to
  77187. * @param result The vector3 to copy the absolute position to
  77188. */
  77189. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  77190. /**
  77191. * Compute the absolute transforms of this bone and its children
  77192. */
  77193. computeAbsoluteTransforms(): void;
  77194. /**
  77195. * Get the world direction from an axis that is in the local space of the bone
  77196. * @param localAxis The local direction that is used to compute the world direction
  77197. * @param mesh The mesh that this bone is attached to
  77198. * @returns The world direction
  77199. */
  77200. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77201. /**
  77202. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  77203. * @param localAxis The local direction that is used to compute the world direction
  77204. * @param mesh The mesh that this bone is attached to
  77205. * @param result The vector3 that the world direction will be copied to
  77206. */
  77207. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77208. /**
  77209. * Get the euler rotation of the bone in local or world space
  77210. * @param space The space that the rotation should be in
  77211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77212. * @returns The euler rotation
  77213. */
  77214. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77215. /**
  77216. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  77217. * @param space The space that the rotation should be in
  77218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77219. * @param result The vector3 that the rotation should be copied to
  77220. */
  77221. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77222. /**
  77223. * Get the quaternion rotation of the bone in either local or world space
  77224. * @param space The space that the rotation should be in
  77225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77226. * @returns The quaternion rotation
  77227. */
  77228. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  77229. /**
  77230. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  77231. * @param space The space that the rotation should be in
  77232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77233. * @param result The quaternion that the rotation should be copied to
  77234. */
  77235. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  77236. /**
  77237. * Get the rotation matrix of the bone in local or world space
  77238. * @param space The space that the rotation should be in
  77239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77240. * @returns The rotation matrix
  77241. */
  77242. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  77243. /**
  77244. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  77245. * @param space The space that the rotation should be in
  77246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77247. * @param result The quaternion that the rotation should be copied to
  77248. */
  77249. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  77250. /**
  77251. * Get the world position of a point that is in the local space of the bone
  77252. * @param position The local position
  77253. * @param mesh The mesh that this bone is attached to
  77254. * @returns The world position
  77255. */
  77256. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77257. /**
  77258. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  77259. * @param position The local position
  77260. * @param mesh The mesh that this bone is attached to
  77261. * @param result The vector3 that the world position should be copied to
  77262. */
  77263. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77264. /**
  77265. * Get the local position of a point that is in world space
  77266. * @param position The world position
  77267. * @param mesh The mesh that this bone is attached to
  77268. * @returns The local position
  77269. */
  77270. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77271. /**
  77272. * Get the local position of a point that is in world space and copy it to the result param
  77273. * @param position The world position
  77274. * @param mesh The mesh that this bone is attached to
  77275. * @param result The vector3 that the local position should be copied to
  77276. */
  77277. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77278. }
  77279. }
  77280. declare module BABYLON {
  77281. /**
  77282. * 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.
  77283. * @see https://doc.babylonjs.com/how_to/transformnode
  77284. */
  77285. export class TransformNode extends Node {
  77286. /**
  77287. * Object will not rotate to face the camera
  77288. */
  77289. static BILLBOARDMODE_NONE: number;
  77290. /**
  77291. * Object will rotate to face the camera but only on the x axis
  77292. */
  77293. static BILLBOARDMODE_X: number;
  77294. /**
  77295. * Object will rotate to face the camera but only on the y axis
  77296. */
  77297. static BILLBOARDMODE_Y: number;
  77298. /**
  77299. * Object will rotate to face the camera but only on the z axis
  77300. */
  77301. static BILLBOARDMODE_Z: number;
  77302. /**
  77303. * Object will rotate to face the camera
  77304. */
  77305. static BILLBOARDMODE_ALL: number;
  77306. private _forward;
  77307. private _forwardInverted;
  77308. private _up;
  77309. private _right;
  77310. private _rightInverted;
  77311. private _position;
  77312. private _rotation;
  77313. private _rotationQuaternion;
  77314. protected _scaling: Vector3;
  77315. protected _isDirty: boolean;
  77316. private _transformToBoneReferal;
  77317. private _billboardMode;
  77318. /**
  77319. * Gets or sets the billboard mode. Default is 0.
  77320. *
  77321. * | Value | Type | Description |
  77322. * | --- | --- | --- |
  77323. * | 0 | BILLBOARDMODE_NONE | |
  77324. * | 1 | BILLBOARDMODE_X | |
  77325. * | 2 | BILLBOARDMODE_Y | |
  77326. * | 4 | BILLBOARDMODE_Z | |
  77327. * | 7 | BILLBOARDMODE_ALL | |
  77328. *
  77329. */
  77330. billboardMode: number;
  77331. private _preserveParentRotationForBillboard;
  77332. /**
  77333. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  77334. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  77335. */
  77336. preserveParentRotationForBillboard: boolean;
  77337. /**
  77338. * 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
  77339. */
  77340. scalingDeterminant: number;
  77341. private _infiniteDistance;
  77342. /**
  77343. * Gets or sets the distance of the object to max, often used by skybox
  77344. */
  77345. infiniteDistance: boolean;
  77346. /**
  77347. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  77348. * By default the system will update normals to compensate
  77349. */
  77350. ignoreNonUniformScaling: boolean;
  77351. /**
  77352. * 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
  77353. */
  77354. reIntegrateRotationIntoRotationQuaternion: boolean;
  77355. /** @hidden */
  77356. _poseMatrix: Nullable<Matrix>;
  77357. /** @hidden */
  77358. _localMatrix: Matrix;
  77359. private _usePivotMatrix;
  77360. private _absolutePosition;
  77361. private _pivotMatrix;
  77362. private _pivotMatrixInverse;
  77363. protected _postMultiplyPivotMatrix: boolean;
  77364. protected _isWorldMatrixFrozen: boolean;
  77365. /** @hidden */
  77366. _indexInSceneTransformNodesArray: number;
  77367. /**
  77368. * An event triggered after the world matrix is updated
  77369. */
  77370. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  77371. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  77372. /**
  77373. * Gets a string identifying the name of the class
  77374. * @returns "TransformNode" string
  77375. */
  77376. getClassName(): string;
  77377. /**
  77378. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  77379. */
  77380. position: Vector3;
  77381. /**
  77382. * 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)).
  77383. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  77384. */
  77385. rotation: Vector3;
  77386. /**
  77387. * 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)).
  77388. */
  77389. scaling: Vector3;
  77390. /**
  77391. * 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).
  77392. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  77393. */
  77394. rotationQuaternion: Nullable<Quaternion>;
  77395. /**
  77396. * The forward direction of that transform in world space.
  77397. */
  77398. readonly forward: Vector3;
  77399. /**
  77400. * The up direction of that transform in world space.
  77401. */
  77402. readonly up: Vector3;
  77403. /**
  77404. * The right direction of that transform in world space.
  77405. */
  77406. readonly right: Vector3;
  77407. /**
  77408. * Copies the parameter passed Matrix into the mesh Pose matrix.
  77409. * @param matrix the matrix to copy the pose from
  77410. * @returns this TransformNode.
  77411. */
  77412. updatePoseMatrix(matrix: Matrix): TransformNode;
  77413. /**
  77414. * Returns the mesh Pose matrix.
  77415. * @returns the pose matrix
  77416. */
  77417. getPoseMatrix(): Matrix;
  77418. /** @hidden */
  77419. _isSynchronized(): boolean;
  77420. /** @hidden */
  77421. _initCache(): void;
  77422. /**
  77423. * Flag the transform node as dirty (Forcing it to update everything)
  77424. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  77425. * @returns this transform node
  77426. */
  77427. markAsDirty(property: string): TransformNode;
  77428. /**
  77429. * Returns the current mesh absolute position.
  77430. * Returns a Vector3.
  77431. */
  77432. readonly absolutePosition: Vector3;
  77433. /**
  77434. * Sets a new matrix to apply before all other transformation
  77435. * @param matrix defines the transform matrix
  77436. * @returns the current TransformNode
  77437. */
  77438. setPreTransformMatrix(matrix: Matrix): TransformNode;
  77439. /**
  77440. * Sets a new pivot matrix to the current node
  77441. * @param matrix defines the new pivot matrix to use
  77442. * @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
  77443. * @returns the current TransformNode
  77444. */
  77445. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  77446. /**
  77447. * Returns the mesh pivot matrix.
  77448. * Default : Identity.
  77449. * @returns the matrix
  77450. */
  77451. getPivotMatrix(): Matrix;
  77452. /**
  77453. * Prevents the World matrix to be computed any longer.
  77454. * @returns the TransformNode.
  77455. */
  77456. freezeWorldMatrix(): TransformNode;
  77457. /**
  77458. * Allows back the World matrix computation.
  77459. * @returns the TransformNode.
  77460. */
  77461. unfreezeWorldMatrix(): this;
  77462. /**
  77463. * True if the World matrix has been frozen.
  77464. */
  77465. readonly isWorldMatrixFrozen: boolean;
  77466. /**
  77467. * Retuns the mesh absolute position in the World.
  77468. * @returns a Vector3.
  77469. */
  77470. getAbsolutePosition(): Vector3;
  77471. /**
  77472. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  77473. * @param absolutePosition the absolute position to set
  77474. * @returns the TransformNode.
  77475. */
  77476. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77477. /**
  77478. * Sets the mesh position in its local space.
  77479. * @param vector3 the position to set in localspace
  77480. * @returns the TransformNode.
  77481. */
  77482. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  77483. /**
  77484. * Returns the mesh position in the local space from the current World matrix values.
  77485. * @returns a new Vector3.
  77486. */
  77487. getPositionExpressedInLocalSpace(): Vector3;
  77488. /**
  77489. * Translates the mesh along the passed Vector3 in its local space.
  77490. * @param vector3 the distance to translate in localspace
  77491. * @returns the TransformNode.
  77492. */
  77493. locallyTranslate(vector3: Vector3): TransformNode;
  77494. private static _lookAtVectorCache;
  77495. /**
  77496. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  77497. * @param targetPoint the position (must be in same space as current mesh) to look at
  77498. * @param yawCor optional yaw (y-axis) correction in radians
  77499. * @param pitchCor optional pitch (x-axis) correction in radians
  77500. * @param rollCor optional roll (z-axis) correction in radians
  77501. * @param space the choosen space of the target
  77502. * @returns the TransformNode.
  77503. */
  77504. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  77505. /**
  77506. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77507. * This Vector3 is expressed in the World space.
  77508. * @param localAxis axis to rotate
  77509. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77510. */
  77511. getDirection(localAxis: Vector3): Vector3;
  77512. /**
  77513. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  77514. * localAxis is expressed in the mesh local space.
  77515. * result is computed in the Wordl space from the mesh World matrix.
  77516. * @param localAxis axis to rotate
  77517. * @param result the resulting transformnode
  77518. * @returns this TransformNode.
  77519. */
  77520. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  77521. /**
  77522. * Sets this transform node rotation to the given local axis.
  77523. * @param localAxis the axis in local space
  77524. * @param yawCor optional yaw (y-axis) correction in radians
  77525. * @param pitchCor optional pitch (x-axis) correction in radians
  77526. * @param rollCor optional roll (z-axis) correction in radians
  77527. * @returns this TransformNode
  77528. */
  77529. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  77530. /**
  77531. * Sets a new pivot point to the current node
  77532. * @param point defines the new pivot point to use
  77533. * @param space defines if the point is in world or local space (local by default)
  77534. * @returns the current TransformNode
  77535. */
  77536. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  77537. /**
  77538. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  77539. * @returns the pivot point
  77540. */
  77541. getPivotPoint(): Vector3;
  77542. /**
  77543. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  77544. * @param result the vector3 to store the result
  77545. * @returns this TransformNode.
  77546. */
  77547. getPivotPointToRef(result: Vector3): TransformNode;
  77548. /**
  77549. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  77550. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  77551. */
  77552. getAbsolutePivotPoint(): Vector3;
  77553. /**
  77554. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  77555. * @param result vector3 to store the result
  77556. * @returns this TransformNode.
  77557. */
  77558. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  77559. /**
  77560. * Defines the passed node as the parent of the current node.
  77561. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  77562. * @see https://doc.babylonjs.com/how_to/parenting
  77563. * @param node the node ot set as the parent
  77564. * @returns this TransformNode.
  77565. */
  77566. setParent(node: Nullable<Node>): TransformNode;
  77567. private _nonUniformScaling;
  77568. /**
  77569. * True if the scaling property of this object is non uniform eg. (1,2,1)
  77570. */
  77571. readonly nonUniformScaling: boolean;
  77572. /** @hidden */
  77573. _updateNonUniformScalingState(value: boolean): boolean;
  77574. /**
  77575. * Attach the current TransformNode to another TransformNode associated with a bone
  77576. * @param bone Bone affecting the TransformNode
  77577. * @param affectedTransformNode TransformNode associated with the bone
  77578. * @returns this object
  77579. */
  77580. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  77581. /**
  77582. * Detach the transform node if its associated with a bone
  77583. * @returns this object
  77584. */
  77585. detachFromBone(): TransformNode;
  77586. private static _rotationAxisCache;
  77587. /**
  77588. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  77589. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77590. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77591. * The passed axis is also normalized.
  77592. * @param axis the axis to rotate around
  77593. * @param amount the amount to rotate in radians
  77594. * @param space Space to rotate in (Default: local)
  77595. * @returns the TransformNode.
  77596. */
  77597. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77598. /**
  77599. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  77600. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77601. * The passed axis is also normalized. .
  77602. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  77603. * @param point the point to rotate around
  77604. * @param axis the axis to rotate around
  77605. * @param amount the amount to rotate in radians
  77606. * @returns the TransformNode
  77607. */
  77608. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  77609. /**
  77610. * Translates the mesh along the axis vector for the passed distance in the given space.
  77611. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77612. * @param axis the axis to translate in
  77613. * @param distance the distance to translate
  77614. * @param space Space to rotate in (Default: local)
  77615. * @returns the TransformNode.
  77616. */
  77617. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77618. /**
  77619. * Adds a rotation step to the mesh current rotation.
  77620. * x, y, z are Euler angles expressed in radians.
  77621. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  77622. * This means this rotation is made in the mesh local space only.
  77623. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  77624. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  77625. * ```javascript
  77626. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  77627. * ```
  77628. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  77629. * 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.
  77630. * @param x Rotation to add
  77631. * @param y Rotation to add
  77632. * @param z Rotation to add
  77633. * @returns the TransformNode.
  77634. */
  77635. addRotation(x: number, y: number, z: number): TransformNode;
  77636. /**
  77637. * @hidden
  77638. */
  77639. protected _getEffectiveParent(): Nullable<Node>;
  77640. /**
  77641. * Computes the world matrix of the node
  77642. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77643. * @returns the world matrix
  77644. */
  77645. computeWorldMatrix(force?: boolean): Matrix;
  77646. protected _afterComputeWorldMatrix(): void;
  77647. /**
  77648. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  77649. * @param func callback function to add
  77650. *
  77651. * @returns the TransformNode.
  77652. */
  77653. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77654. /**
  77655. * Removes a registered callback function.
  77656. * @param func callback function to remove
  77657. * @returns the TransformNode.
  77658. */
  77659. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77660. /**
  77661. * Gets the position of the current mesh in camera space
  77662. * @param camera defines the camera to use
  77663. * @returns a position
  77664. */
  77665. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  77666. /**
  77667. * Returns the distance from the mesh to the active camera
  77668. * @param camera defines the camera to use
  77669. * @returns the distance
  77670. */
  77671. getDistanceToCamera(camera?: Nullable<Camera>): number;
  77672. /**
  77673. * Clone the current transform node
  77674. * @param name Name of the new clone
  77675. * @param newParent New parent for the clone
  77676. * @param doNotCloneChildren Do not clone children hierarchy
  77677. * @returns the new transform node
  77678. */
  77679. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  77680. /**
  77681. * Serializes the objects information.
  77682. * @param currentSerializationObject defines the object to serialize in
  77683. * @returns the serialized object
  77684. */
  77685. serialize(currentSerializationObject?: any): any;
  77686. /**
  77687. * Returns a new TransformNode object parsed from the source provided.
  77688. * @param parsedTransformNode is the source.
  77689. * @param scene the scne the object belongs to
  77690. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  77691. * @returns a new TransformNode object parsed from the source provided.
  77692. */
  77693. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  77694. /**
  77695. * Get all child-transformNodes of this node
  77696. * @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
  77697. * @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
  77698. * @returns an array of TransformNode
  77699. */
  77700. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  77701. /**
  77702. * Releases resources associated with this transform node.
  77703. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77704. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77705. */
  77706. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77707. /**
  77708. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  77709. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  77710. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  77711. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  77712. * @returns the current mesh
  77713. */
  77714. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  77715. }
  77716. }
  77717. declare module BABYLON {
  77718. /**
  77719. * Defines the types of pose enabled controllers that are supported
  77720. */
  77721. export enum PoseEnabledControllerType {
  77722. /**
  77723. * HTC Vive
  77724. */
  77725. VIVE = 0,
  77726. /**
  77727. * Oculus Rift
  77728. */
  77729. OCULUS = 1,
  77730. /**
  77731. * Windows mixed reality
  77732. */
  77733. WINDOWS = 2,
  77734. /**
  77735. * Samsung gear VR
  77736. */
  77737. GEAR_VR = 3,
  77738. /**
  77739. * Google Daydream
  77740. */
  77741. DAYDREAM = 4,
  77742. /**
  77743. * Generic
  77744. */
  77745. GENERIC = 5
  77746. }
  77747. /**
  77748. * Defines the MutableGamepadButton interface for the state of a gamepad button
  77749. */
  77750. export interface MutableGamepadButton {
  77751. /**
  77752. * Value of the button/trigger
  77753. */
  77754. value: number;
  77755. /**
  77756. * If the button/trigger is currently touched
  77757. */
  77758. touched: boolean;
  77759. /**
  77760. * If the button/trigger is currently pressed
  77761. */
  77762. pressed: boolean;
  77763. }
  77764. /**
  77765. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  77766. * @hidden
  77767. */
  77768. export interface ExtendedGamepadButton extends GamepadButton {
  77769. /**
  77770. * If the button/trigger is currently pressed
  77771. */
  77772. readonly pressed: boolean;
  77773. /**
  77774. * If the button/trigger is currently touched
  77775. */
  77776. readonly touched: boolean;
  77777. /**
  77778. * Value of the button/trigger
  77779. */
  77780. readonly value: number;
  77781. }
  77782. /** @hidden */
  77783. export interface _GamePadFactory {
  77784. /**
  77785. * Returns wether or not the current gamepad can be created for this type of controller.
  77786. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  77787. * @returns true if it can be created, otherwise false
  77788. */
  77789. canCreate(gamepadInfo: any): boolean;
  77790. /**
  77791. * Creates a new instance of the Gamepad.
  77792. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  77793. * @returns the new gamepad instance
  77794. */
  77795. create(gamepadInfo: any): Gamepad;
  77796. }
  77797. /**
  77798. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  77799. */
  77800. export class PoseEnabledControllerHelper {
  77801. /** @hidden */
  77802. static _ControllerFactories: _GamePadFactory[];
  77803. /** @hidden */
  77804. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  77805. /**
  77806. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  77807. * @param vrGamepad the gamepad to initialized
  77808. * @returns a vr controller of the type the gamepad identified as
  77809. */
  77810. static InitiateController(vrGamepad: any): Gamepad;
  77811. }
  77812. /**
  77813. * Defines the PoseEnabledController object that contains state of a vr capable controller
  77814. */
  77815. export class PoseEnabledController extends Gamepad implements PoseControlled {
  77816. /**
  77817. * If the controller is used in a webXR session
  77818. */
  77819. isXR: boolean;
  77820. private _deviceRoomPosition;
  77821. private _deviceRoomRotationQuaternion;
  77822. /**
  77823. * The device position in babylon space
  77824. */
  77825. devicePosition: Vector3;
  77826. /**
  77827. * The device rotation in babylon space
  77828. */
  77829. deviceRotationQuaternion: Quaternion;
  77830. /**
  77831. * The scale factor of the device in babylon space
  77832. */
  77833. deviceScaleFactor: number;
  77834. /**
  77835. * (Likely devicePosition should be used instead) The device position in its room space
  77836. */
  77837. position: Vector3;
  77838. /**
  77839. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  77840. */
  77841. rotationQuaternion: Quaternion;
  77842. /**
  77843. * The type of controller (Eg. Windows mixed reality)
  77844. */
  77845. controllerType: PoseEnabledControllerType;
  77846. protected _calculatedPosition: Vector3;
  77847. private _calculatedRotation;
  77848. /**
  77849. * The raw pose from the device
  77850. */
  77851. rawPose: DevicePose;
  77852. private _trackPosition;
  77853. private _maxRotationDistFromHeadset;
  77854. private _draggedRoomRotation;
  77855. /**
  77856. * @hidden
  77857. */
  77858. _disableTrackPosition(fixedPosition: Vector3): void;
  77859. /**
  77860. * Internal, the mesh attached to the controller
  77861. * @hidden
  77862. */
  77863. _mesh: Nullable<AbstractMesh>;
  77864. private _poseControlledCamera;
  77865. private _leftHandSystemQuaternion;
  77866. /**
  77867. * Internal, matrix used to convert room space to babylon space
  77868. * @hidden
  77869. */
  77870. _deviceToWorld: Matrix;
  77871. /**
  77872. * Node to be used when casting a ray from the controller
  77873. * @hidden
  77874. */
  77875. _pointingPoseNode: Nullable<TransformNode>;
  77876. /**
  77877. * Name of the child mesh that can be used to cast a ray from the controller
  77878. */
  77879. static readonly POINTING_POSE: string;
  77880. /**
  77881. * Creates a new PoseEnabledController from a gamepad
  77882. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  77883. */
  77884. constructor(browserGamepad: any);
  77885. private _workingMatrix;
  77886. /**
  77887. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  77888. */
  77889. update(): void;
  77890. /**
  77891. * Updates only the pose device and mesh without doing any button event checking
  77892. */
  77893. protected _updatePoseAndMesh(): void;
  77894. /**
  77895. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  77896. * @param poseData raw pose fromthe device
  77897. */
  77898. updateFromDevice(poseData: DevicePose): void;
  77899. /**
  77900. * @hidden
  77901. */
  77902. _meshAttachedObservable: Observable<AbstractMesh>;
  77903. /**
  77904. * Attaches a mesh to the controller
  77905. * @param mesh the mesh to be attached
  77906. */
  77907. attachToMesh(mesh: AbstractMesh): void;
  77908. /**
  77909. * Attaches the controllers mesh to a camera
  77910. * @param camera the camera the mesh should be attached to
  77911. */
  77912. attachToPoseControlledCamera(camera: TargetCamera): void;
  77913. /**
  77914. * Disposes of the controller
  77915. */
  77916. dispose(): void;
  77917. /**
  77918. * The mesh that is attached to the controller
  77919. */
  77920. readonly mesh: Nullable<AbstractMesh>;
  77921. /**
  77922. * Gets the ray of the controller in the direction the controller is pointing
  77923. * @param length the length the resulting ray should be
  77924. * @returns a ray in the direction the controller is pointing
  77925. */
  77926. getForwardRay(length?: number): Ray;
  77927. }
  77928. }
  77929. declare module BABYLON {
  77930. /**
  77931. * Defines the WebVRController object that represents controllers tracked in 3D space
  77932. */
  77933. export abstract class WebVRController extends PoseEnabledController {
  77934. /**
  77935. * Internal, the default controller model for the controller
  77936. */
  77937. protected _defaultModel: AbstractMesh;
  77938. /**
  77939. * Fired when the trigger state has changed
  77940. */
  77941. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  77942. /**
  77943. * Fired when the main button state has changed
  77944. */
  77945. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  77946. /**
  77947. * Fired when the secondary button state has changed
  77948. */
  77949. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  77950. /**
  77951. * Fired when the pad state has changed
  77952. */
  77953. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  77954. /**
  77955. * Fired when controllers stick values have changed
  77956. */
  77957. onPadValuesChangedObservable: Observable<StickValues>;
  77958. /**
  77959. * Array of button availible on the controller
  77960. */
  77961. protected _buttons: Array<MutableGamepadButton>;
  77962. private _onButtonStateChange;
  77963. /**
  77964. * Fired when a controller button's state has changed
  77965. * @param callback the callback containing the button that was modified
  77966. */
  77967. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  77968. /**
  77969. * X and Y axis corresponding to the controllers joystick
  77970. */
  77971. pad: StickValues;
  77972. /**
  77973. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  77974. */
  77975. hand: string;
  77976. /**
  77977. * The default controller model for the controller
  77978. */
  77979. readonly defaultModel: AbstractMesh;
  77980. /**
  77981. * Creates a new WebVRController from a gamepad
  77982. * @param vrGamepad the gamepad that the WebVRController should be created from
  77983. */
  77984. constructor(vrGamepad: any);
  77985. /**
  77986. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  77987. */
  77988. update(): void;
  77989. /**
  77990. * Function to be called when a button is modified
  77991. */
  77992. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  77993. /**
  77994. * Loads a mesh and attaches it to the controller
  77995. * @param scene the scene the mesh should be added to
  77996. * @param meshLoaded callback for when the mesh has been loaded
  77997. */
  77998. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  77999. private _setButtonValue;
  78000. private _changes;
  78001. private _checkChanges;
  78002. /**
  78003. * Disposes of th webVRCOntroller
  78004. */
  78005. dispose(): void;
  78006. }
  78007. }
  78008. declare module BABYLON {
  78009. /**
  78010. * The HemisphericLight simulates the ambient environment light,
  78011. * so the passed direction is the light reflection direction, not the incoming direction.
  78012. */
  78013. export class HemisphericLight extends Light {
  78014. /**
  78015. * The groundColor is the light in the opposite direction to the one specified during creation.
  78016. * 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.
  78017. */
  78018. groundColor: Color3;
  78019. /**
  78020. * The light reflection direction, not the incoming direction.
  78021. */
  78022. direction: Vector3;
  78023. /**
  78024. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78025. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78026. * The HemisphericLight can't cast shadows.
  78027. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78028. * @param name The friendly name of the light
  78029. * @param direction The direction of the light reflection
  78030. * @param scene The scene the light belongs to
  78031. */
  78032. constructor(name: string, direction: Vector3, scene: Scene);
  78033. protected _buildUniformLayout(): void;
  78034. /**
  78035. * Returns the string "HemisphericLight".
  78036. * @return The class name
  78037. */
  78038. getClassName(): string;
  78039. /**
  78040. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78041. * Returns the updated direction.
  78042. * @param target The target the direction should point to
  78043. * @return The computed direction
  78044. */
  78045. setDirectionToTarget(target: Vector3): Vector3;
  78046. /**
  78047. * Returns the shadow generator associated to the light.
  78048. * @returns Always null for hemispheric lights because it does not support shadows.
  78049. */
  78050. getShadowGenerator(): Nullable<IShadowGenerator>;
  78051. /**
  78052. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78053. * @param effect The effect to update
  78054. * @param lightIndex The index of the light in the effect to update
  78055. * @returns The hemispheric light
  78056. */
  78057. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78058. /**
  78059. * Computes the world matrix of the node
  78060. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78061. * @param useWasUpdatedFlag defines a reserved property
  78062. * @returns the world matrix
  78063. */
  78064. computeWorldMatrix(): Matrix;
  78065. /**
  78066. * Returns the integer 3.
  78067. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78068. */
  78069. getTypeID(): number;
  78070. /**
  78071. * Prepares the list of defines specific to the light type.
  78072. * @param defines the list of defines
  78073. * @param lightIndex defines the index of the light for the effect
  78074. */
  78075. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78076. }
  78077. }
  78078. declare module BABYLON {
  78079. /** @hidden */
  78080. export var vrMultiviewToSingleviewPixelShader: {
  78081. name: string;
  78082. shader: string;
  78083. };
  78084. }
  78085. declare module BABYLON {
  78086. /**
  78087. * Renders to multiple views with a single draw call
  78088. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  78089. */
  78090. export class MultiviewRenderTarget extends RenderTargetTexture {
  78091. /**
  78092. * Creates a multiview render target
  78093. * @param scene scene used with the render target
  78094. * @param size the size of the render target (used for each view)
  78095. */
  78096. constructor(scene: Scene, size?: number | {
  78097. width: number;
  78098. height: number;
  78099. } | {
  78100. ratio: number;
  78101. });
  78102. /**
  78103. * @hidden
  78104. * @param faceIndex the face index, if its a cube texture
  78105. */
  78106. _bindFrameBuffer(faceIndex?: number): void;
  78107. /**
  78108. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78109. * @returns the view count
  78110. */
  78111. getViewCount(): number;
  78112. }
  78113. }
  78114. declare module BABYLON {
  78115. /**
  78116. * Reprasents a camera frustum
  78117. */
  78118. export class Frustum {
  78119. /**
  78120. * Gets the planes representing the frustum
  78121. * @param transform matrix to be applied to the returned planes
  78122. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78123. */
  78124. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  78125. /**
  78126. * Gets the near frustum plane transformed by the transform matrix
  78127. * @param transform transformation matrix to be applied to the resulting frustum plane
  78128. * @param frustumPlane the resuling frustum plane
  78129. */
  78130. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78131. /**
  78132. * Gets the far frustum plane transformed by the transform matrix
  78133. * @param transform transformation matrix to be applied to the resulting frustum plane
  78134. * @param frustumPlane the resuling frustum plane
  78135. */
  78136. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78137. /**
  78138. * Gets the left frustum plane transformed by the transform matrix
  78139. * @param transform transformation matrix to be applied to the resulting frustum plane
  78140. * @param frustumPlane the resuling frustum plane
  78141. */
  78142. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78143. /**
  78144. * Gets the right frustum plane transformed by the transform matrix
  78145. * @param transform transformation matrix to be applied to the resulting frustum plane
  78146. * @param frustumPlane the resuling frustum plane
  78147. */
  78148. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78149. /**
  78150. * Gets the top frustum plane transformed by the transform matrix
  78151. * @param transform transformation matrix to be applied to the resulting frustum plane
  78152. * @param frustumPlane the resuling frustum plane
  78153. */
  78154. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78155. /**
  78156. * Gets the bottom frustum plane transformed by the transform matrix
  78157. * @param transform transformation matrix to be applied to the resulting frustum plane
  78158. * @param frustumPlane the resuling frustum plane
  78159. */
  78160. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78161. /**
  78162. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78163. * @param transform transformation matrix to be applied to the resulting frustum planes
  78164. * @param frustumPlanes the resuling frustum planes
  78165. */
  78166. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  78167. }
  78168. }
  78169. declare module BABYLON {
  78170. interface Engine {
  78171. /**
  78172. * Creates a new multiview render target
  78173. * @param width defines the width of the texture
  78174. * @param height defines the height of the texture
  78175. * @returns the created multiview texture
  78176. */
  78177. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  78178. /**
  78179. * Binds a multiview framebuffer to be drawn to
  78180. * @param multiviewTexture texture to bind
  78181. */
  78182. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  78183. }
  78184. interface Camera {
  78185. /**
  78186. * @hidden
  78187. * 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)
  78188. */
  78189. _useMultiviewToSingleView: boolean;
  78190. /**
  78191. * @hidden
  78192. * 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)
  78193. */
  78194. _multiviewTexture: Nullable<RenderTargetTexture>;
  78195. /**
  78196. * @hidden
  78197. * ensures the multiview texture of the camera exists and has the specified width/height
  78198. * @param width height to set on the multiview texture
  78199. * @param height width to set on the multiview texture
  78200. */
  78201. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  78202. }
  78203. interface Scene {
  78204. /** @hidden */
  78205. _transformMatrixR: Matrix;
  78206. /** @hidden */
  78207. _multiviewSceneUbo: Nullable<UniformBuffer>;
  78208. /** @hidden */
  78209. _createMultiviewUbo(): void;
  78210. /** @hidden */
  78211. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  78212. /** @hidden */
  78213. _renderMultiviewToSingleView(camera: Camera): void;
  78214. }
  78215. }
  78216. declare module BABYLON {
  78217. /**
  78218. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  78219. * This will not be used for webXR as it supports displaying texture arrays directly
  78220. */
  78221. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  78222. /**
  78223. * Initializes a VRMultiviewToSingleview
  78224. * @param name name of the post process
  78225. * @param camera camera to be applied to
  78226. * @param scaleFactor scaling factor to the size of the output texture
  78227. */
  78228. constructor(name: string, camera: Camera, scaleFactor: number);
  78229. }
  78230. }
  78231. declare module BABYLON {
  78232. interface Engine {
  78233. /** @hidden */
  78234. _vrDisplay: any;
  78235. /** @hidden */
  78236. _vrSupported: boolean;
  78237. /** @hidden */
  78238. _oldSize: Size;
  78239. /** @hidden */
  78240. _oldHardwareScaleFactor: number;
  78241. /** @hidden */
  78242. _vrExclusivePointerMode: boolean;
  78243. /** @hidden */
  78244. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  78245. /** @hidden */
  78246. _onVRDisplayPointerRestricted: () => void;
  78247. /** @hidden */
  78248. _onVRDisplayPointerUnrestricted: () => void;
  78249. /** @hidden */
  78250. _onVrDisplayConnect: Nullable<(display: any) => void>;
  78251. /** @hidden */
  78252. _onVrDisplayDisconnect: Nullable<() => void>;
  78253. /** @hidden */
  78254. _onVrDisplayPresentChange: Nullable<() => void>;
  78255. /**
  78256. * Observable signaled when VR display mode changes
  78257. */
  78258. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  78259. /**
  78260. * Observable signaled when VR request present is complete
  78261. */
  78262. onVRRequestPresentComplete: Observable<boolean>;
  78263. /**
  78264. * Observable signaled when VR request present starts
  78265. */
  78266. onVRRequestPresentStart: Observable<Engine>;
  78267. /**
  78268. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  78269. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  78270. */
  78271. isInVRExclusivePointerMode: boolean;
  78272. /**
  78273. * Gets a boolean indicating if a webVR device was detected
  78274. * @returns true if a webVR device was detected
  78275. */
  78276. isVRDevicePresent(): boolean;
  78277. /**
  78278. * Gets the current webVR device
  78279. * @returns the current webVR device (or null)
  78280. */
  78281. getVRDevice(): any;
  78282. /**
  78283. * Initializes a webVR display and starts listening to display change events
  78284. * The onVRDisplayChangedObservable will be notified upon these changes
  78285. * @returns A promise containing a VRDisplay and if vr is supported
  78286. */
  78287. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  78288. /** @hidden */
  78289. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  78290. /**
  78291. * Call this function to switch to webVR mode
  78292. * Will do nothing if webVR is not supported or if there is no webVR device
  78293. * @see http://doc.babylonjs.com/how_to/webvr_camera
  78294. */
  78295. enableVR(): void;
  78296. /** @hidden */
  78297. _onVRFullScreenTriggered(): void;
  78298. }
  78299. }
  78300. declare module BABYLON {
  78301. /**
  78302. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  78303. * IMPORTANT!! The data is right-hand data.
  78304. * @export
  78305. * @interface DevicePose
  78306. */
  78307. export interface DevicePose {
  78308. /**
  78309. * The position of the device, values in array are [x,y,z].
  78310. */
  78311. readonly position: Nullable<Float32Array>;
  78312. /**
  78313. * The linearVelocity of the device, values in array are [x,y,z].
  78314. */
  78315. readonly linearVelocity: Nullable<Float32Array>;
  78316. /**
  78317. * The linearAcceleration of the device, values in array are [x,y,z].
  78318. */
  78319. readonly linearAcceleration: Nullable<Float32Array>;
  78320. /**
  78321. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  78322. */
  78323. readonly orientation: Nullable<Float32Array>;
  78324. /**
  78325. * The angularVelocity of the device, values in array are [x,y,z].
  78326. */
  78327. readonly angularVelocity: Nullable<Float32Array>;
  78328. /**
  78329. * The angularAcceleration of the device, values in array are [x,y,z].
  78330. */
  78331. readonly angularAcceleration: Nullable<Float32Array>;
  78332. }
  78333. /**
  78334. * Interface representing a pose controlled object in Babylon.
  78335. * A pose controlled object has both regular pose values as well as pose values
  78336. * from an external device such as a VR head mounted display
  78337. */
  78338. export interface PoseControlled {
  78339. /**
  78340. * The position of the object in babylon space.
  78341. */
  78342. position: Vector3;
  78343. /**
  78344. * The rotation quaternion of the object in babylon space.
  78345. */
  78346. rotationQuaternion: Quaternion;
  78347. /**
  78348. * The position of the device in babylon space.
  78349. */
  78350. devicePosition?: Vector3;
  78351. /**
  78352. * The rotation quaternion of the device in babylon space.
  78353. */
  78354. deviceRotationQuaternion: Quaternion;
  78355. /**
  78356. * The raw pose coming from the device.
  78357. */
  78358. rawPose: Nullable<DevicePose>;
  78359. /**
  78360. * The scale of the device to be used when translating from device space to babylon space.
  78361. */
  78362. deviceScaleFactor: number;
  78363. /**
  78364. * Updates the poseControlled values based on the input device pose.
  78365. * @param poseData the pose data to update the object with
  78366. */
  78367. updateFromDevice(poseData: DevicePose): void;
  78368. }
  78369. /**
  78370. * Set of options to customize the webVRCamera
  78371. */
  78372. export interface WebVROptions {
  78373. /**
  78374. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  78375. */
  78376. trackPosition?: boolean;
  78377. /**
  78378. * Sets the scale of the vrDevice in babylon space. (default: 1)
  78379. */
  78380. positionScale?: number;
  78381. /**
  78382. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  78383. */
  78384. displayName?: string;
  78385. /**
  78386. * Should the native controller meshes be initialized. (default: true)
  78387. */
  78388. controllerMeshes?: boolean;
  78389. /**
  78390. * Creating a default HemiLight only on controllers. (default: true)
  78391. */
  78392. defaultLightingOnControllers?: boolean;
  78393. /**
  78394. * If you don't want to use the default VR button of the helper. (default: false)
  78395. */
  78396. useCustomVRButton?: boolean;
  78397. /**
  78398. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  78399. */
  78400. customVRButton?: HTMLButtonElement;
  78401. /**
  78402. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  78403. */
  78404. rayLength?: number;
  78405. /**
  78406. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  78407. */
  78408. defaultHeight?: number;
  78409. /**
  78410. * If multiview should be used if availible (default: false)
  78411. */
  78412. useMultiview?: boolean;
  78413. }
  78414. /**
  78415. * This represents a WebVR camera.
  78416. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  78417. * @example http://doc.babylonjs.com/how_to/webvr_camera
  78418. */
  78419. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  78420. private webVROptions;
  78421. /**
  78422. * @hidden
  78423. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  78424. */
  78425. _vrDevice: any;
  78426. /**
  78427. * The rawPose of the vrDevice.
  78428. */
  78429. rawPose: Nullable<DevicePose>;
  78430. private _onVREnabled;
  78431. private _specsVersion;
  78432. private _attached;
  78433. private _frameData;
  78434. protected _descendants: Array<Node>;
  78435. private _deviceRoomPosition;
  78436. /** @hidden */
  78437. _deviceRoomRotationQuaternion: Quaternion;
  78438. private _standingMatrix;
  78439. /**
  78440. * Represents device position in babylon space.
  78441. */
  78442. devicePosition: Vector3;
  78443. /**
  78444. * Represents device rotation in babylon space.
  78445. */
  78446. deviceRotationQuaternion: Quaternion;
  78447. /**
  78448. * The scale of the device to be used when translating from device space to babylon space.
  78449. */
  78450. deviceScaleFactor: number;
  78451. private _deviceToWorld;
  78452. private _worldToDevice;
  78453. /**
  78454. * References to the webVR controllers for the vrDevice.
  78455. */
  78456. controllers: Array<WebVRController>;
  78457. /**
  78458. * Emits an event when a controller is attached.
  78459. */
  78460. onControllersAttachedObservable: Observable<WebVRController[]>;
  78461. /**
  78462. * Emits an event when a controller's mesh has been loaded;
  78463. */
  78464. onControllerMeshLoadedObservable: Observable<WebVRController>;
  78465. /**
  78466. * Emits an event when the HMD's pose has been updated.
  78467. */
  78468. onPoseUpdatedFromDeviceObservable: Observable<any>;
  78469. private _poseSet;
  78470. /**
  78471. * If the rig cameras be used as parent instead of this camera.
  78472. */
  78473. rigParenting: boolean;
  78474. private _lightOnControllers;
  78475. private _defaultHeight?;
  78476. /**
  78477. * Instantiates a WebVRFreeCamera.
  78478. * @param name The name of the WebVRFreeCamera
  78479. * @param position The starting anchor position for the camera
  78480. * @param scene The scene the camera belongs to
  78481. * @param webVROptions a set of customizable options for the webVRCamera
  78482. */
  78483. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  78484. /**
  78485. * Gets the device distance from the ground in meters.
  78486. * @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.
  78487. */
  78488. deviceDistanceToRoomGround(): number;
  78489. /**
  78490. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78491. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  78492. */
  78493. useStandingMatrix(callback?: (bool: boolean) => void): void;
  78494. /**
  78495. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78496. * @returns A promise with a boolean set to if the standing matrix is supported.
  78497. */
  78498. useStandingMatrixAsync(): Promise<boolean>;
  78499. /**
  78500. * Disposes the camera
  78501. */
  78502. dispose(): void;
  78503. /**
  78504. * Gets a vrController by name.
  78505. * @param name The name of the controller to retreive
  78506. * @returns the controller matching the name specified or null if not found
  78507. */
  78508. getControllerByName(name: string): Nullable<WebVRController>;
  78509. private _leftController;
  78510. /**
  78511. * The controller corresponding to the users left hand.
  78512. */
  78513. readonly leftController: Nullable<WebVRController>;
  78514. private _rightController;
  78515. /**
  78516. * The controller corresponding to the users right hand.
  78517. */
  78518. readonly rightController: Nullable<WebVRController>;
  78519. /**
  78520. * Casts a ray forward from the vrCamera's gaze.
  78521. * @param length Length of the ray (default: 100)
  78522. * @returns the ray corresponding to the gaze
  78523. */
  78524. getForwardRay(length?: number): Ray;
  78525. /**
  78526. * @hidden
  78527. * Updates the camera based on device's frame data
  78528. */
  78529. _checkInputs(): void;
  78530. /**
  78531. * Updates the poseControlled values based on the input device pose.
  78532. * @param poseData Pose coming from the device
  78533. */
  78534. updateFromDevice(poseData: DevicePose): void;
  78535. private _htmlElementAttached;
  78536. private _detachIfAttached;
  78537. /**
  78538. * WebVR's attach control will start broadcasting frames to the device.
  78539. * Note that in certain browsers (chrome for example) this function must be called
  78540. * within a user-interaction callback. Example:
  78541. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  78542. *
  78543. * @param element html element to attach the vrDevice to
  78544. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  78545. */
  78546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78547. /**
  78548. * Detaches the camera from the html element and disables VR
  78549. *
  78550. * @param element html element to detach from
  78551. */
  78552. detachControl(element: HTMLElement): void;
  78553. /**
  78554. * @returns the name of this class
  78555. */
  78556. getClassName(): string;
  78557. /**
  78558. * Calls resetPose on the vrDisplay
  78559. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  78560. */
  78561. resetToCurrentRotation(): void;
  78562. /**
  78563. * @hidden
  78564. * Updates the rig cameras (left and right eye)
  78565. */
  78566. _updateRigCameras(): void;
  78567. private _workingVector;
  78568. private _oneVector;
  78569. private _workingMatrix;
  78570. private updateCacheCalled;
  78571. private _correctPositionIfNotTrackPosition;
  78572. /**
  78573. * @hidden
  78574. * Updates the cached values of the camera
  78575. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  78576. */
  78577. _updateCache(ignoreParentClass?: boolean): void;
  78578. /**
  78579. * @hidden
  78580. * Get current device position in babylon world
  78581. */
  78582. _computeDevicePosition(): void;
  78583. /**
  78584. * Updates the current device position and rotation in the babylon world
  78585. */
  78586. update(): void;
  78587. /**
  78588. * @hidden
  78589. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  78590. * @returns an identity matrix
  78591. */
  78592. _getViewMatrix(): Matrix;
  78593. private _tmpMatrix;
  78594. /**
  78595. * This function is called by the two RIG cameras.
  78596. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  78597. * @hidden
  78598. */
  78599. _getWebVRViewMatrix(): Matrix;
  78600. /** @hidden */
  78601. _getWebVRProjectionMatrix(): Matrix;
  78602. private _onGamepadConnectedObserver;
  78603. private _onGamepadDisconnectedObserver;
  78604. private _updateCacheWhenTrackingDisabledObserver;
  78605. /**
  78606. * Initializes the controllers and their meshes
  78607. */
  78608. initControllers(): void;
  78609. }
  78610. }
  78611. declare module BABYLON {
  78612. /**
  78613. * Size options for a post process
  78614. */
  78615. export type PostProcessOptions = {
  78616. width: number;
  78617. height: number;
  78618. };
  78619. /**
  78620. * PostProcess can be used to apply a shader to a texture after it has been rendered
  78621. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78622. */
  78623. export class PostProcess {
  78624. /** Name of the PostProcess. */
  78625. name: string;
  78626. /**
  78627. * Gets or sets the unique id of the post process
  78628. */
  78629. uniqueId: number;
  78630. /**
  78631. * Width of the texture to apply the post process on
  78632. */
  78633. width: number;
  78634. /**
  78635. * Height of the texture to apply the post process on
  78636. */
  78637. height: number;
  78638. /**
  78639. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  78640. * @hidden
  78641. */
  78642. _outputTexture: Nullable<InternalTexture>;
  78643. /**
  78644. * Sampling mode used by the shader
  78645. * See https://doc.babylonjs.com/classes/3.1/texture
  78646. */
  78647. renderTargetSamplingMode: number;
  78648. /**
  78649. * Clear color to use when screen clearing
  78650. */
  78651. clearColor: Color4;
  78652. /**
  78653. * If the buffer needs to be cleared before applying the post process. (default: true)
  78654. * Should be set to false if shader will overwrite all previous pixels.
  78655. */
  78656. autoClear: boolean;
  78657. /**
  78658. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  78659. */
  78660. alphaMode: number;
  78661. /**
  78662. * Sets the setAlphaBlendConstants of the babylon engine
  78663. */
  78664. alphaConstants: Color4;
  78665. /**
  78666. * Animations to be used for the post processing
  78667. */
  78668. animations: Animation[];
  78669. /**
  78670. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  78671. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  78672. */
  78673. enablePixelPerfectMode: boolean;
  78674. /**
  78675. * Force the postprocess to be applied without taking in account viewport
  78676. */
  78677. forceFullscreenViewport: boolean;
  78678. /**
  78679. * List of inspectable custom properties (used by the Inspector)
  78680. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78681. */
  78682. inspectableCustomProperties: IInspectable[];
  78683. /**
  78684. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  78685. *
  78686. * | Value | Type | Description |
  78687. * | ----- | ----------------------------------- | ----------- |
  78688. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  78689. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  78690. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  78691. *
  78692. */
  78693. scaleMode: number;
  78694. /**
  78695. * Force textures to be a power of two (default: false)
  78696. */
  78697. alwaysForcePOT: boolean;
  78698. private _samples;
  78699. /**
  78700. * Number of sample textures (default: 1)
  78701. */
  78702. samples: number;
  78703. /**
  78704. * Modify the scale of the post process to be the same as the viewport (default: false)
  78705. */
  78706. adaptScaleToCurrentViewport: boolean;
  78707. private _camera;
  78708. private _scene;
  78709. private _engine;
  78710. private _options;
  78711. private _reusable;
  78712. private _textureType;
  78713. /**
  78714. * Smart array of input and output textures for the post process.
  78715. * @hidden
  78716. */
  78717. _textures: SmartArray<InternalTexture>;
  78718. /**
  78719. * The index in _textures that corresponds to the output texture.
  78720. * @hidden
  78721. */
  78722. _currentRenderTextureInd: number;
  78723. private _effect;
  78724. private _samplers;
  78725. private _fragmentUrl;
  78726. private _vertexUrl;
  78727. private _parameters;
  78728. private _scaleRatio;
  78729. protected _indexParameters: any;
  78730. private _shareOutputWithPostProcess;
  78731. private _texelSize;
  78732. private _forcedOutputTexture;
  78733. /**
  78734. * Returns the fragment url or shader name used in the post process.
  78735. * @returns the fragment url or name in the shader store.
  78736. */
  78737. getEffectName(): string;
  78738. /**
  78739. * An event triggered when the postprocess is activated.
  78740. */
  78741. onActivateObservable: Observable<Camera>;
  78742. private _onActivateObserver;
  78743. /**
  78744. * A function that is added to the onActivateObservable
  78745. */
  78746. onActivate: Nullable<(camera: Camera) => void>;
  78747. /**
  78748. * An event triggered when the postprocess changes its size.
  78749. */
  78750. onSizeChangedObservable: Observable<PostProcess>;
  78751. private _onSizeChangedObserver;
  78752. /**
  78753. * A function that is added to the onSizeChangedObservable
  78754. */
  78755. onSizeChanged: (postProcess: PostProcess) => void;
  78756. /**
  78757. * An event triggered when the postprocess applies its effect.
  78758. */
  78759. onApplyObservable: Observable<Effect>;
  78760. private _onApplyObserver;
  78761. /**
  78762. * A function that is added to the onApplyObservable
  78763. */
  78764. onApply: (effect: Effect) => void;
  78765. /**
  78766. * An event triggered before rendering the postprocess
  78767. */
  78768. onBeforeRenderObservable: Observable<Effect>;
  78769. private _onBeforeRenderObserver;
  78770. /**
  78771. * A function that is added to the onBeforeRenderObservable
  78772. */
  78773. onBeforeRender: (effect: Effect) => void;
  78774. /**
  78775. * An event triggered after rendering the postprocess
  78776. */
  78777. onAfterRenderObservable: Observable<Effect>;
  78778. private _onAfterRenderObserver;
  78779. /**
  78780. * A function that is added to the onAfterRenderObservable
  78781. */
  78782. onAfterRender: (efect: Effect) => void;
  78783. /**
  78784. * 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
  78785. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  78786. */
  78787. inputTexture: InternalTexture;
  78788. /**
  78789. * Gets the camera which post process is applied to.
  78790. * @returns The camera the post process is applied to.
  78791. */
  78792. getCamera(): Camera;
  78793. /**
  78794. * Gets the texel size of the postprocess.
  78795. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  78796. */
  78797. readonly texelSize: Vector2;
  78798. /**
  78799. * Creates a new instance PostProcess
  78800. * @param name The name of the PostProcess.
  78801. * @param fragmentUrl The url of the fragment shader to be used.
  78802. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  78803. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  78804. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  78805. * @param camera The camera to apply the render pass to.
  78806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78807. * @param engine The engine which the post process will be applied. (default: current engine)
  78808. * @param reusable If the post process can be reused on the same frame. (default: false)
  78809. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  78810. * @param textureType Type of textures used when performing the post process. (default: 0)
  78811. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  78812. * @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
  78813. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  78814. */
  78815. constructor(
  78816. /** Name of the PostProcess. */
  78817. 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);
  78818. /**
  78819. * Gets a string idenfifying the name of the class
  78820. * @returns "PostProcess" string
  78821. */
  78822. getClassName(): string;
  78823. /**
  78824. * Gets the engine which this post process belongs to.
  78825. * @returns The engine the post process was enabled with.
  78826. */
  78827. getEngine(): Engine;
  78828. /**
  78829. * The effect that is created when initializing the post process.
  78830. * @returns The created effect corresponding the the postprocess.
  78831. */
  78832. getEffect(): Effect;
  78833. /**
  78834. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  78835. * @param postProcess The post process to share the output with.
  78836. * @returns This post process.
  78837. */
  78838. shareOutputWith(postProcess: PostProcess): PostProcess;
  78839. /**
  78840. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  78841. * This should be called if the post process that shares output with this post process is disabled/disposed.
  78842. */
  78843. useOwnOutput(): void;
  78844. /**
  78845. * Updates the effect with the current post process compile time values and recompiles the shader.
  78846. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  78847. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  78848. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  78849. * @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
  78850. * @param onCompiled Called when the shader has been compiled.
  78851. * @param onError Called if there is an error when compiling a shader.
  78852. */
  78853. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  78854. /**
  78855. * The post process is reusable if it can be used multiple times within one frame.
  78856. * @returns If the post process is reusable
  78857. */
  78858. isReusable(): boolean;
  78859. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  78860. markTextureDirty(): void;
  78861. /**
  78862. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  78863. * 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.
  78864. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  78865. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  78866. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  78867. * @returns The target texture that was bound to be written to.
  78868. */
  78869. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  78870. /**
  78871. * If the post process is supported.
  78872. */
  78873. readonly isSupported: boolean;
  78874. /**
  78875. * The aspect ratio of the output texture.
  78876. */
  78877. readonly aspectRatio: number;
  78878. /**
  78879. * Get a value indicating if the post-process is ready to be used
  78880. * @returns true if the post-process is ready (shader is compiled)
  78881. */
  78882. isReady(): boolean;
  78883. /**
  78884. * Binds all textures and uniforms to the shader, this will be run on every pass.
  78885. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  78886. */
  78887. apply(): Nullable<Effect>;
  78888. private _disposeTextures;
  78889. /**
  78890. * Disposes the post process.
  78891. * @param camera The camera to dispose the post process on.
  78892. */
  78893. dispose(camera?: Camera): void;
  78894. }
  78895. }
  78896. declare module BABYLON {
  78897. /** @hidden */
  78898. export var kernelBlurVaryingDeclaration: {
  78899. name: string;
  78900. shader: string;
  78901. };
  78902. }
  78903. declare module BABYLON {
  78904. /** @hidden */
  78905. export var kernelBlurFragment: {
  78906. name: string;
  78907. shader: string;
  78908. };
  78909. }
  78910. declare module BABYLON {
  78911. /** @hidden */
  78912. export var kernelBlurFragment2: {
  78913. name: string;
  78914. shader: string;
  78915. };
  78916. }
  78917. declare module BABYLON {
  78918. /** @hidden */
  78919. export var kernelBlurPixelShader: {
  78920. name: string;
  78921. shader: string;
  78922. };
  78923. }
  78924. declare module BABYLON {
  78925. /** @hidden */
  78926. export var kernelBlurVertex: {
  78927. name: string;
  78928. shader: string;
  78929. };
  78930. }
  78931. declare module BABYLON {
  78932. /** @hidden */
  78933. export var kernelBlurVertexShader: {
  78934. name: string;
  78935. shader: string;
  78936. };
  78937. }
  78938. declare module BABYLON {
  78939. /**
  78940. * The Blur Post Process which blurs an image based on a kernel and direction.
  78941. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  78942. */
  78943. export class BlurPostProcess extends PostProcess {
  78944. /** The direction in which to blur the image. */
  78945. direction: Vector2;
  78946. private blockCompilation;
  78947. protected _kernel: number;
  78948. protected _idealKernel: number;
  78949. protected _packedFloat: boolean;
  78950. private _staticDefines;
  78951. /**
  78952. * Sets the length in pixels of the blur sample region
  78953. */
  78954. /**
  78955. * Gets the length in pixels of the blur sample region
  78956. */
  78957. kernel: number;
  78958. /**
  78959. * Sets wether or not the blur needs to unpack/repack floats
  78960. */
  78961. /**
  78962. * Gets wether or not the blur is unpacking/repacking floats
  78963. */
  78964. packedFloat: boolean;
  78965. /**
  78966. * Creates a new instance BlurPostProcess
  78967. * @param name The name of the effect.
  78968. * @param direction The direction in which to blur the image.
  78969. * @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.
  78970. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  78971. * @param camera The camera to apply the render pass to.
  78972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78973. * @param engine The engine which the post process will be applied. (default: current engine)
  78974. * @param reusable If the post process can be reused on the same frame. (default: false)
  78975. * @param textureType Type of textures used when performing the post process. (default: 0)
  78976. * @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)
  78977. */
  78978. constructor(name: string,
  78979. /** The direction in which to blur the image. */
  78980. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  78981. /**
  78982. * Updates the effect with the current post process compile time values and recompiles the shader.
  78983. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  78984. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  78985. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  78986. * @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
  78987. * @param onCompiled Called when the shader has been compiled.
  78988. * @param onError Called if there is an error when compiling a shader.
  78989. */
  78990. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  78991. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  78992. /**
  78993. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  78994. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  78995. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  78996. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  78997. * The gaps between physical kernels are compensated for in the weighting of the samples
  78998. * @param idealKernel Ideal blur kernel.
  78999. * @return Nearest best kernel.
  79000. */
  79001. protected _nearestBestKernel(idealKernel: number): number;
  79002. /**
  79003. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79004. * @param x The point on the Gaussian distribution to sample.
  79005. * @return the value of the Gaussian function at x.
  79006. */
  79007. protected _gaussianWeight(x: number): number;
  79008. /**
  79009. * Generates a string that can be used as a floating point number in GLSL.
  79010. * @param x Value to print.
  79011. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79012. * @return GLSL float string.
  79013. */
  79014. protected _glslFloat(x: number, decimalFigures?: number): string;
  79015. }
  79016. }
  79017. declare module BABYLON {
  79018. /**
  79019. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79020. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79021. * You can then easily use it as a reflectionTexture on a flat surface.
  79022. * In case the surface is not a plane, please consider relying on reflection probes.
  79023. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79024. */
  79025. export class MirrorTexture extends RenderTargetTexture {
  79026. private scene;
  79027. /**
  79028. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79029. * 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.
  79030. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79031. */
  79032. mirrorPlane: Plane;
  79033. /**
  79034. * Define the blur ratio used to blur the reflection if needed.
  79035. */
  79036. blurRatio: number;
  79037. /**
  79038. * Define the adaptive blur kernel used to blur the reflection if needed.
  79039. * This will autocompute the closest best match for the `blurKernel`
  79040. */
  79041. adaptiveBlurKernel: number;
  79042. /**
  79043. * Define the blur kernel used to blur the reflection if needed.
  79044. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79045. */
  79046. blurKernel: number;
  79047. /**
  79048. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79049. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79050. */
  79051. blurKernelX: number;
  79052. /**
  79053. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79054. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79055. */
  79056. blurKernelY: number;
  79057. private _autoComputeBlurKernel;
  79058. protected _onRatioRescale(): void;
  79059. private _updateGammaSpace;
  79060. private _imageProcessingConfigChangeObserver;
  79061. private _transformMatrix;
  79062. private _mirrorMatrix;
  79063. private _savedViewMatrix;
  79064. private _blurX;
  79065. private _blurY;
  79066. private _adaptiveBlurKernel;
  79067. private _blurKernelX;
  79068. private _blurKernelY;
  79069. private _blurRatio;
  79070. /**
  79071. * Instantiates a Mirror Texture.
  79072. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79073. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79074. * You can then easily use it as a reflectionTexture on a flat surface.
  79075. * In case the surface is not a plane, please consider relying on reflection probes.
  79076. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79077. * @param name
  79078. * @param size
  79079. * @param scene
  79080. * @param generateMipMaps
  79081. * @param type
  79082. * @param samplingMode
  79083. * @param generateDepthBuffer
  79084. */
  79085. constructor(name: string, size: number | {
  79086. width: number;
  79087. height: number;
  79088. } | {
  79089. ratio: number;
  79090. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  79091. private _preparePostProcesses;
  79092. /**
  79093. * Clone the mirror texture.
  79094. * @returns the cloned texture
  79095. */
  79096. clone(): MirrorTexture;
  79097. /**
  79098. * Serialize the texture to a JSON representation you could use in Parse later on
  79099. * @returns the serialized JSON representation
  79100. */
  79101. serialize(): any;
  79102. /**
  79103. * Dispose the texture and release its associated resources.
  79104. */
  79105. dispose(): void;
  79106. }
  79107. }
  79108. declare module BABYLON {
  79109. /**
  79110. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79111. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79112. */
  79113. export class Texture extends BaseTexture {
  79114. /** @hidden */
  79115. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  79116. /** @hidden */
  79117. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  79118. /** @hidden */
  79119. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  79120. /** nearest is mag = nearest and min = nearest and mip = linear */
  79121. static readonly NEAREST_SAMPLINGMODE: number;
  79122. /** nearest is mag = nearest and min = nearest and mip = linear */
  79123. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  79124. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79125. static readonly BILINEAR_SAMPLINGMODE: number;
  79126. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79127. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  79128. /** Trilinear is mag = linear and min = linear and mip = linear */
  79129. static readonly TRILINEAR_SAMPLINGMODE: number;
  79130. /** Trilinear is mag = linear and min = linear and mip = linear */
  79131. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  79132. /** mag = nearest and min = nearest and mip = nearest */
  79133. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  79134. /** mag = nearest and min = linear and mip = nearest */
  79135. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  79136. /** mag = nearest and min = linear and mip = linear */
  79137. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  79138. /** mag = nearest and min = linear and mip = none */
  79139. static readonly NEAREST_LINEAR: number;
  79140. /** mag = nearest and min = nearest and mip = none */
  79141. static readonly NEAREST_NEAREST: number;
  79142. /** mag = linear and min = nearest and mip = nearest */
  79143. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  79144. /** mag = linear and min = nearest and mip = linear */
  79145. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  79146. /** mag = linear and min = linear and mip = none */
  79147. static readonly LINEAR_LINEAR: number;
  79148. /** mag = linear and min = nearest and mip = none */
  79149. static readonly LINEAR_NEAREST: number;
  79150. /** Explicit coordinates mode */
  79151. static readonly EXPLICIT_MODE: number;
  79152. /** Spherical coordinates mode */
  79153. static readonly SPHERICAL_MODE: number;
  79154. /** Planar coordinates mode */
  79155. static readonly PLANAR_MODE: number;
  79156. /** Cubic coordinates mode */
  79157. static readonly CUBIC_MODE: number;
  79158. /** Projection coordinates mode */
  79159. static readonly PROJECTION_MODE: number;
  79160. /** Inverse Cubic coordinates mode */
  79161. static readonly SKYBOX_MODE: number;
  79162. /** Inverse Cubic coordinates mode */
  79163. static readonly INVCUBIC_MODE: number;
  79164. /** Equirectangular coordinates mode */
  79165. static readonly EQUIRECTANGULAR_MODE: number;
  79166. /** Equirectangular Fixed coordinates mode */
  79167. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  79168. /** Equirectangular Fixed Mirrored coordinates mode */
  79169. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79170. /** Texture is not repeating outside of 0..1 UVs */
  79171. static readonly CLAMP_ADDRESSMODE: number;
  79172. /** Texture is repeating outside of 0..1 UVs */
  79173. static readonly WRAP_ADDRESSMODE: number;
  79174. /** Texture is repeating and mirrored */
  79175. static readonly MIRROR_ADDRESSMODE: number;
  79176. /**
  79177. * 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
  79178. */
  79179. static UseSerializedUrlIfAny: boolean;
  79180. /**
  79181. * Define the url of the texture.
  79182. */
  79183. url: Nullable<string>;
  79184. /**
  79185. * Define an offset on the texture to offset the u coordinates of the UVs
  79186. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79187. */
  79188. uOffset: number;
  79189. /**
  79190. * Define an offset on the texture to offset the v coordinates of the UVs
  79191. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79192. */
  79193. vOffset: number;
  79194. /**
  79195. * Define an offset on the texture to scale the u coordinates of the UVs
  79196. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79197. */
  79198. uScale: number;
  79199. /**
  79200. * Define an offset on the texture to scale the v coordinates of the UVs
  79201. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79202. */
  79203. vScale: number;
  79204. /**
  79205. * Define an offset on the texture to rotate around the u coordinates of the UVs
  79206. * @see http://doc.babylonjs.com/how_to/more_materials
  79207. */
  79208. uAng: number;
  79209. /**
  79210. * Define an offset on the texture to rotate around the v coordinates of the UVs
  79211. * @see http://doc.babylonjs.com/how_to/more_materials
  79212. */
  79213. vAng: number;
  79214. /**
  79215. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  79216. * @see http://doc.babylonjs.com/how_to/more_materials
  79217. */
  79218. wAng: number;
  79219. /**
  79220. * Defines the center of rotation (U)
  79221. */
  79222. uRotationCenter: number;
  79223. /**
  79224. * Defines the center of rotation (V)
  79225. */
  79226. vRotationCenter: number;
  79227. /**
  79228. * Defines the center of rotation (W)
  79229. */
  79230. wRotationCenter: number;
  79231. /**
  79232. * Are mip maps generated for this texture or not.
  79233. */
  79234. readonly noMipmap: boolean;
  79235. /**
  79236. * List of inspectable custom properties (used by the Inspector)
  79237. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79238. */
  79239. inspectableCustomProperties: Nullable<IInspectable[]>;
  79240. private _noMipmap;
  79241. /** @hidden */
  79242. _invertY: boolean;
  79243. private _rowGenerationMatrix;
  79244. private _cachedTextureMatrix;
  79245. private _projectionModeMatrix;
  79246. private _t0;
  79247. private _t1;
  79248. private _t2;
  79249. private _cachedUOffset;
  79250. private _cachedVOffset;
  79251. private _cachedUScale;
  79252. private _cachedVScale;
  79253. private _cachedUAng;
  79254. private _cachedVAng;
  79255. private _cachedWAng;
  79256. private _cachedProjectionMatrixId;
  79257. private _cachedCoordinatesMode;
  79258. /** @hidden */
  79259. protected _initialSamplingMode: number;
  79260. /** @hidden */
  79261. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  79262. private _deleteBuffer;
  79263. protected _format: Nullable<number>;
  79264. private _delayedOnLoad;
  79265. private _delayedOnError;
  79266. /**
  79267. * Observable triggered once the texture has been loaded.
  79268. */
  79269. onLoadObservable: Observable<Texture>;
  79270. protected _isBlocking: boolean;
  79271. /**
  79272. * Is the texture preventing material to render while loading.
  79273. * If false, a default texture will be used instead of the loading one during the preparation step.
  79274. */
  79275. isBlocking: boolean;
  79276. /**
  79277. * Get the current sampling mode associated with the texture.
  79278. */
  79279. readonly samplingMode: number;
  79280. /**
  79281. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  79282. */
  79283. readonly invertY: boolean;
  79284. /**
  79285. * Instantiates a new texture.
  79286. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79287. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79288. * @param url define the url of the picture to load as a texture
  79289. * @param scene define the scene or engine the texture will belong to
  79290. * @param noMipmap define if the texture will require mip maps or not
  79291. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79292. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79293. * @param onLoad define a callback triggered when the texture has been loaded
  79294. * @param onError define a callback triggered when an error occurred during the loading session
  79295. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79296. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79297. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79298. */
  79299. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  79300. /**
  79301. * Update the url (and optional buffer) of this texture if url was null during construction.
  79302. * @param url the url of the texture
  79303. * @param buffer the buffer of the texture (defaults to null)
  79304. * @param onLoad callback called when the texture is loaded (defaults to null)
  79305. */
  79306. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  79307. /**
  79308. * Finish the loading sequence of a texture flagged as delayed load.
  79309. * @hidden
  79310. */
  79311. delayLoad(): void;
  79312. private _prepareRowForTextureGeneration;
  79313. /**
  79314. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  79315. * @returns the transform matrix of the texture.
  79316. */
  79317. getTextureMatrix(): Matrix;
  79318. /**
  79319. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  79320. * @returns The reflection texture transform
  79321. */
  79322. getReflectionTextureMatrix(): Matrix;
  79323. /**
  79324. * Clones the texture.
  79325. * @returns the cloned texture
  79326. */
  79327. clone(): Texture;
  79328. /**
  79329. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  79330. * @returns The JSON representation of the texture
  79331. */
  79332. serialize(): any;
  79333. /**
  79334. * Get the current class name of the texture useful for serialization or dynamic coding.
  79335. * @returns "Texture"
  79336. */
  79337. getClassName(): string;
  79338. /**
  79339. * Dispose the texture and release its associated resources.
  79340. */
  79341. dispose(): void;
  79342. /**
  79343. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  79344. * @param parsedTexture Define the JSON representation of the texture
  79345. * @param scene Define the scene the parsed texture should be instantiated in
  79346. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  79347. * @returns The parsed texture if successful
  79348. */
  79349. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  79350. /**
  79351. * Creates a texture from its base 64 representation.
  79352. * @param data Define the base64 payload without the data: prefix
  79353. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79354. * @param scene Define the scene the texture should belong to
  79355. * @param noMipmap Forces the texture to not create mip map information if true
  79356. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79357. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79358. * @param onLoad define a callback triggered when the texture has been loaded
  79359. * @param onError define a callback triggered when an error occurred during the loading session
  79360. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79361. * @returns the created texture
  79362. */
  79363. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  79364. /**
  79365. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  79366. * @param data Define the base64 payload without the data: prefix
  79367. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79368. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79369. * @param scene Define the scene the texture should belong to
  79370. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79371. * @param noMipmap Forces the texture to not create mip map information if true
  79372. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79373. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79374. * @param onLoad define a callback triggered when the texture has been loaded
  79375. * @param onError define a callback triggered when an error occurred during the loading session
  79376. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79377. * @returns the created texture
  79378. */
  79379. 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;
  79380. }
  79381. }
  79382. declare module BABYLON {
  79383. /**
  79384. * PostProcessManager is used to manage one or more post processes or post process pipelines
  79385. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79386. */
  79387. export class PostProcessManager {
  79388. private _scene;
  79389. private _indexBuffer;
  79390. private _vertexBuffers;
  79391. /**
  79392. * Creates a new instance PostProcess
  79393. * @param scene The scene that the post process is associated with.
  79394. */
  79395. constructor(scene: Scene);
  79396. private _prepareBuffers;
  79397. private _buildIndexBuffer;
  79398. /**
  79399. * Rebuilds the vertex buffers of the manager.
  79400. * @hidden
  79401. */
  79402. _rebuild(): void;
  79403. /**
  79404. * Prepares a frame to be run through a post process.
  79405. * @param sourceTexture The input texture to the post procesess. (default: null)
  79406. * @param postProcesses An array of post processes to be run. (default: null)
  79407. * @returns True if the post processes were able to be run.
  79408. * @hidden
  79409. */
  79410. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  79411. /**
  79412. * Manually render a set of post processes to a texture.
  79413. * @param postProcesses An array of post processes to be run.
  79414. * @param targetTexture The target texture to render to.
  79415. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  79416. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  79417. * @param lodLevel defines which lod of the texture to render to
  79418. */
  79419. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  79420. /**
  79421. * Finalize the result of the output of the postprocesses.
  79422. * @param doNotPresent If true the result will not be displayed to the screen.
  79423. * @param targetTexture The target texture to render to.
  79424. * @param faceIndex The index of the face to bind the target texture to.
  79425. * @param postProcesses The array of post processes to render.
  79426. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  79427. * @hidden
  79428. */
  79429. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  79430. /**
  79431. * Disposes of the post process manager.
  79432. */
  79433. dispose(): void;
  79434. }
  79435. }
  79436. declare module BABYLON {
  79437. /** Interface used by value gradients (color, factor, ...) */
  79438. export interface IValueGradient {
  79439. /**
  79440. * Gets or sets the gradient value (between 0 and 1)
  79441. */
  79442. gradient: number;
  79443. }
  79444. /** Class used to store color4 gradient */
  79445. export class ColorGradient implements IValueGradient {
  79446. /**
  79447. * Gets or sets the gradient value (between 0 and 1)
  79448. */
  79449. gradient: number;
  79450. /**
  79451. * Gets or sets first associated color
  79452. */
  79453. color1: Color4;
  79454. /**
  79455. * Gets or sets second associated color
  79456. */
  79457. color2?: Color4;
  79458. /**
  79459. * Will get a color picked randomly between color1 and color2.
  79460. * If color2 is undefined then color1 will be used
  79461. * @param result defines the target Color4 to store the result in
  79462. */
  79463. getColorToRef(result: Color4): void;
  79464. }
  79465. /** Class used to store color 3 gradient */
  79466. export class Color3Gradient implements IValueGradient {
  79467. /**
  79468. * Gets or sets the gradient value (between 0 and 1)
  79469. */
  79470. gradient: number;
  79471. /**
  79472. * Gets or sets the associated color
  79473. */
  79474. color: Color3;
  79475. }
  79476. /** Class used to store factor gradient */
  79477. export class FactorGradient implements IValueGradient {
  79478. /**
  79479. * Gets or sets the gradient value (between 0 and 1)
  79480. */
  79481. gradient: number;
  79482. /**
  79483. * Gets or sets first associated factor
  79484. */
  79485. factor1: number;
  79486. /**
  79487. * Gets or sets second associated factor
  79488. */
  79489. factor2?: number;
  79490. /**
  79491. * Will get a number picked randomly between factor1 and factor2.
  79492. * If factor2 is undefined then factor1 will be used
  79493. * @returns the picked number
  79494. */
  79495. getFactor(): number;
  79496. }
  79497. /**
  79498. * Helper used to simplify some generic gradient tasks
  79499. */
  79500. export class GradientHelper {
  79501. /**
  79502. * Gets the current gradient from an array of IValueGradient
  79503. * @param ratio defines the current ratio to get
  79504. * @param gradients defines the array of IValueGradient
  79505. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  79506. */
  79507. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  79508. }
  79509. }
  79510. declare module BABYLON {
  79511. interface AbstractScene {
  79512. /**
  79513. * The list of procedural textures added to the scene
  79514. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79515. */
  79516. proceduralTextures: Array<ProceduralTexture>;
  79517. }
  79518. /**
  79519. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  79520. * in a given scene.
  79521. */
  79522. export class ProceduralTextureSceneComponent implements ISceneComponent {
  79523. /**
  79524. * The component name helpfull to identify the component in the list of scene components.
  79525. */
  79526. readonly name: string;
  79527. /**
  79528. * The scene the component belongs to.
  79529. */
  79530. scene: Scene;
  79531. /**
  79532. * Creates a new instance of the component for the given scene
  79533. * @param scene Defines the scene to register the component in
  79534. */
  79535. constructor(scene: Scene);
  79536. /**
  79537. * Registers the component in a given scene
  79538. */
  79539. register(): void;
  79540. /**
  79541. * Rebuilds the elements related to this component in case of
  79542. * context lost for instance.
  79543. */
  79544. rebuild(): void;
  79545. /**
  79546. * Disposes the component and the associated ressources.
  79547. */
  79548. dispose(): void;
  79549. private _beforeClear;
  79550. }
  79551. }
  79552. declare module BABYLON {
  79553. interface Engine {
  79554. /**
  79555. * Creates a new render target cube texture
  79556. * @param size defines the size of the texture
  79557. * @param options defines the options used to create the texture
  79558. * @returns a new render target cube texture stored in an InternalTexture
  79559. */
  79560. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  79561. }
  79562. }
  79563. declare module BABYLON {
  79564. /** @hidden */
  79565. export var proceduralVertexShader: {
  79566. name: string;
  79567. shader: string;
  79568. };
  79569. }
  79570. declare module BABYLON {
  79571. /**
  79572. * 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.
  79573. * This is the base class of any Procedural texture and contains most of the shareable code.
  79574. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79575. */
  79576. export class ProceduralTexture extends Texture {
  79577. isCube: boolean;
  79578. /**
  79579. * Define if the texture is enabled or not (disabled texture will not render)
  79580. */
  79581. isEnabled: boolean;
  79582. /**
  79583. * Define if the texture must be cleared before rendering (default is true)
  79584. */
  79585. autoClear: boolean;
  79586. /**
  79587. * Callback called when the texture is generated
  79588. */
  79589. onGenerated: () => void;
  79590. /**
  79591. * Event raised when the texture is generated
  79592. */
  79593. onGeneratedObservable: Observable<ProceduralTexture>;
  79594. /** @hidden */
  79595. _generateMipMaps: boolean;
  79596. /** @hidden **/
  79597. _effect: Effect;
  79598. /** @hidden */
  79599. _textures: {
  79600. [key: string]: Texture;
  79601. };
  79602. private _size;
  79603. private _currentRefreshId;
  79604. private _refreshRate;
  79605. private _vertexBuffers;
  79606. private _indexBuffer;
  79607. private _uniforms;
  79608. private _samplers;
  79609. private _fragment;
  79610. private _floats;
  79611. private _ints;
  79612. private _floatsArrays;
  79613. private _colors3;
  79614. private _colors4;
  79615. private _vectors2;
  79616. private _vectors3;
  79617. private _matrices;
  79618. private _fallbackTexture;
  79619. private _fallbackTextureUsed;
  79620. private _engine;
  79621. private _cachedDefines;
  79622. private _contentUpdateId;
  79623. private _contentData;
  79624. /**
  79625. * Instantiates a new procedural texture.
  79626. * 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.
  79627. * This is the base class of any Procedural texture and contains most of the shareable code.
  79628. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79629. * @param name Define the name of the texture
  79630. * @param size Define the size of the texture to create
  79631. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  79632. * @param scene Define the scene the texture belongs to
  79633. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  79634. * @param generateMipMaps Define if the texture should creates mip maps or not
  79635. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  79636. */
  79637. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  79638. /**
  79639. * The effect that is created when initializing the post process.
  79640. * @returns The created effect corresponding the the postprocess.
  79641. */
  79642. getEffect(): Effect;
  79643. /**
  79644. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  79645. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  79646. */
  79647. getContent(): Nullable<ArrayBufferView>;
  79648. private _createIndexBuffer;
  79649. /** @hidden */
  79650. _rebuild(): void;
  79651. /**
  79652. * Resets the texture in order to recreate its associated resources.
  79653. * This can be called in case of context loss
  79654. */
  79655. reset(): void;
  79656. protected _getDefines(): string;
  79657. /**
  79658. * Is the texture ready to be used ? (rendered at least once)
  79659. * @returns true if ready, otherwise, false.
  79660. */
  79661. isReady(): boolean;
  79662. /**
  79663. * Resets the refresh counter of the texture and start bak from scratch.
  79664. * Could be useful to regenerate the texture if it is setup to render only once.
  79665. */
  79666. resetRefreshCounter(): void;
  79667. /**
  79668. * Set the fragment shader to use in order to render the texture.
  79669. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  79670. */
  79671. setFragment(fragment: any): void;
  79672. /**
  79673. * Define the refresh rate of the texture or the rendering frequency.
  79674. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  79675. */
  79676. refreshRate: number;
  79677. /** @hidden */
  79678. _shouldRender(): boolean;
  79679. /**
  79680. * Get the size the texture is rendering at.
  79681. * @returns the size (texture is always squared)
  79682. */
  79683. getRenderSize(): number;
  79684. /**
  79685. * Resize the texture to new value.
  79686. * @param size Define the new size the texture should have
  79687. * @param generateMipMaps Define whether the new texture should create mip maps
  79688. */
  79689. resize(size: number, generateMipMaps: boolean): void;
  79690. private _checkUniform;
  79691. /**
  79692. * Set a texture in the shader program used to render.
  79693. * @param name Define the name of the uniform samplers as defined in the shader
  79694. * @param texture Define the texture to bind to this sampler
  79695. * @return the texture itself allowing "fluent" like uniform updates
  79696. */
  79697. setTexture(name: string, texture: Texture): ProceduralTexture;
  79698. /**
  79699. * Set a float in the shader.
  79700. * @param name Define the name of the uniform as defined in the shader
  79701. * @param value Define the value to give to the uniform
  79702. * @return the texture itself allowing "fluent" like uniform updates
  79703. */
  79704. setFloat(name: string, value: number): ProceduralTexture;
  79705. /**
  79706. * Set a int in the shader.
  79707. * @param name Define the name of the uniform as defined in the shader
  79708. * @param value Define the value to give to the uniform
  79709. * @return the texture itself allowing "fluent" like uniform updates
  79710. */
  79711. setInt(name: string, value: number): ProceduralTexture;
  79712. /**
  79713. * Set an array of floats in the shader.
  79714. * @param name Define the name of the uniform as defined in the shader
  79715. * @param value Define the value to give to the uniform
  79716. * @return the texture itself allowing "fluent" like uniform updates
  79717. */
  79718. setFloats(name: string, value: number[]): ProceduralTexture;
  79719. /**
  79720. * Set a vec3 in the shader from a Color3.
  79721. * @param name Define the name of the uniform as defined in the shader
  79722. * @param value Define the value to give to the uniform
  79723. * @return the texture itself allowing "fluent" like uniform updates
  79724. */
  79725. setColor3(name: string, value: Color3): ProceduralTexture;
  79726. /**
  79727. * Set a vec4 in the shader from a Color4.
  79728. * @param name Define the name of the uniform as defined in the shader
  79729. * @param value Define the value to give to the uniform
  79730. * @return the texture itself allowing "fluent" like uniform updates
  79731. */
  79732. setColor4(name: string, value: Color4): ProceduralTexture;
  79733. /**
  79734. * Set a vec2 in the shader from a Vector2.
  79735. * @param name Define the name of the uniform as defined in the shader
  79736. * @param value Define the value to give to the uniform
  79737. * @return the texture itself allowing "fluent" like uniform updates
  79738. */
  79739. setVector2(name: string, value: Vector2): ProceduralTexture;
  79740. /**
  79741. * Set a vec3 in the shader from a Vector3.
  79742. * @param name Define the name of the uniform as defined in the shader
  79743. * @param value Define the value to give to the uniform
  79744. * @return the texture itself allowing "fluent" like uniform updates
  79745. */
  79746. setVector3(name: string, value: Vector3): ProceduralTexture;
  79747. /**
  79748. * Set a mat4 in the shader from a MAtrix.
  79749. * @param name Define the name of the uniform as defined in the shader
  79750. * @param value Define the value to give to the uniform
  79751. * @return the texture itself allowing "fluent" like uniform updates
  79752. */
  79753. setMatrix(name: string, value: Matrix): ProceduralTexture;
  79754. /**
  79755. * Render the texture to its associated render target.
  79756. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  79757. */
  79758. render(useCameraPostProcess?: boolean): void;
  79759. /**
  79760. * Clone the texture.
  79761. * @returns the cloned texture
  79762. */
  79763. clone(): ProceduralTexture;
  79764. /**
  79765. * Dispose the texture and release its asoociated resources.
  79766. */
  79767. dispose(): void;
  79768. }
  79769. }
  79770. declare module BABYLON {
  79771. /**
  79772. * This represents the base class for particle system in Babylon.
  79773. * 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.
  79774. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  79775. * @example https://doc.babylonjs.com/babylon101/particles
  79776. */
  79777. export class BaseParticleSystem {
  79778. /**
  79779. * Source color is added to the destination color without alpha affecting the result
  79780. */
  79781. static BLENDMODE_ONEONE: number;
  79782. /**
  79783. * Blend current color and particle color using particle’s alpha
  79784. */
  79785. static BLENDMODE_STANDARD: number;
  79786. /**
  79787. * Add current color and particle color multiplied by particle’s alpha
  79788. */
  79789. static BLENDMODE_ADD: number;
  79790. /**
  79791. * Multiply current color with particle color
  79792. */
  79793. static BLENDMODE_MULTIPLY: number;
  79794. /**
  79795. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  79796. */
  79797. static BLENDMODE_MULTIPLYADD: number;
  79798. /**
  79799. * List of animations used by the particle system.
  79800. */
  79801. animations: Animation[];
  79802. /**
  79803. * The id of the Particle system.
  79804. */
  79805. id: string;
  79806. /**
  79807. * The friendly name of the Particle system.
  79808. */
  79809. name: string;
  79810. /**
  79811. * The rendering group used by the Particle system to chose when to render.
  79812. */
  79813. renderingGroupId: number;
  79814. /**
  79815. * The emitter represents the Mesh or position we are attaching the particle system to.
  79816. */
  79817. emitter: Nullable<AbstractMesh | Vector3>;
  79818. /**
  79819. * The maximum number of particles to emit per frame
  79820. */
  79821. emitRate: number;
  79822. /**
  79823. * If you want to launch only a few particles at once, that can be done, as well.
  79824. */
  79825. manualEmitCount: number;
  79826. /**
  79827. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  79828. */
  79829. updateSpeed: number;
  79830. /**
  79831. * The amount of time the particle system is running (depends of the overall update speed).
  79832. */
  79833. targetStopDuration: number;
  79834. /**
  79835. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  79836. */
  79837. disposeOnStop: boolean;
  79838. /**
  79839. * Minimum power of emitting particles.
  79840. */
  79841. minEmitPower: number;
  79842. /**
  79843. * Maximum power of emitting particles.
  79844. */
  79845. maxEmitPower: number;
  79846. /**
  79847. * Minimum life time of emitting particles.
  79848. */
  79849. minLifeTime: number;
  79850. /**
  79851. * Maximum life time of emitting particles.
  79852. */
  79853. maxLifeTime: number;
  79854. /**
  79855. * Minimum Size of emitting particles.
  79856. */
  79857. minSize: number;
  79858. /**
  79859. * Maximum Size of emitting particles.
  79860. */
  79861. maxSize: number;
  79862. /**
  79863. * Minimum scale of emitting particles on X axis.
  79864. */
  79865. minScaleX: number;
  79866. /**
  79867. * Maximum scale of emitting particles on X axis.
  79868. */
  79869. maxScaleX: number;
  79870. /**
  79871. * Minimum scale of emitting particles on Y axis.
  79872. */
  79873. minScaleY: number;
  79874. /**
  79875. * Maximum scale of emitting particles on Y axis.
  79876. */
  79877. maxScaleY: number;
  79878. /**
  79879. * Gets or sets the minimal initial rotation in radians.
  79880. */
  79881. minInitialRotation: number;
  79882. /**
  79883. * Gets or sets the maximal initial rotation in radians.
  79884. */
  79885. maxInitialRotation: number;
  79886. /**
  79887. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  79888. */
  79889. minAngularSpeed: number;
  79890. /**
  79891. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  79892. */
  79893. maxAngularSpeed: number;
  79894. /**
  79895. * The texture used to render each particle. (this can be a spritesheet)
  79896. */
  79897. particleTexture: Nullable<Texture>;
  79898. /**
  79899. * The layer mask we are rendering the particles through.
  79900. */
  79901. layerMask: number;
  79902. /**
  79903. * This can help using your own shader to render the particle system.
  79904. * The according effect will be created
  79905. */
  79906. customShader: any;
  79907. /**
  79908. * By default particle system starts as soon as they are created. This prevents the
  79909. * automatic start to happen and let you decide when to start emitting particles.
  79910. */
  79911. preventAutoStart: boolean;
  79912. private _noiseTexture;
  79913. /**
  79914. * Gets or sets a texture used to add random noise to particle positions
  79915. */
  79916. noiseTexture: Nullable<ProceduralTexture>;
  79917. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  79918. noiseStrength: Vector3;
  79919. /**
  79920. * Callback triggered when the particle animation is ending.
  79921. */
  79922. onAnimationEnd: Nullable<() => void>;
  79923. /**
  79924. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  79925. */
  79926. blendMode: number;
  79927. /**
  79928. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  79929. * to override the particles.
  79930. */
  79931. forceDepthWrite: boolean;
  79932. /** 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 */
  79933. preWarmCycles: number;
  79934. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  79935. preWarmStepOffset: number;
  79936. /**
  79937. * 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)
  79938. */
  79939. spriteCellChangeSpeed: number;
  79940. /**
  79941. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  79942. */
  79943. startSpriteCellID: number;
  79944. /**
  79945. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  79946. */
  79947. endSpriteCellID: number;
  79948. /**
  79949. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  79950. */
  79951. spriteCellWidth: number;
  79952. /**
  79953. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  79954. */
  79955. spriteCellHeight: number;
  79956. /**
  79957. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  79958. */
  79959. spriteRandomStartCell: boolean;
  79960. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  79961. translationPivot: Vector2;
  79962. /** @hidden */
  79963. protected _isAnimationSheetEnabled: boolean;
  79964. /**
  79965. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  79966. */
  79967. beginAnimationOnStart: boolean;
  79968. /**
  79969. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  79970. */
  79971. beginAnimationFrom: number;
  79972. /**
  79973. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  79974. */
  79975. beginAnimationTo: number;
  79976. /**
  79977. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  79978. */
  79979. beginAnimationLoop: boolean;
  79980. /**
  79981. * Gets or sets a world offset applied to all particles
  79982. */
  79983. worldOffset: Vector3;
  79984. /**
  79985. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  79986. */
  79987. isAnimationSheetEnabled: boolean;
  79988. /**
  79989. * Get hosting scene
  79990. * @returns the scene
  79991. */
  79992. getScene(): Scene;
  79993. /**
  79994. * You can use gravity if you want to give an orientation to your particles.
  79995. */
  79996. gravity: Vector3;
  79997. protected _colorGradients: Nullable<Array<ColorGradient>>;
  79998. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  79999. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80000. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80001. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80002. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80003. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80004. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80005. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80006. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80007. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80008. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80009. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80010. /**
  80011. * Defines the delay in milliseconds before starting the system (0 by default)
  80012. */
  80013. startDelay: number;
  80014. /**
  80015. * Gets the current list of drag gradients.
  80016. * You must use addDragGradient and removeDragGradient to udpate this list
  80017. * @returns the list of drag gradients
  80018. */
  80019. getDragGradients(): Nullable<Array<FactorGradient>>;
  80020. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80021. limitVelocityDamping: number;
  80022. /**
  80023. * Gets the current list of limit velocity gradients.
  80024. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80025. * @returns the list of limit velocity gradients
  80026. */
  80027. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80028. /**
  80029. * Gets the current list of color gradients.
  80030. * You must use addColorGradient and removeColorGradient to udpate this list
  80031. * @returns the list of color gradients
  80032. */
  80033. getColorGradients(): Nullable<Array<ColorGradient>>;
  80034. /**
  80035. * Gets the current list of size gradients.
  80036. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80037. * @returns the list of size gradients
  80038. */
  80039. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80040. /**
  80041. * Gets the current list of color remap gradients.
  80042. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80043. * @returns the list of color remap gradients
  80044. */
  80045. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80046. /**
  80047. * Gets the current list of alpha remap gradients.
  80048. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80049. * @returns the list of alpha remap gradients
  80050. */
  80051. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80052. /**
  80053. * Gets the current list of life time gradients.
  80054. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80055. * @returns the list of life time gradients
  80056. */
  80057. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80058. /**
  80059. * Gets the current list of angular speed gradients.
  80060. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80061. * @returns the list of angular speed gradients
  80062. */
  80063. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80064. /**
  80065. * Gets the current list of velocity gradients.
  80066. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80067. * @returns the list of velocity gradients
  80068. */
  80069. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80070. /**
  80071. * Gets the current list of start size gradients.
  80072. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80073. * @returns the list of start size gradients
  80074. */
  80075. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80076. /**
  80077. * Gets the current list of emit rate gradients.
  80078. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80079. * @returns the list of emit rate gradients
  80080. */
  80081. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80082. /**
  80083. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80084. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80085. */
  80086. direction1: Vector3;
  80087. /**
  80088. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80089. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80090. */
  80091. direction2: Vector3;
  80092. /**
  80093. * 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.
  80094. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80095. */
  80096. minEmitBox: Vector3;
  80097. /**
  80098. * 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.
  80099. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80100. */
  80101. maxEmitBox: Vector3;
  80102. /**
  80103. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80104. */
  80105. color1: Color4;
  80106. /**
  80107. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80108. */
  80109. color2: Color4;
  80110. /**
  80111. * Color the particle will have at the end of its lifetime
  80112. */
  80113. colorDead: Color4;
  80114. /**
  80115. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  80116. */
  80117. textureMask: Color4;
  80118. /**
  80119. * The particle emitter type defines the emitter used by the particle system.
  80120. * It can be for example box, sphere, or cone...
  80121. */
  80122. particleEmitterType: IParticleEmitterType;
  80123. /** @hidden */
  80124. _isSubEmitter: boolean;
  80125. /**
  80126. * Gets or sets the billboard mode to use when isBillboardBased = true.
  80127. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  80128. */
  80129. billboardMode: number;
  80130. protected _isBillboardBased: boolean;
  80131. /**
  80132. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  80133. */
  80134. isBillboardBased: boolean;
  80135. /**
  80136. * The scene the particle system belongs to.
  80137. */
  80138. protected _scene: Scene;
  80139. /**
  80140. * Local cache of defines for image processing.
  80141. */
  80142. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  80143. /**
  80144. * Default configuration related to image processing available in the standard Material.
  80145. */
  80146. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  80147. /**
  80148. * Gets the image processing configuration used either in this material.
  80149. */
  80150. /**
  80151. * Sets the Default image processing configuration used either in the this material.
  80152. *
  80153. * If sets to null, the scene one is in use.
  80154. */
  80155. imageProcessingConfiguration: ImageProcessingConfiguration;
  80156. /**
  80157. * Attaches a new image processing configuration to the Standard Material.
  80158. * @param configuration
  80159. */
  80160. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  80161. /** @hidden */
  80162. protected _reset(): void;
  80163. /** @hidden */
  80164. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  80165. /**
  80166. * Instantiates a particle system.
  80167. * 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.
  80168. * @param name The name of the particle system
  80169. */
  80170. constructor(name: string);
  80171. /**
  80172. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  80173. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80174. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80175. * @returns the emitter
  80176. */
  80177. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  80178. /**
  80179. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  80180. * @param radius The radius of the hemisphere to emit from
  80181. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80182. * @returns the emitter
  80183. */
  80184. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  80185. /**
  80186. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  80187. * @param radius The radius of the sphere to emit from
  80188. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80189. * @returns the emitter
  80190. */
  80191. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  80192. /**
  80193. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  80194. * @param radius The radius of the sphere to emit from
  80195. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  80196. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  80197. * @returns the emitter
  80198. */
  80199. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  80200. /**
  80201. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  80202. * @param radius The radius of the emission cylinder
  80203. * @param height The height of the emission cylinder
  80204. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  80205. * @param directionRandomizer How much to randomize the particle direction [0-1]
  80206. * @returns the emitter
  80207. */
  80208. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  80209. /**
  80210. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  80211. * @param radius The radius of the cylinder to emit from
  80212. * @param height The height of the emission cylinder
  80213. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80214. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  80215. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  80216. * @returns the emitter
  80217. */
  80218. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  80219. /**
  80220. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  80221. * @param radius The radius of the cone to emit from
  80222. * @param angle The base angle of the cone
  80223. * @returns the emitter
  80224. */
  80225. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  80226. /**
  80227. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  80228. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80229. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80230. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80231. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80232. * @returns the emitter
  80233. */
  80234. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  80235. }
  80236. }
  80237. declare module BABYLON {
  80238. /**
  80239. * Type of sub emitter
  80240. */
  80241. export enum SubEmitterType {
  80242. /**
  80243. * Attached to the particle over it's lifetime
  80244. */
  80245. ATTACHED = 0,
  80246. /**
  80247. * Created when the particle dies
  80248. */
  80249. END = 1
  80250. }
  80251. /**
  80252. * Sub emitter class used to emit particles from an existing particle
  80253. */
  80254. export class SubEmitter {
  80255. /**
  80256. * the particle system to be used by the sub emitter
  80257. */
  80258. particleSystem: ParticleSystem;
  80259. /**
  80260. * Type of the submitter (Default: END)
  80261. */
  80262. type: SubEmitterType;
  80263. /**
  80264. * 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)
  80265. * Note: This only is supported when using an emitter of type Mesh
  80266. */
  80267. inheritDirection: boolean;
  80268. /**
  80269. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  80270. */
  80271. inheritedVelocityAmount: number;
  80272. /**
  80273. * Creates a sub emitter
  80274. * @param particleSystem the particle system to be used by the sub emitter
  80275. */
  80276. constructor(
  80277. /**
  80278. * the particle system to be used by the sub emitter
  80279. */
  80280. particleSystem: ParticleSystem);
  80281. /**
  80282. * Clones the sub emitter
  80283. * @returns the cloned sub emitter
  80284. */
  80285. clone(): SubEmitter;
  80286. /**
  80287. * Serialize current object to a JSON object
  80288. * @returns the serialized object
  80289. */
  80290. serialize(): any;
  80291. /** @hidden */
  80292. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  80293. /**
  80294. * Creates a new SubEmitter from a serialized JSON version
  80295. * @param serializationObject defines the JSON object to read from
  80296. * @param scene defines the hosting scene
  80297. * @param rootUrl defines the rootUrl for data loading
  80298. * @returns a new SubEmitter
  80299. */
  80300. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  80301. /** Release associated resources */
  80302. dispose(): void;
  80303. }
  80304. }
  80305. declare module BABYLON {
  80306. /** @hidden */
  80307. export var clipPlaneFragmentDeclaration: {
  80308. name: string;
  80309. shader: string;
  80310. };
  80311. }
  80312. declare module BABYLON {
  80313. /** @hidden */
  80314. export var imageProcessingDeclaration: {
  80315. name: string;
  80316. shader: string;
  80317. };
  80318. }
  80319. declare module BABYLON {
  80320. /** @hidden */
  80321. export var imageProcessingFunctions: {
  80322. name: string;
  80323. shader: string;
  80324. };
  80325. }
  80326. declare module BABYLON {
  80327. /** @hidden */
  80328. export var clipPlaneFragment: {
  80329. name: string;
  80330. shader: string;
  80331. };
  80332. }
  80333. declare module BABYLON {
  80334. /** @hidden */
  80335. export var particlesPixelShader: {
  80336. name: string;
  80337. shader: string;
  80338. };
  80339. }
  80340. declare module BABYLON {
  80341. /** @hidden */
  80342. export var clipPlaneVertexDeclaration: {
  80343. name: string;
  80344. shader: string;
  80345. };
  80346. }
  80347. declare module BABYLON {
  80348. /** @hidden */
  80349. export var clipPlaneVertex: {
  80350. name: string;
  80351. shader: string;
  80352. };
  80353. }
  80354. declare module BABYLON {
  80355. /** @hidden */
  80356. export var particlesVertexShader: {
  80357. name: string;
  80358. shader: string;
  80359. };
  80360. }
  80361. declare module BABYLON {
  80362. /**
  80363. * This represents a particle system in Babylon.
  80364. * 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.
  80365. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80366. * @example https://doc.babylonjs.com/babylon101/particles
  80367. */
  80368. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  80369. /**
  80370. * Billboard mode will only apply to Y axis
  80371. */
  80372. static readonly BILLBOARDMODE_Y: number;
  80373. /**
  80374. * Billboard mode will apply to all axes
  80375. */
  80376. static readonly BILLBOARDMODE_ALL: number;
  80377. /**
  80378. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80379. */
  80380. static readonly BILLBOARDMODE_STRETCHED: number;
  80381. /**
  80382. * This function can be defined to provide custom update for active particles.
  80383. * This function will be called instead of regular update (age, position, color, etc.).
  80384. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  80385. */
  80386. updateFunction: (particles: Particle[]) => void;
  80387. private _emitterWorldMatrix;
  80388. /**
  80389. * This function can be defined to specify initial direction for every new particle.
  80390. * It by default use the emitterType defined function
  80391. */
  80392. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  80393. /**
  80394. * This function can be defined to specify initial position for every new particle.
  80395. * It by default use the emitterType defined function
  80396. */
  80397. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  80398. /**
  80399. * @hidden
  80400. */
  80401. _inheritedVelocityOffset: Vector3;
  80402. /**
  80403. * An event triggered when the system is disposed
  80404. */
  80405. onDisposeObservable: Observable<ParticleSystem>;
  80406. private _onDisposeObserver;
  80407. /**
  80408. * Sets a callback that will be triggered when the system is disposed
  80409. */
  80410. onDispose: () => void;
  80411. private _particles;
  80412. private _epsilon;
  80413. private _capacity;
  80414. private _stockParticles;
  80415. private _newPartsExcess;
  80416. private _vertexData;
  80417. private _vertexBuffer;
  80418. private _vertexBuffers;
  80419. private _spriteBuffer;
  80420. private _indexBuffer;
  80421. private _effect;
  80422. private _customEffect;
  80423. private _cachedDefines;
  80424. private _scaledColorStep;
  80425. private _colorDiff;
  80426. private _scaledDirection;
  80427. private _scaledGravity;
  80428. private _currentRenderId;
  80429. private _alive;
  80430. private _useInstancing;
  80431. private _started;
  80432. private _stopped;
  80433. private _actualFrame;
  80434. private _scaledUpdateSpeed;
  80435. private _vertexBufferSize;
  80436. /** @hidden */
  80437. _currentEmitRateGradient: Nullable<FactorGradient>;
  80438. /** @hidden */
  80439. _currentEmitRate1: number;
  80440. /** @hidden */
  80441. _currentEmitRate2: number;
  80442. /** @hidden */
  80443. _currentStartSizeGradient: Nullable<FactorGradient>;
  80444. /** @hidden */
  80445. _currentStartSize1: number;
  80446. /** @hidden */
  80447. _currentStartSize2: number;
  80448. private readonly _rawTextureWidth;
  80449. private _rampGradientsTexture;
  80450. private _useRampGradients;
  80451. /** Gets or sets a boolean indicating that ramp gradients must be used
  80452. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  80453. */
  80454. useRampGradients: boolean;
  80455. /**
  80456. * 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.
  80457. * 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: [])
  80458. */
  80459. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  80460. private _subEmitters;
  80461. /**
  80462. * @hidden
  80463. * If the particle systems emitter should be disposed when the particle system is disposed
  80464. */
  80465. _disposeEmitterOnDispose: boolean;
  80466. /**
  80467. * The current active Sub-systems, this property is used by the root particle system only.
  80468. */
  80469. activeSubSystems: Array<ParticleSystem>;
  80470. private _rootParticleSystem;
  80471. /**
  80472. * Gets the current list of active particles
  80473. */
  80474. readonly particles: Particle[];
  80475. /**
  80476. * Returns the string "ParticleSystem"
  80477. * @returns a string containing the class name
  80478. */
  80479. getClassName(): string;
  80480. /**
  80481. * Instantiates a particle system.
  80482. * 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.
  80483. * @param name The name of the particle system
  80484. * @param capacity The max number of particles alive at the same time
  80485. * @param scene The scene the particle system belongs to
  80486. * @param customEffect a custom effect used to change the way particles are rendered by default
  80487. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  80488. * @param epsilon Offset used to render the particles
  80489. */
  80490. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  80491. private _addFactorGradient;
  80492. private _removeFactorGradient;
  80493. /**
  80494. * Adds a new life time gradient
  80495. * @param gradient defines the gradient to use (between 0 and 1)
  80496. * @param factor defines the life time factor to affect to the specified gradient
  80497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80498. * @returns the current particle system
  80499. */
  80500. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80501. /**
  80502. * Remove a specific life time gradient
  80503. * @param gradient defines the gradient to remove
  80504. * @returns the current particle system
  80505. */
  80506. removeLifeTimeGradient(gradient: number): IParticleSystem;
  80507. /**
  80508. * Adds a new size gradient
  80509. * @param gradient defines the gradient to use (between 0 and 1)
  80510. * @param factor defines the size factor to affect to the specified gradient
  80511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80512. * @returns the current particle system
  80513. */
  80514. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80515. /**
  80516. * Remove a specific size gradient
  80517. * @param gradient defines the gradient to remove
  80518. * @returns the current particle system
  80519. */
  80520. removeSizeGradient(gradient: number): IParticleSystem;
  80521. /**
  80522. * Adds a new color remap gradient
  80523. * @param gradient defines the gradient to use (between 0 and 1)
  80524. * @param min defines the color remap minimal range
  80525. * @param max defines the color remap maximal range
  80526. * @returns the current particle system
  80527. */
  80528. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80529. /**
  80530. * Remove a specific color remap gradient
  80531. * @param gradient defines the gradient to remove
  80532. * @returns the current particle system
  80533. */
  80534. removeColorRemapGradient(gradient: number): IParticleSystem;
  80535. /**
  80536. * Adds a new alpha remap gradient
  80537. * @param gradient defines the gradient to use (between 0 and 1)
  80538. * @param min defines the alpha remap minimal range
  80539. * @param max defines the alpha remap maximal range
  80540. * @returns the current particle system
  80541. */
  80542. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80543. /**
  80544. * Remove a specific alpha remap gradient
  80545. * @param gradient defines the gradient to remove
  80546. * @returns the current particle system
  80547. */
  80548. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  80549. /**
  80550. * Adds a new angular speed gradient
  80551. * @param gradient defines the gradient to use (between 0 and 1)
  80552. * @param factor defines the angular speed to affect to the specified gradient
  80553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80554. * @returns the current particle system
  80555. */
  80556. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80557. /**
  80558. * Remove a specific angular speed gradient
  80559. * @param gradient defines the gradient to remove
  80560. * @returns the current particle system
  80561. */
  80562. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  80563. /**
  80564. * Adds a new velocity gradient
  80565. * @param gradient defines the gradient to use (between 0 and 1)
  80566. * @param factor defines the velocity to affect to the specified gradient
  80567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80568. * @returns the current particle system
  80569. */
  80570. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80571. /**
  80572. * Remove a specific velocity gradient
  80573. * @param gradient defines the gradient to remove
  80574. * @returns the current particle system
  80575. */
  80576. removeVelocityGradient(gradient: number): IParticleSystem;
  80577. /**
  80578. * Adds a new limit velocity gradient
  80579. * @param gradient defines the gradient to use (between 0 and 1)
  80580. * @param factor defines the limit velocity value to affect to the specified gradient
  80581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80582. * @returns the current particle system
  80583. */
  80584. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80585. /**
  80586. * Remove a specific limit velocity gradient
  80587. * @param gradient defines the gradient to remove
  80588. * @returns the current particle system
  80589. */
  80590. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  80591. /**
  80592. * Adds a new drag gradient
  80593. * @param gradient defines the gradient to use (between 0 and 1)
  80594. * @param factor defines the drag value to affect to the specified gradient
  80595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80596. * @returns the current particle system
  80597. */
  80598. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80599. /**
  80600. * Remove a specific drag gradient
  80601. * @param gradient defines the gradient to remove
  80602. * @returns the current particle system
  80603. */
  80604. removeDragGradient(gradient: number): IParticleSystem;
  80605. /**
  80606. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  80607. * @param gradient defines the gradient to use (between 0 and 1)
  80608. * @param factor defines the emit rate value to affect to the specified gradient
  80609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80610. * @returns the current particle system
  80611. */
  80612. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80613. /**
  80614. * Remove a specific emit rate gradient
  80615. * @param gradient defines the gradient to remove
  80616. * @returns the current particle system
  80617. */
  80618. removeEmitRateGradient(gradient: number): IParticleSystem;
  80619. /**
  80620. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  80621. * @param gradient defines the gradient to use (between 0 and 1)
  80622. * @param factor defines the start size value to affect to the specified gradient
  80623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80624. * @returns the current particle system
  80625. */
  80626. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80627. /**
  80628. * Remove a specific start size gradient
  80629. * @param gradient defines the gradient to remove
  80630. * @returns the current particle system
  80631. */
  80632. removeStartSizeGradient(gradient: number): IParticleSystem;
  80633. private _createRampGradientTexture;
  80634. /**
  80635. * Gets the current list of ramp gradients.
  80636. * You must use addRampGradient and removeRampGradient to udpate this list
  80637. * @returns the list of ramp gradients
  80638. */
  80639. getRampGradients(): Nullable<Array<Color3Gradient>>;
  80640. /**
  80641. * Adds a new ramp gradient used to remap particle colors
  80642. * @param gradient defines the gradient to use (between 0 and 1)
  80643. * @param color defines the color to affect to the specified gradient
  80644. * @returns the current particle system
  80645. */
  80646. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  80647. /**
  80648. * Remove a specific ramp gradient
  80649. * @param gradient defines the gradient to remove
  80650. * @returns the current particle system
  80651. */
  80652. removeRampGradient(gradient: number): ParticleSystem;
  80653. /**
  80654. * Adds a new color gradient
  80655. * @param gradient defines the gradient to use (between 0 and 1)
  80656. * @param color1 defines the color to affect to the specified gradient
  80657. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  80658. * @returns this particle system
  80659. */
  80660. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  80661. /**
  80662. * Remove a specific color gradient
  80663. * @param gradient defines the gradient to remove
  80664. * @returns this particle system
  80665. */
  80666. removeColorGradient(gradient: number): IParticleSystem;
  80667. private _fetchR;
  80668. protected _reset(): void;
  80669. private _resetEffect;
  80670. private _createVertexBuffers;
  80671. private _createIndexBuffer;
  80672. /**
  80673. * Gets the maximum number of particles active at the same time.
  80674. * @returns The max number of active particles.
  80675. */
  80676. getCapacity(): number;
  80677. /**
  80678. * Gets whether there are still active particles in the system.
  80679. * @returns True if it is alive, otherwise false.
  80680. */
  80681. isAlive(): boolean;
  80682. /**
  80683. * Gets if the system has been started. (Note: this will still be true after stop is called)
  80684. * @returns True if it has been started, otherwise false.
  80685. */
  80686. isStarted(): boolean;
  80687. private _prepareSubEmitterInternalArray;
  80688. /**
  80689. * Starts the particle system and begins to emit
  80690. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  80691. */
  80692. start(delay?: number): void;
  80693. /**
  80694. * Stops the particle system.
  80695. * @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.
  80696. */
  80697. stop(stopSubEmitters?: boolean): void;
  80698. /**
  80699. * Remove all active particles
  80700. */
  80701. reset(): void;
  80702. /**
  80703. * @hidden (for internal use only)
  80704. */
  80705. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  80706. /**
  80707. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  80708. * Its lifetime will start back at 0.
  80709. */
  80710. recycleParticle: (particle: Particle) => void;
  80711. private _stopSubEmitters;
  80712. private _createParticle;
  80713. private _removeFromRoot;
  80714. private _emitFromParticle;
  80715. private _update;
  80716. /** @hidden */
  80717. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  80718. /** @hidden */
  80719. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  80720. /** @hidden */
  80721. private _getEffect;
  80722. /**
  80723. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  80724. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  80725. */
  80726. animate(preWarmOnly?: boolean): void;
  80727. private _appendParticleVertices;
  80728. /**
  80729. * Rebuilds the particle system.
  80730. */
  80731. rebuild(): void;
  80732. /**
  80733. * Is this system ready to be used/rendered
  80734. * @return true if the system is ready
  80735. */
  80736. isReady(): boolean;
  80737. private _render;
  80738. /**
  80739. * Renders the particle system in its current state.
  80740. * @returns the current number of particles
  80741. */
  80742. render(): number;
  80743. /**
  80744. * Disposes the particle system and free the associated resources
  80745. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  80746. */
  80747. dispose(disposeTexture?: boolean): void;
  80748. /**
  80749. * Clones the particle system.
  80750. * @param name The name of the cloned object
  80751. * @param newEmitter The new emitter to use
  80752. * @returns the cloned particle system
  80753. */
  80754. clone(name: string, newEmitter: any): ParticleSystem;
  80755. /**
  80756. * Serializes the particle system to a JSON object.
  80757. * @returns the JSON object
  80758. */
  80759. serialize(): any;
  80760. /** @hidden */
  80761. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  80762. /** @hidden */
  80763. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  80764. /**
  80765. * Parses a JSON object to create a particle system.
  80766. * @param parsedParticleSystem The JSON object to parse
  80767. * @param scene The scene to create the particle system in
  80768. * @param rootUrl The root url to use to load external dependencies like texture
  80769. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  80770. * @returns the Parsed particle system
  80771. */
  80772. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  80773. }
  80774. }
  80775. declare module BABYLON {
  80776. /**
  80777. * A particle represents one of the element emitted by a particle system.
  80778. * This is mainly define by its coordinates, direction, velocity and age.
  80779. */
  80780. export class Particle {
  80781. /**
  80782. * The particle system the particle belongs to.
  80783. */
  80784. particleSystem: ParticleSystem;
  80785. private static _Count;
  80786. /**
  80787. * Unique ID of the particle
  80788. */
  80789. id: number;
  80790. /**
  80791. * The world position of the particle in the scene.
  80792. */
  80793. position: Vector3;
  80794. /**
  80795. * The world direction of the particle in the scene.
  80796. */
  80797. direction: Vector3;
  80798. /**
  80799. * The color of the particle.
  80800. */
  80801. color: Color4;
  80802. /**
  80803. * The color change of the particle per step.
  80804. */
  80805. colorStep: Color4;
  80806. /**
  80807. * Defines how long will the life of the particle be.
  80808. */
  80809. lifeTime: number;
  80810. /**
  80811. * The current age of the particle.
  80812. */
  80813. age: number;
  80814. /**
  80815. * The current size of the particle.
  80816. */
  80817. size: number;
  80818. /**
  80819. * The current scale of the particle.
  80820. */
  80821. scale: Vector2;
  80822. /**
  80823. * The current angle of the particle.
  80824. */
  80825. angle: number;
  80826. /**
  80827. * Defines how fast is the angle changing.
  80828. */
  80829. angularSpeed: number;
  80830. /**
  80831. * Defines the cell index used by the particle to be rendered from a sprite.
  80832. */
  80833. cellIndex: number;
  80834. /**
  80835. * The information required to support color remapping
  80836. */
  80837. remapData: Vector4;
  80838. /** @hidden */
  80839. _randomCellOffset?: number;
  80840. /** @hidden */
  80841. _initialDirection: Nullable<Vector3>;
  80842. /** @hidden */
  80843. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  80844. /** @hidden */
  80845. _initialStartSpriteCellID: number;
  80846. /** @hidden */
  80847. _initialEndSpriteCellID: number;
  80848. /** @hidden */
  80849. _currentColorGradient: Nullable<ColorGradient>;
  80850. /** @hidden */
  80851. _currentColor1: Color4;
  80852. /** @hidden */
  80853. _currentColor2: Color4;
  80854. /** @hidden */
  80855. _currentSizeGradient: Nullable<FactorGradient>;
  80856. /** @hidden */
  80857. _currentSize1: number;
  80858. /** @hidden */
  80859. _currentSize2: number;
  80860. /** @hidden */
  80861. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  80862. /** @hidden */
  80863. _currentAngularSpeed1: number;
  80864. /** @hidden */
  80865. _currentAngularSpeed2: number;
  80866. /** @hidden */
  80867. _currentVelocityGradient: Nullable<FactorGradient>;
  80868. /** @hidden */
  80869. _currentVelocity1: number;
  80870. /** @hidden */
  80871. _currentVelocity2: number;
  80872. /** @hidden */
  80873. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  80874. /** @hidden */
  80875. _currentLimitVelocity1: number;
  80876. /** @hidden */
  80877. _currentLimitVelocity2: number;
  80878. /** @hidden */
  80879. _currentDragGradient: Nullable<FactorGradient>;
  80880. /** @hidden */
  80881. _currentDrag1: number;
  80882. /** @hidden */
  80883. _currentDrag2: number;
  80884. /** @hidden */
  80885. _randomNoiseCoordinates1: Vector3;
  80886. /** @hidden */
  80887. _randomNoiseCoordinates2: Vector3;
  80888. /**
  80889. * Creates a new instance Particle
  80890. * @param particleSystem the particle system the particle belongs to
  80891. */
  80892. constructor(
  80893. /**
  80894. * The particle system the particle belongs to.
  80895. */
  80896. particleSystem: ParticleSystem);
  80897. private updateCellInfoFromSystem;
  80898. /**
  80899. * Defines how the sprite cell index is updated for the particle
  80900. */
  80901. updateCellIndex(): void;
  80902. /** @hidden */
  80903. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  80904. /** @hidden */
  80905. _inheritParticleInfoToSubEmitters(): void;
  80906. /** @hidden */
  80907. _reset(): void;
  80908. /**
  80909. * Copy the properties of particle to another one.
  80910. * @param other the particle to copy the information to.
  80911. */
  80912. copyTo(other: Particle): void;
  80913. }
  80914. }
  80915. declare module BABYLON {
  80916. /**
  80917. * Particle emitter represents a volume emitting particles.
  80918. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  80919. */
  80920. export interface IParticleEmitterType {
  80921. /**
  80922. * Called by the particle System when the direction is computed for the created particle.
  80923. * @param worldMatrix is the world matrix of the particle system
  80924. * @param directionToUpdate is the direction vector to update with the result
  80925. * @param particle is the particle we are computed the direction for
  80926. */
  80927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  80928. /**
  80929. * Called by the particle System when the position is computed for the created particle.
  80930. * @param worldMatrix is the world matrix of the particle system
  80931. * @param positionToUpdate is the position vector to update with the result
  80932. * @param particle is the particle we are computed the position for
  80933. */
  80934. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  80935. /**
  80936. * Clones the current emitter and returns a copy of it
  80937. * @returns the new emitter
  80938. */
  80939. clone(): IParticleEmitterType;
  80940. /**
  80941. * Called by the GPUParticleSystem to setup the update shader
  80942. * @param effect defines the update shader
  80943. */
  80944. applyToShader(effect: Effect): void;
  80945. /**
  80946. * Returns a string to use to update the GPU particles update shader
  80947. * @returns the effect defines string
  80948. */
  80949. getEffectDefines(): string;
  80950. /**
  80951. * Returns a string representing the class name
  80952. * @returns a string containing the class name
  80953. */
  80954. getClassName(): string;
  80955. /**
  80956. * Serializes the particle system to a JSON object.
  80957. * @returns the JSON object
  80958. */
  80959. serialize(): any;
  80960. /**
  80961. * Parse properties from a JSON object
  80962. * @param serializationObject defines the JSON object
  80963. */
  80964. parse(serializationObject: any): void;
  80965. }
  80966. }
  80967. declare module BABYLON {
  80968. /**
  80969. * Particle emitter emitting particles from the inside of a box.
  80970. * It emits the particles randomly between 2 given directions.
  80971. */
  80972. export class BoxParticleEmitter implements IParticleEmitterType {
  80973. /**
  80974. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80975. */
  80976. direction1: Vector3;
  80977. /**
  80978. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80979. */
  80980. direction2: Vector3;
  80981. /**
  80982. * 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.
  80983. */
  80984. minEmitBox: Vector3;
  80985. /**
  80986. * 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.
  80987. */
  80988. maxEmitBox: Vector3;
  80989. /**
  80990. * Creates a new instance BoxParticleEmitter
  80991. */
  80992. constructor();
  80993. /**
  80994. * Called by the particle System when the direction is computed for the created particle.
  80995. * @param worldMatrix is the world matrix of the particle system
  80996. * @param directionToUpdate is the direction vector to update with the result
  80997. * @param particle is the particle we are computed the direction for
  80998. */
  80999. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81000. /**
  81001. * Called by the particle System when the position is computed for the created particle.
  81002. * @param worldMatrix is the world matrix of the particle system
  81003. * @param positionToUpdate is the position vector to update with the result
  81004. * @param particle is the particle we are computed the position for
  81005. */
  81006. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81007. /**
  81008. * Clones the current emitter and returns a copy of it
  81009. * @returns the new emitter
  81010. */
  81011. clone(): BoxParticleEmitter;
  81012. /**
  81013. * Called by the GPUParticleSystem to setup the update shader
  81014. * @param effect defines the update shader
  81015. */
  81016. applyToShader(effect: Effect): void;
  81017. /**
  81018. * Returns a string to use to update the GPU particles update shader
  81019. * @returns a string containng the defines string
  81020. */
  81021. getEffectDefines(): string;
  81022. /**
  81023. * Returns the string "BoxParticleEmitter"
  81024. * @returns a string containing the class name
  81025. */
  81026. getClassName(): string;
  81027. /**
  81028. * Serializes the particle system to a JSON object.
  81029. * @returns the JSON object
  81030. */
  81031. serialize(): any;
  81032. /**
  81033. * Parse properties from a JSON object
  81034. * @param serializationObject defines the JSON object
  81035. */
  81036. parse(serializationObject: any): void;
  81037. }
  81038. }
  81039. declare module BABYLON {
  81040. /**
  81041. * Particle emitter emitting particles from the inside of a cone.
  81042. * It emits the particles alongside the cone volume from the base to the particle.
  81043. * The emission direction might be randomized.
  81044. */
  81045. export class ConeParticleEmitter implements IParticleEmitterType {
  81046. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81047. directionRandomizer: number;
  81048. private _radius;
  81049. private _angle;
  81050. private _height;
  81051. /**
  81052. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81053. */
  81054. radiusRange: number;
  81055. /**
  81056. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81057. */
  81058. heightRange: number;
  81059. /**
  81060. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81061. */
  81062. emitFromSpawnPointOnly: boolean;
  81063. /**
  81064. * Gets or sets the radius of the emission cone
  81065. */
  81066. radius: number;
  81067. /**
  81068. * Gets or sets the angle of the emission cone
  81069. */
  81070. angle: number;
  81071. private _buildHeight;
  81072. /**
  81073. * Creates a new instance ConeParticleEmitter
  81074. * @param radius the radius of the emission cone (1 by default)
  81075. * @param angle the cone base angle (PI by default)
  81076. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81077. */
  81078. constructor(radius?: number, angle?: number,
  81079. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81080. directionRandomizer?: number);
  81081. /**
  81082. * Called by the particle System when the direction is computed for the created particle.
  81083. * @param worldMatrix is the world matrix of the particle system
  81084. * @param directionToUpdate is the direction vector to update with the result
  81085. * @param particle is the particle we are computed the direction for
  81086. */
  81087. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81088. /**
  81089. * Called by the particle System when the position is computed for the created particle.
  81090. * @param worldMatrix is the world matrix of the particle system
  81091. * @param positionToUpdate is the position vector to update with the result
  81092. * @param particle is the particle we are computed the position for
  81093. */
  81094. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81095. /**
  81096. * Clones the current emitter and returns a copy of it
  81097. * @returns the new emitter
  81098. */
  81099. clone(): ConeParticleEmitter;
  81100. /**
  81101. * Called by the GPUParticleSystem to setup the update shader
  81102. * @param effect defines the update shader
  81103. */
  81104. applyToShader(effect: Effect): void;
  81105. /**
  81106. * Returns a string to use to update the GPU particles update shader
  81107. * @returns a string containng the defines string
  81108. */
  81109. getEffectDefines(): string;
  81110. /**
  81111. * Returns the string "ConeParticleEmitter"
  81112. * @returns a string containing the class name
  81113. */
  81114. getClassName(): string;
  81115. /**
  81116. * Serializes the particle system to a JSON object.
  81117. * @returns the JSON object
  81118. */
  81119. serialize(): any;
  81120. /**
  81121. * Parse properties from a JSON object
  81122. * @param serializationObject defines the JSON object
  81123. */
  81124. parse(serializationObject: any): void;
  81125. }
  81126. }
  81127. declare module BABYLON {
  81128. /**
  81129. * Particle emitter emitting particles from the inside of a cylinder.
  81130. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  81131. */
  81132. export class CylinderParticleEmitter implements IParticleEmitterType {
  81133. /**
  81134. * The radius of the emission cylinder.
  81135. */
  81136. radius: number;
  81137. /**
  81138. * The height of the emission cylinder.
  81139. */
  81140. height: number;
  81141. /**
  81142. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81143. */
  81144. radiusRange: number;
  81145. /**
  81146. * How much to randomize the particle direction [0-1].
  81147. */
  81148. directionRandomizer: number;
  81149. /**
  81150. * Creates a new instance CylinderParticleEmitter
  81151. * @param radius the radius of the emission cylinder (1 by default)
  81152. * @param height the height of the emission cylinder (1 by default)
  81153. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81154. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81155. */
  81156. constructor(
  81157. /**
  81158. * The radius of the emission cylinder.
  81159. */
  81160. radius?: number,
  81161. /**
  81162. * The height of the emission cylinder.
  81163. */
  81164. height?: number,
  81165. /**
  81166. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81167. */
  81168. radiusRange?: number,
  81169. /**
  81170. * How much to randomize the particle direction [0-1].
  81171. */
  81172. directionRandomizer?: number);
  81173. /**
  81174. * Called by the particle System when the direction is computed for the created particle.
  81175. * @param worldMatrix is the world matrix of the particle system
  81176. * @param directionToUpdate is the direction vector to update with the result
  81177. * @param particle is the particle we are computed the direction for
  81178. */
  81179. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81180. /**
  81181. * Called by the particle System when the position is computed for the created particle.
  81182. * @param worldMatrix is the world matrix of the particle system
  81183. * @param positionToUpdate is the position vector to update with the result
  81184. * @param particle is the particle we are computed the position for
  81185. */
  81186. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81187. /**
  81188. * Clones the current emitter and returns a copy of it
  81189. * @returns the new emitter
  81190. */
  81191. clone(): CylinderParticleEmitter;
  81192. /**
  81193. * Called by the GPUParticleSystem to setup the update shader
  81194. * @param effect defines the update shader
  81195. */
  81196. applyToShader(effect: Effect): void;
  81197. /**
  81198. * Returns a string to use to update the GPU particles update shader
  81199. * @returns a string containng the defines string
  81200. */
  81201. getEffectDefines(): string;
  81202. /**
  81203. * Returns the string "CylinderParticleEmitter"
  81204. * @returns a string containing the class name
  81205. */
  81206. getClassName(): string;
  81207. /**
  81208. * Serializes the particle system to a JSON object.
  81209. * @returns the JSON object
  81210. */
  81211. serialize(): any;
  81212. /**
  81213. * Parse properties from a JSON object
  81214. * @param serializationObject defines the JSON object
  81215. */
  81216. parse(serializationObject: any): void;
  81217. }
  81218. /**
  81219. * Particle emitter emitting particles from the inside of a cylinder.
  81220. * It emits the particles randomly between two vectors.
  81221. */
  81222. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  81223. /**
  81224. * The min limit of the emission direction.
  81225. */
  81226. direction1: Vector3;
  81227. /**
  81228. * The max limit of the emission direction.
  81229. */
  81230. direction2: Vector3;
  81231. /**
  81232. * Creates a new instance CylinderDirectedParticleEmitter
  81233. * @param radius the radius of the emission cylinder (1 by default)
  81234. * @param height the height of the emission cylinder (1 by default)
  81235. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81236. * @param direction1 the min limit of the emission direction (up vector by default)
  81237. * @param direction2 the max limit of the emission direction (up vector by default)
  81238. */
  81239. constructor(radius?: number, height?: number, radiusRange?: number,
  81240. /**
  81241. * The min limit of the emission direction.
  81242. */
  81243. direction1?: Vector3,
  81244. /**
  81245. * The max limit of the emission direction.
  81246. */
  81247. direction2?: Vector3);
  81248. /**
  81249. * Called by the particle System when the direction is computed for the created particle.
  81250. * @param worldMatrix is the world matrix of the particle system
  81251. * @param directionToUpdate is the direction vector to update with the result
  81252. * @param particle is the particle we are computed the direction for
  81253. */
  81254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81255. /**
  81256. * Clones the current emitter and returns a copy of it
  81257. * @returns the new emitter
  81258. */
  81259. clone(): CylinderDirectedParticleEmitter;
  81260. /**
  81261. * Called by the GPUParticleSystem to setup the update shader
  81262. * @param effect defines the update shader
  81263. */
  81264. applyToShader(effect: Effect): void;
  81265. /**
  81266. * Returns a string to use to update the GPU particles update shader
  81267. * @returns a string containng the defines string
  81268. */
  81269. getEffectDefines(): string;
  81270. /**
  81271. * Returns the string "CylinderDirectedParticleEmitter"
  81272. * @returns a string containing the class name
  81273. */
  81274. getClassName(): string;
  81275. /**
  81276. * Serializes the particle system to a JSON object.
  81277. * @returns the JSON object
  81278. */
  81279. serialize(): any;
  81280. /**
  81281. * Parse properties from a JSON object
  81282. * @param serializationObject defines the JSON object
  81283. */
  81284. parse(serializationObject: any): void;
  81285. }
  81286. }
  81287. declare module BABYLON {
  81288. /**
  81289. * Particle emitter emitting particles from the inside of a hemisphere.
  81290. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  81291. */
  81292. export class HemisphericParticleEmitter implements IParticleEmitterType {
  81293. /**
  81294. * The radius of the emission hemisphere.
  81295. */
  81296. radius: number;
  81297. /**
  81298. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81299. */
  81300. radiusRange: number;
  81301. /**
  81302. * How much to randomize the particle direction [0-1].
  81303. */
  81304. directionRandomizer: number;
  81305. /**
  81306. * Creates a new instance HemisphericParticleEmitter
  81307. * @param radius the radius of the emission hemisphere (1 by default)
  81308. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81309. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81310. */
  81311. constructor(
  81312. /**
  81313. * The radius of the emission hemisphere.
  81314. */
  81315. radius?: number,
  81316. /**
  81317. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81318. */
  81319. radiusRange?: number,
  81320. /**
  81321. * How much to randomize the particle direction [0-1].
  81322. */
  81323. directionRandomizer?: number);
  81324. /**
  81325. * Called by the particle System when the direction is computed for the created particle.
  81326. * @param worldMatrix is the world matrix of the particle system
  81327. * @param directionToUpdate is the direction vector to update with the result
  81328. * @param particle is the particle we are computed the direction for
  81329. */
  81330. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81331. /**
  81332. * Called by the particle System when the position is computed for the created particle.
  81333. * @param worldMatrix is the world matrix of the particle system
  81334. * @param positionToUpdate is the position vector to update with the result
  81335. * @param particle is the particle we are computed the position for
  81336. */
  81337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81338. /**
  81339. * Clones the current emitter and returns a copy of it
  81340. * @returns the new emitter
  81341. */
  81342. clone(): HemisphericParticleEmitter;
  81343. /**
  81344. * Called by the GPUParticleSystem to setup the update shader
  81345. * @param effect defines the update shader
  81346. */
  81347. applyToShader(effect: Effect): void;
  81348. /**
  81349. * Returns a string to use to update the GPU particles update shader
  81350. * @returns a string containng the defines string
  81351. */
  81352. getEffectDefines(): string;
  81353. /**
  81354. * Returns the string "HemisphericParticleEmitter"
  81355. * @returns a string containing the class name
  81356. */
  81357. getClassName(): string;
  81358. /**
  81359. * Serializes the particle system to a JSON object.
  81360. * @returns the JSON object
  81361. */
  81362. serialize(): any;
  81363. /**
  81364. * Parse properties from a JSON object
  81365. * @param serializationObject defines the JSON object
  81366. */
  81367. parse(serializationObject: any): void;
  81368. }
  81369. }
  81370. declare module BABYLON {
  81371. /**
  81372. * Particle emitter emitting particles from a point.
  81373. * It emits the particles randomly between 2 given directions.
  81374. */
  81375. export class PointParticleEmitter implements IParticleEmitterType {
  81376. /**
  81377. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81378. */
  81379. direction1: Vector3;
  81380. /**
  81381. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81382. */
  81383. direction2: Vector3;
  81384. /**
  81385. * Creates a new instance PointParticleEmitter
  81386. */
  81387. constructor();
  81388. /**
  81389. * Called by the particle System when the direction is computed for the created particle.
  81390. * @param worldMatrix is the world matrix of the particle system
  81391. * @param directionToUpdate is the direction vector to update with the result
  81392. * @param particle is the particle we are computed the direction for
  81393. */
  81394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81395. /**
  81396. * Called by the particle System when the position is computed for the created particle.
  81397. * @param worldMatrix is the world matrix of the particle system
  81398. * @param positionToUpdate is the position vector to update with the result
  81399. * @param particle is the particle we are computed the position for
  81400. */
  81401. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81402. /**
  81403. * Clones the current emitter and returns a copy of it
  81404. * @returns the new emitter
  81405. */
  81406. clone(): PointParticleEmitter;
  81407. /**
  81408. * Called by the GPUParticleSystem to setup the update shader
  81409. * @param effect defines the update shader
  81410. */
  81411. applyToShader(effect: Effect): void;
  81412. /**
  81413. * Returns a string to use to update the GPU particles update shader
  81414. * @returns a string containng the defines string
  81415. */
  81416. getEffectDefines(): string;
  81417. /**
  81418. * Returns the string "PointParticleEmitter"
  81419. * @returns a string containing the class name
  81420. */
  81421. getClassName(): string;
  81422. /**
  81423. * Serializes the particle system to a JSON object.
  81424. * @returns the JSON object
  81425. */
  81426. serialize(): any;
  81427. /**
  81428. * Parse properties from a JSON object
  81429. * @param serializationObject defines the JSON object
  81430. */
  81431. parse(serializationObject: any): void;
  81432. }
  81433. }
  81434. declare module BABYLON {
  81435. /**
  81436. * Particle emitter emitting particles from the inside of a sphere.
  81437. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  81438. */
  81439. export class SphereParticleEmitter implements IParticleEmitterType {
  81440. /**
  81441. * The radius of the emission sphere.
  81442. */
  81443. radius: number;
  81444. /**
  81445. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81446. */
  81447. radiusRange: number;
  81448. /**
  81449. * How much to randomize the particle direction [0-1].
  81450. */
  81451. directionRandomizer: number;
  81452. /**
  81453. * Creates a new instance SphereParticleEmitter
  81454. * @param radius the radius of the emission sphere (1 by default)
  81455. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81456. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81457. */
  81458. constructor(
  81459. /**
  81460. * The radius of the emission sphere.
  81461. */
  81462. radius?: number,
  81463. /**
  81464. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81465. */
  81466. radiusRange?: number,
  81467. /**
  81468. * How much to randomize the particle direction [0-1].
  81469. */
  81470. directionRandomizer?: number);
  81471. /**
  81472. * Called by the particle System when the direction is computed for the created particle.
  81473. * @param worldMatrix is the world matrix of the particle system
  81474. * @param directionToUpdate is the direction vector to update with the result
  81475. * @param particle is the particle we are computed the direction for
  81476. */
  81477. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81478. /**
  81479. * Called by the particle System when the position is computed for the created particle.
  81480. * @param worldMatrix is the world matrix of the particle system
  81481. * @param positionToUpdate is the position vector to update with the result
  81482. * @param particle is the particle we are computed the position for
  81483. */
  81484. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81485. /**
  81486. * Clones the current emitter and returns a copy of it
  81487. * @returns the new emitter
  81488. */
  81489. clone(): SphereParticleEmitter;
  81490. /**
  81491. * Called by the GPUParticleSystem to setup the update shader
  81492. * @param effect defines the update shader
  81493. */
  81494. applyToShader(effect: Effect): void;
  81495. /**
  81496. * Returns a string to use to update the GPU particles update shader
  81497. * @returns a string containng the defines string
  81498. */
  81499. getEffectDefines(): string;
  81500. /**
  81501. * Returns the string "SphereParticleEmitter"
  81502. * @returns a string containing the class name
  81503. */
  81504. getClassName(): string;
  81505. /**
  81506. * Serializes the particle system to a JSON object.
  81507. * @returns the JSON object
  81508. */
  81509. serialize(): any;
  81510. /**
  81511. * Parse properties from a JSON object
  81512. * @param serializationObject defines the JSON object
  81513. */
  81514. parse(serializationObject: any): void;
  81515. }
  81516. /**
  81517. * Particle emitter emitting particles from the inside of a sphere.
  81518. * It emits the particles randomly between two vectors.
  81519. */
  81520. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  81521. /**
  81522. * The min limit of the emission direction.
  81523. */
  81524. direction1: Vector3;
  81525. /**
  81526. * The max limit of the emission direction.
  81527. */
  81528. direction2: Vector3;
  81529. /**
  81530. * Creates a new instance SphereDirectedParticleEmitter
  81531. * @param radius the radius of the emission sphere (1 by default)
  81532. * @param direction1 the min limit of the emission direction (up vector by default)
  81533. * @param direction2 the max limit of the emission direction (up vector by default)
  81534. */
  81535. constructor(radius?: number,
  81536. /**
  81537. * The min limit of the emission direction.
  81538. */
  81539. direction1?: Vector3,
  81540. /**
  81541. * The max limit of the emission direction.
  81542. */
  81543. direction2?: Vector3);
  81544. /**
  81545. * Called by the particle System when the direction is computed for the created particle.
  81546. * @param worldMatrix is the world matrix of the particle system
  81547. * @param directionToUpdate is the direction vector to update with the result
  81548. * @param particle is the particle we are computed the direction for
  81549. */
  81550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81551. /**
  81552. * Clones the current emitter and returns a copy of it
  81553. * @returns the new emitter
  81554. */
  81555. clone(): SphereDirectedParticleEmitter;
  81556. /**
  81557. * Called by the GPUParticleSystem to setup the update shader
  81558. * @param effect defines the update shader
  81559. */
  81560. applyToShader(effect: Effect): void;
  81561. /**
  81562. * Returns a string to use to update the GPU particles update shader
  81563. * @returns a string containng the defines string
  81564. */
  81565. getEffectDefines(): string;
  81566. /**
  81567. * Returns the string "SphereDirectedParticleEmitter"
  81568. * @returns a string containing the class name
  81569. */
  81570. getClassName(): string;
  81571. /**
  81572. * Serializes the particle system to a JSON object.
  81573. * @returns the JSON object
  81574. */
  81575. serialize(): any;
  81576. /**
  81577. * Parse properties from a JSON object
  81578. * @param serializationObject defines the JSON object
  81579. */
  81580. parse(serializationObject: any): void;
  81581. }
  81582. }
  81583. declare module BABYLON {
  81584. /**
  81585. * Interface representing a particle system in Babylon.js.
  81586. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  81587. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  81588. */
  81589. export interface IParticleSystem {
  81590. /**
  81591. * List of animations used by the particle system.
  81592. */
  81593. animations: Animation[];
  81594. /**
  81595. * The id of the Particle system.
  81596. */
  81597. id: string;
  81598. /**
  81599. * The name of the Particle system.
  81600. */
  81601. name: string;
  81602. /**
  81603. * The emitter represents the Mesh or position we are attaching the particle system to.
  81604. */
  81605. emitter: Nullable<AbstractMesh | Vector3>;
  81606. /**
  81607. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81608. */
  81609. isBillboardBased: boolean;
  81610. /**
  81611. * The rendering group used by the Particle system to chose when to render.
  81612. */
  81613. renderingGroupId: number;
  81614. /**
  81615. * The layer mask we are rendering the particles through.
  81616. */
  81617. layerMask: number;
  81618. /**
  81619. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81620. */
  81621. updateSpeed: number;
  81622. /**
  81623. * The amount of time the particle system is running (depends of the overall update speed).
  81624. */
  81625. targetStopDuration: number;
  81626. /**
  81627. * The texture used to render each particle. (this can be a spritesheet)
  81628. */
  81629. particleTexture: Nullable<Texture>;
  81630. /**
  81631. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  81632. */
  81633. blendMode: number;
  81634. /**
  81635. * Minimum life time of emitting particles.
  81636. */
  81637. minLifeTime: number;
  81638. /**
  81639. * Maximum life time of emitting particles.
  81640. */
  81641. maxLifeTime: number;
  81642. /**
  81643. * Minimum Size of emitting particles.
  81644. */
  81645. minSize: number;
  81646. /**
  81647. * Maximum Size of emitting particles.
  81648. */
  81649. maxSize: number;
  81650. /**
  81651. * Minimum scale of emitting particles on X axis.
  81652. */
  81653. minScaleX: number;
  81654. /**
  81655. * Maximum scale of emitting particles on X axis.
  81656. */
  81657. maxScaleX: number;
  81658. /**
  81659. * Minimum scale of emitting particles on Y axis.
  81660. */
  81661. minScaleY: number;
  81662. /**
  81663. * Maximum scale of emitting particles on Y axis.
  81664. */
  81665. maxScaleY: number;
  81666. /**
  81667. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81668. */
  81669. color1: Color4;
  81670. /**
  81671. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81672. */
  81673. color2: Color4;
  81674. /**
  81675. * Color the particle will have at the end of its lifetime.
  81676. */
  81677. colorDead: Color4;
  81678. /**
  81679. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  81680. */
  81681. emitRate: number;
  81682. /**
  81683. * You can use gravity if you want to give an orientation to your particles.
  81684. */
  81685. gravity: Vector3;
  81686. /**
  81687. * Minimum power of emitting particles.
  81688. */
  81689. minEmitPower: number;
  81690. /**
  81691. * Maximum power of emitting particles.
  81692. */
  81693. maxEmitPower: number;
  81694. /**
  81695. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81696. */
  81697. minAngularSpeed: number;
  81698. /**
  81699. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81700. */
  81701. maxAngularSpeed: number;
  81702. /**
  81703. * Gets or sets the minimal initial rotation in radians.
  81704. */
  81705. minInitialRotation: number;
  81706. /**
  81707. * Gets or sets the maximal initial rotation in radians.
  81708. */
  81709. maxInitialRotation: number;
  81710. /**
  81711. * The particle emitter type defines the emitter used by the particle system.
  81712. * It can be for example box, sphere, or cone...
  81713. */
  81714. particleEmitterType: Nullable<IParticleEmitterType>;
  81715. /**
  81716. * Defines the delay in milliseconds before starting the system (0 by default)
  81717. */
  81718. startDelay: number;
  81719. /**
  81720. * 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
  81721. */
  81722. preWarmCycles: number;
  81723. /**
  81724. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  81725. */
  81726. preWarmStepOffset: number;
  81727. /**
  81728. * 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)
  81729. */
  81730. spriteCellChangeSpeed: number;
  81731. /**
  81732. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81733. */
  81734. startSpriteCellID: number;
  81735. /**
  81736. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81737. */
  81738. endSpriteCellID: number;
  81739. /**
  81740. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81741. */
  81742. spriteCellWidth: number;
  81743. /**
  81744. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81745. */
  81746. spriteCellHeight: number;
  81747. /**
  81748. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81749. */
  81750. spriteRandomStartCell: boolean;
  81751. /**
  81752. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  81753. */
  81754. isAnimationSheetEnabled: boolean;
  81755. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81756. translationPivot: Vector2;
  81757. /**
  81758. * Gets or sets a texture used to add random noise to particle positions
  81759. */
  81760. noiseTexture: Nullable<BaseTexture>;
  81761. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81762. noiseStrength: Vector3;
  81763. /**
  81764. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81765. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81766. */
  81767. billboardMode: number;
  81768. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81769. limitVelocityDamping: number;
  81770. /**
  81771. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81772. */
  81773. beginAnimationOnStart: boolean;
  81774. /**
  81775. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81776. */
  81777. beginAnimationFrom: number;
  81778. /**
  81779. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81780. */
  81781. beginAnimationTo: number;
  81782. /**
  81783. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81784. */
  81785. beginAnimationLoop: boolean;
  81786. /**
  81787. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81788. */
  81789. disposeOnStop: boolean;
  81790. /**
  81791. * Gets the maximum number of particles active at the same time.
  81792. * @returns The max number of active particles.
  81793. */
  81794. getCapacity(): number;
  81795. /**
  81796. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81797. * @returns True if it has been started, otherwise false.
  81798. */
  81799. isStarted(): boolean;
  81800. /**
  81801. * Animates the particle system for this frame.
  81802. */
  81803. animate(): void;
  81804. /**
  81805. * Renders the particle system in its current state.
  81806. * @returns the current number of particles
  81807. */
  81808. render(): number;
  81809. /**
  81810. * Dispose the particle system and frees its associated resources.
  81811. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81812. */
  81813. dispose(disposeTexture?: boolean): void;
  81814. /**
  81815. * Clones the particle system.
  81816. * @param name The name of the cloned object
  81817. * @param newEmitter The new emitter to use
  81818. * @returns the cloned particle system
  81819. */
  81820. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  81821. /**
  81822. * Serializes the particle system to a JSON object.
  81823. * @returns the JSON object
  81824. */
  81825. serialize(): any;
  81826. /**
  81827. * Rebuild the particle system
  81828. */
  81829. rebuild(): void;
  81830. /**
  81831. * Starts the particle system and begins to emit
  81832. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  81833. */
  81834. start(delay?: number): void;
  81835. /**
  81836. * Stops the particle system.
  81837. */
  81838. stop(): void;
  81839. /**
  81840. * Remove all active particles
  81841. */
  81842. reset(): void;
  81843. /**
  81844. * Is this system ready to be used/rendered
  81845. * @return true if the system is ready
  81846. */
  81847. isReady(): boolean;
  81848. /**
  81849. * Adds a new color gradient
  81850. * @param gradient defines the gradient to use (between 0 and 1)
  81851. * @param color1 defines the color to affect to the specified gradient
  81852. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81853. * @returns the current particle system
  81854. */
  81855. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81856. /**
  81857. * Remove a specific color gradient
  81858. * @param gradient defines the gradient to remove
  81859. * @returns the current particle system
  81860. */
  81861. removeColorGradient(gradient: number): IParticleSystem;
  81862. /**
  81863. * Adds a new size gradient
  81864. * @param gradient defines the gradient to use (between 0 and 1)
  81865. * @param factor defines the size factor to affect to the specified gradient
  81866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81867. * @returns the current particle system
  81868. */
  81869. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81870. /**
  81871. * Remove a specific size gradient
  81872. * @param gradient defines the gradient to remove
  81873. * @returns the current particle system
  81874. */
  81875. removeSizeGradient(gradient: number): IParticleSystem;
  81876. /**
  81877. * Gets the current list of color gradients.
  81878. * You must use addColorGradient and removeColorGradient to udpate this list
  81879. * @returns the list of color gradients
  81880. */
  81881. getColorGradients(): Nullable<Array<ColorGradient>>;
  81882. /**
  81883. * Gets the current list of size gradients.
  81884. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81885. * @returns the list of size gradients
  81886. */
  81887. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81888. /**
  81889. * Gets the current list of angular speed gradients.
  81890. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81891. * @returns the list of angular speed gradients
  81892. */
  81893. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81894. /**
  81895. * Adds a new angular speed gradient
  81896. * @param gradient defines the gradient to use (between 0 and 1)
  81897. * @param factor defines the angular speed to affect to the specified gradient
  81898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81899. * @returns the current particle system
  81900. */
  81901. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81902. /**
  81903. * Remove a specific angular speed gradient
  81904. * @param gradient defines the gradient to remove
  81905. * @returns the current particle system
  81906. */
  81907. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81908. /**
  81909. * Gets the current list of velocity gradients.
  81910. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81911. * @returns the list of velocity gradients
  81912. */
  81913. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81914. /**
  81915. * Adds a new velocity gradient
  81916. * @param gradient defines the gradient to use (between 0 and 1)
  81917. * @param factor defines the velocity to affect to the specified gradient
  81918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81919. * @returns the current particle system
  81920. */
  81921. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81922. /**
  81923. * Remove a specific velocity gradient
  81924. * @param gradient defines the gradient to remove
  81925. * @returns the current particle system
  81926. */
  81927. removeVelocityGradient(gradient: number): IParticleSystem;
  81928. /**
  81929. * Gets the current list of limit velocity gradients.
  81930. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81931. * @returns the list of limit velocity gradients
  81932. */
  81933. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81934. /**
  81935. * Adds a new limit velocity gradient
  81936. * @param gradient defines the gradient to use (between 0 and 1)
  81937. * @param factor defines the limit velocity to affect to the specified gradient
  81938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81939. * @returns the current particle system
  81940. */
  81941. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81942. /**
  81943. * Remove a specific limit velocity gradient
  81944. * @param gradient defines the gradient to remove
  81945. * @returns the current particle system
  81946. */
  81947. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81948. /**
  81949. * Adds a new drag gradient
  81950. * @param gradient defines the gradient to use (between 0 and 1)
  81951. * @param factor defines the drag to affect to the specified gradient
  81952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81953. * @returns the current particle system
  81954. */
  81955. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81956. /**
  81957. * Remove a specific drag gradient
  81958. * @param gradient defines the gradient to remove
  81959. * @returns the current particle system
  81960. */
  81961. removeDragGradient(gradient: number): IParticleSystem;
  81962. /**
  81963. * Gets the current list of drag gradients.
  81964. * You must use addDragGradient and removeDragGradient to udpate this list
  81965. * @returns the list of drag gradients
  81966. */
  81967. getDragGradients(): Nullable<Array<FactorGradient>>;
  81968. /**
  81969. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81970. * @param gradient defines the gradient to use (between 0 and 1)
  81971. * @param factor defines the emit rate to affect to the specified gradient
  81972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81973. * @returns the current particle system
  81974. */
  81975. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81976. /**
  81977. * Remove a specific emit rate gradient
  81978. * @param gradient defines the gradient to remove
  81979. * @returns the current particle system
  81980. */
  81981. removeEmitRateGradient(gradient: number): IParticleSystem;
  81982. /**
  81983. * Gets the current list of emit rate gradients.
  81984. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81985. * @returns the list of emit rate gradients
  81986. */
  81987. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81988. /**
  81989. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81990. * @param gradient defines the gradient to use (between 0 and 1)
  81991. * @param factor defines the start size to affect to the specified gradient
  81992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81993. * @returns the current particle system
  81994. */
  81995. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81996. /**
  81997. * Remove a specific start size gradient
  81998. * @param gradient defines the gradient to remove
  81999. * @returns the current particle system
  82000. */
  82001. removeStartSizeGradient(gradient: number): IParticleSystem;
  82002. /**
  82003. * Gets the current list of start size gradients.
  82004. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82005. * @returns the list of start size gradients
  82006. */
  82007. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82008. /**
  82009. * Adds a new life time gradient
  82010. * @param gradient defines the gradient to use (between 0 and 1)
  82011. * @param factor defines the life time factor to affect to the specified gradient
  82012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82013. * @returns the current particle system
  82014. */
  82015. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82016. /**
  82017. * Remove a specific life time gradient
  82018. * @param gradient defines the gradient to remove
  82019. * @returns the current particle system
  82020. */
  82021. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82022. /**
  82023. * Gets the current list of life time gradients.
  82024. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82025. * @returns the list of life time gradients
  82026. */
  82027. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82028. /**
  82029. * Gets the current list of color gradients.
  82030. * You must use addColorGradient and removeColorGradient to udpate this list
  82031. * @returns the list of color gradients
  82032. */
  82033. getColorGradients(): Nullable<Array<ColorGradient>>;
  82034. /**
  82035. * Adds a new ramp gradient used to remap particle colors
  82036. * @param gradient defines the gradient to use (between 0 and 1)
  82037. * @param color defines the color to affect to the specified gradient
  82038. * @returns the current particle system
  82039. */
  82040. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82041. /**
  82042. * Gets the current list of ramp gradients.
  82043. * You must use addRampGradient and removeRampGradient to udpate this list
  82044. * @returns the list of ramp gradients
  82045. */
  82046. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82047. /** Gets or sets a boolean indicating that ramp gradients must be used
  82048. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82049. */
  82050. useRampGradients: boolean;
  82051. /**
  82052. * Adds a new color remap gradient
  82053. * @param gradient defines the gradient to use (between 0 and 1)
  82054. * @param min defines the color remap minimal range
  82055. * @param max defines the color remap maximal range
  82056. * @returns the current particle system
  82057. */
  82058. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82059. /**
  82060. * Gets the current list of color remap gradients.
  82061. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82062. * @returns the list of color remap gradients
  82063. */
  82064. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82065. /**
  82066. * Adds a new alpha remap gradient
  82067. * @param gradient defines the gradient to use (between 0 and 1)
  82068. * @param min defines the alpha remap minimal range
  82069. * @param max defines the alpha remap maximal range
  82070. * @returns the current particle system
  82071. */
  82072. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82073. /**
  82074. * Gets the current list of alpha remap gradients.
  82075. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82076. * @returns the list of alpha remap gradients
  82077. */
  82078. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82079. /**
  82080. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82081. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82082. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82083. * @returns the emitter
  82084. */
  82085. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82086. /**
  82087. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82088. * @param radius The radius of the hemisphere to emit from
  82089. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82090. * @returns the emitter
  82091. */
  82092. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  82093. /**
  82094. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82095. * @param radius The radius of the sphere to emit from
  82096. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82097. * @returns the emitter
  82098. */
  82099. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  82100. /**
  82101. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82102. * @param radius The radius of the sphere to emit from
  82103. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82104. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82105. * @returns the emitter
  82106. */
  82107. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82108. /**
  82109. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82110. * @param radius The radius of the emission cylinder
  82111. * @param height The height of the emission cylinder
  82112. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82113. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82114. * @returns the emitter
  82115. */
  82116. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  82117. /**
  82118. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82119. * @param radius The radius of the cylinder to emit from
  82120. * @param height The height of the emission cylinder
  82121. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82124. * @returns the emitter
  82125. */
  82126. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82127. /**
  82128. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82129. * @param radius The radius of the cone to emit from
  82130. * @param angle The base angle of the cone
  82131. * @returns the emitter
  82132. */
  82133. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  82134. /**
  82135. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82136. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82137. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82138. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82139. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82140. * @returns the emitter
  82141. */
  82142. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82143. /**
  82144. * Get hosting scene
  82145. * @returns the scene
  82146. */
  82147. getScene(): Scene;
  82148. }
  82149. }
  82150. declare module BABYLON {
  82151. /**
  82152. * Creates an instance based on a source mesh.
  82153. */
  82154. export class InstancedMesh extends AbstractMesh {
  82155. private _sourceMesh;
  82156. private _currentLOD;
  82157. /** @hidden */
  82158. _indexInSourceMeshInstanceArray: number;
  82159. constructor(name: string, source: Mesh);
  82160. /**
  82161. * Returns the string "InstancedMesh".
  82162. */
  82163. getClassName(): string;
  82164. /** Gets the list of lights affecting that mesh */
  82165. readonly lightSources: Light[];
  82166. _resyncLightSources(): void;
  82167. _resyncLighSource(light: Light): void;
  82168. _removeLightSource(light: Light): void;
  82169. /**
  82170. * If the source mesh receives shadows
  82171. */
  82172. readonly receiveShadows: boolean;
  82173. /**
  82174. * The material of the source mesh
  82175. */
  82176. readonly material: Nullable<Material>;
  82177. /**
  82178. * Visibility of the source mesh
  82179. */
  82180. readonly visibility: number;
  82181. /**
  82182. * Skeleton of the source mesh
  82183. */
  82184. readonly skeleton: Nullable<Skeleton>;
  82185. /**
  82186. * Rendering ground id of the source mesh
  82187. */
  82188. renderingGroupId: number;
  82189. /**
  82190. * Returns the total number of vertices (integer).
  82191. */
  82192. getTotalVertices(): number;
  82193. /**
  82194. * Returns a positive integer : the total number of indices in this mesh geometry.
  82195. * @returns the numner of indices or zero if the mesh has no geometry.
  82196. */
  82197. getTotalIndices(): number;
  82198. /**
  82199. * The source mesh of the instance
  82200. */
  82201. readonly sourceMesh: Mesh;
  82202. /**
  82203. * Is this node ready to be used/rendered
  82204. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82205. * @return {boolean} is it ready
  82206. */
  82207. isReady(completeCheck?: boolean): boolean;
  82208. /**
  82209. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82210. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82211. * @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.
  82212. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82213. */
  82214. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  82215. /**
  82216. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82217. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82218. * The `data` are either a numeric array either a Float32Array.
  82219. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82220. * 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).
  82221. * Note that a new underlying VertexBuffer object is created each call.
  82222. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82223. *
  82224. * Possible `kind` values :
  82225. * - VertexBuffer.PositionKind
  82226. * - VertexBuffer.UVKind
  82227. * - VertexBuffer.UV2Kind
  82228. * - VertexBuffer.UV3Kind
  82229. * - VertexBuffer.UV4Kind
  82230. * - VertexBuffer.UV5Kind
  82231. * - VertexBuffer.UV6Kind
  82232. * - VertexBuffer.ColorKind
  82233. * - VertexBuffer.MatricesIndicesKind
  82234. * - VertexBuffer.MatricesIndicesExtraKind
  82235. * - VertexBuffer.MatricesWeightsKind
  82236. * - VertexBuffer.MatricesWeightsExtraKind
  82237. *
  82238. * Returns the Mesh.
  82239. */
  82240. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  82241. /**
  82242. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82243. * If the mesh has no geometry, it is simply returned as it is.
  82244. * The `data` are either a numeric array either a Float32Array.
  82245. * No new underlying VertexBuffer object is created.
  82246. * 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.
  82247. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  82248. *
  82249. * Possible `kind` values :
  82250. * - VertexBuffer.PositionKind
  82251. * - VertexBuffer.UVKind
  82252. * - VertexBuffer.UV2Kind
  82253. * - VertexBuffer.UV3Kind
  82254. * - VertexBuffer.UV4Kind
  82255. * - VertexBuffer.UV5Kind
  82256. * - VertexBuffer.UV6Kind
  82257. * - VertexBuffer.ColorKind
  82258. * - VertexBuffer.MatricesIndicesKind
  82259. * - VertexBuffer.MatricesIndicesExtraKind
  82260. * - VertexBuffer.MatricesWeightsKind
  82261. * - VertexBuffer.MatricesWeightsExtraKind
  82262. *
  82263. * Returns the Mesh.
  82264. */
  82265. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  82266. /**
  82267. * Sets the mesh indices.
  82268. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  82269. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82270. * This method creates a new index buffer each call.
  82271. * Returns the Mesh.
  82272. */
  82273. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  82274. /**
  82275. * Boolean : True if the mesh owns the requested kind of data.
  82276. */
  82277. isVerticesDataPresent(kind: string): boolean;
  82278. /**
  82279. * Returns an array of indices (IndicesArray).
  82280. */
  82281. getIndices(): Nullable<IndicesArray>;
  82282. readonly _positions: Nullable<Vector3[]>;
  82283. /**
  82284. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82285. * This means the mesh underlying bounding box and sphere are recomputed.
  82286. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82287. * @returns the current mesh
  82288. */
  82289. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  82290. /** @hidden */
  82291. _preActivate(): InstancedMesh;
  82292. /** @hidden */
  82293. _activate(renderId: number, intermediateRendering: boolean): boolean;
  82294. /** @hidden */
  82295. _postActivate(): void;
  82296. getWorldMatrix(): Matrix;
  82297. readonly isAnInstance: boolean;
  82298. /**
  82299. * Returns the current associated LOD AbstractMesh.
  82300. */
  82301. getLOD(camera: Camera): AbstractMesh;
  82302. /** @hidden */
  82303. _syncSubMeshes(): InstancedMesh;
  82304. /** @hidden */
  82305. _generatePointsArray(): boolean;
  82306. /**
  82307. * Creates a new InstancedMesh from the current mesh.
  82308. * - name (string) : the cloned mesh name
  82309. * - newParent (optional Node) : the optional Node to parent the clone to.
  82310. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  82311. *
  82312. * Returns the clone.
  82313. */
  82314. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  82315. /**
  82316. * Disposes the InstancedMesh.
  82317. * Returns nothing.
  82318. */
  82319. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82320. }
  82321. }
  82322. declare module BABYLON {
  82323. /**
  82324. * Defines the options associated with the creation of a shader material.
  82325. */
  82326. export interface IShaderMaterialOptions {
  82327. /**
  82328. * Does the material work in alpha blend mode
  82329. */
  82330. needAlphaBlending: boolean;
  82331. /**
  82332. * Does the material work in alpha test mode
  82333. */
  82334. needAlphaTesting: boolean;
  82335. /**
  82336. * The list of attribute names used in the shader
  82337. */
  82338. attributes: string[];
  82339. /**
  82340. * The list of unifrom names used in the shader
  82341. */
  82342. uniforms: string[];
  82343. /**
  82344. * The list of UBO names used in the shader
  82345. */
  82346. uniformBuffers: string[];
  82347. /**
  82348. * The list of sampler names used in the shader
  82349. */
  82350. samplers: string[];
  82351. /**
  82352. * The list of defines used in the shader
  82353. */
  82354. defines: string[];
  82355. }
  82356. /**
  82357. * 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.
  82358. *
  82359. * This returned material effects how the mesh will look based on the code in the shaders.
  82360. *
  82361. * @see http://doc.babylonjs.com/how_to/shader_material
  82362. */
  82363. export class ShaderMaterial extends Material {
  82364. private _shaderPath;
  82365. private _options;
  82366. private _textures;
  82367. private _textureArrays;
  82368. private _floats;
  82369. private _ints;
  82370. private _floatsArrays;
  82371. private _colors3;
  82372. private _colors3Arrays;
  82373. private _colors4;
  82374. private _colors4Arrays;
  82375. private _vectors2;
  82376. private _vectors3;
  82377. private _vectors4;
  82378. private _matrices;
  82379. private _matrices3x3;
  82380. private _matrices2x2;
  82381. private _vectors2Arrays;
  82382. private _vectors3Arrays;
  82383. private _vectors4Arrays;
  82384. private _cachedWorldViewMatrix;
  82385. private _cachedWorldViewProjectionMatrix;
  82386. private _renderId;
  82387. /**
  82388. * Instantiate a new shader material.
  82389. * 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.
  82390. * This returned material effects how the mesh will look based on the code in the shaders.
  82391. * @see http://doc.babylonjs.com/how_to/shader_material
  82392. * @param name Define the name of the material in the scene
  82393. * @param scene Define the scene the material belongs to
  82394. * @param shaderPath Defines the route to the shader code in one of three ways:
  82395. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  82396. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  82397. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  82398. * @param options Define the options used to create the shader
  82399. */
  82400. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  82401. /**
  82402. * Gets the options used to compile the shader.
  82403. * They can be modified to trigger a new compilation
  82404. */
  82405. readonly options: IShaderMaterialOptions;
  82406. /**
  82407. * Gets the current class name of the material e.g. "ShaderMaterial"
  82408. * Mainly use in serialization.
  82409. * @returns the class name
  82410. */
  82411. getClassName(): string;
  82412. /**
  82413. * Specifies if the material will require alpha blending
  82414. * @returns a boolean specifying if alpha blending is needed
  82415. */
  82416. needAlphaBlending(): boolean;
  82417. /**
  82418. * Specifies if this material should be rendered in alpha test mode
  82419. * @returns a boolean specifying if an alpha test is needed.
  82420. */
  82421. needAlphaTesting(): boolean;
  82422. private _checkUniform;
  82423. /**
  82424. * Set a texture in the shader.
  82425. * @param name Define the name of the uniform samplers as defined in the shader
  82426. * @param texture Define the texture to bind to this sampler
  82427. * @return the material itself allowing "fluent" like uniform updates
  82428. */
  82429. setTexture(name: string, texture: Texture): ShaderMaterial;
  82430. /**
  82431. * Set a texture array in the shader.
  82432. * @param name Define the name of the uniform sampler array as defined in the shader
  82433. * @param textures Define the list of textures to bind to this sampler
  82434. * @return the material itself allowing "fluent" like uniform updates
  82435. */
  82436. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  82437. /**
  82438. * Set a float in the shader.
  82439. * @param name Define the name of the uniform as defined in the shader
  82440. * @param value Define the value to give to the uniform
  82441. * @return the material itself allowing "fluent" like uniform updates
  82442. */
  82443. setFloat(name: string, value: number): ShaderMaterial;
  82444. /**
  82445. * Set a int in the shader.
  82446. * @param name Define the name of the uniform as defined in the shader
  82447. * @param value Define the value to give to the uniform
  82448. * @return the material itself allowing "fluent" like uniform updates
  82449. */
  82450. setInt(name: string, value: number): ShaderMaterial;
  82451. /**
  82452. * Set an array of floats in the shader.
  82453. * @param name Define the name of the uniform as defined in the shader
  82454. * @param value Define the value to give to the uniform
  82455. * @return the material itself allowing "fluent" like uniform updates
  82456. */
  82457. setFloats(name: string, value: number[]): ShaderMaterial;
  82458. /**
  82459. * Set a vec3 in the shader from a Color3.
  82460. * @param name Define the name of the uniform as defined in the shader
  82461. * @param value Define the value to give to the uniform
  82462. * @return the material itself allowing "fluent" like uniform updates
  82463. */
  82464. setColor3(name: string, value: Color3): ShaderMaterial;
  82465. /**
  82466. * Set a vec3 array in the shader from a Color3 array.
  82467. * @param name Define the name of the uniform as defined in the shader
  82468. * @param value Define the value to give to the uniform
  82469. * @return the material itself allowing "fluent" like uniform updates
  82470. */
  82471. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  82472. /**
  82473. * Set a vec4 in the shader from a Color4.
  82474. * @param name Define the name of the uniform as defined in the shader
  82475. * @param value Define the value to give to the uniform
  82476. * @return the material itself allowing "fluent" like uniform updates
  82477. */
  82478. setColor4(name: string, value: Color4): ShaderMaterial;
  82479. /**
  82480. * Set a vec4 array in the shader from a Color4 array.
  82481. * @param name Define the name of the uniform as defined in the shader
  82482. * @param value Define the value to give to the uniform
  82483. * @return the material itself allowing "fluent" like uniform updates
  82484. */
  82485. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  82486. /**
  82487. * Set a vec2 in the shader from a Vector2.
  82488. * @param name Define the name of the uniform as defined in the shader
  82489. * @param value Define the value to give to the uniform
  82490. * @return the material itself allowing "fluent" like uniform updates
  82491. */
  82492. setVector2(name: string, value: Vector2): ShaderMaterial;
  82493. /**
  82494. * Set a vec3 in the shader from a Vector3.
  82495. * @param name Define the name of the uniform as defined in the shader
  82496. * @param value Define the value to give to the uniform
  82497. * @return the material itself allowing "fluent" like uniform updates
  82498. */
  82499. setVector3(name: string, value: Vector3): ShaderMaterial;
  82500. /**
  82501. * Set a vec4 in the shader from a Vector4.
  82502. * @param name Define the name of the uniform as defined in the shader
  82503. * @param value Define the value to give to the uniform
  82504. * @return the material itself allowing "fluent" like uniform updates
  82505. */
  82506. setVector4(name: string, value: Vector4): ShaderMaterial;
  82507. /**
  82508. * Set a mat4 in the shader from a Matrix.
  82509. * @param name Define the name of the uniform as defined in the shader
  82510. * @param value Define the value to give to the uniform
  82511. * @return the material itself allowing "fluent" like uniform updates
  82512. */
  82513. setMatrix(name: string, value: Matrix): ShaderMaterial;
  82514. /**
  82515. * Set a mat3 in the shader from a Float32Array.
  82516. * @param name Define the name of the uniform as defined in the shader
  82517. * @param value Define the value to give to the uniform
  82518. * @return the material itself allowing "fluent" like uniform updates
  82519. */
  82520. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  82521. /**
  82522. * Set a mat2 in the shader from a Float32Array.
  82523. * @param name Define the name of the uniform as defined in the shader
  82524. * @param value Define the value to give to the uniform
  82525. * @return the material itself allowing "fluent" like uniform updates
  82526. */
  82527. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  82528. /**
  82529. * Set a vec2 array in the shader from a number array.
  82530. * @param name Define the name of the uniform as defined in the shader
  82531. * @param value Define the value to give to the uniform
  82532. * @return the material itself allowing "fluent" like uniform updates
  82533. */
  82534. setArray2(name: string, value: number[]): ShaderMaterial;
  82535. /**
  82536. * Set a vec3 array in the shader from a number array.
  82537. * @param name Define the name of the uniform as defined in the shader
  82538. * @param value Define the value to give to the uniform
  82539. * @return the material itself allowing "fluent" like uniform updates
  82540. */
  82541. setArray3(name: string, value: number[]): ShaderMaterial;
  82542. /**
  82543. * Set a vec4 array in the shader from a number array.
  82544. * @param name Define the name of the uniform as defined in the shader
  82545. * @param value Define the value to give to the uniform
  82546. * @return the material itself allowing "fluent" like uniform updates
  82547. */
  82548. setArray4(name: string, value: number[]): ShaderMaterial;
  82549. private _checkCache;
  82550. /**
  82551. * Specifies that the submesh is ready to be used
  82552. * @param mesh defines the mesh to check
  82553. * @param subMesh defines which submesh to check
  82554. * @param useInstances specifies that instances should be used
  82555. * @returns a boolean indicating that the submesh is ready or not
  82556. */
  82557. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82558. /**
  82559. * Checks if the material is ready to render the requested mesh
  82560. * @param mesh Define the mesh to render
  82561. * @param useInstances Define whether or not the material is used with instances
  82562. * @returns true if ready, otherwise false
  82563. */
  82564. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82565. /**
  82566. * Binds the world matrix to the material
  82567. * @param world defines the world transformation matrix
  82568. */
  82569. bindOnlyWorldMatrix(world: Matrix): void;
  82570. /**
  82571. * Binds the material to the mesh
  82572. * @param world defines the world transformation matrix
  82573. * @param mesh defines the mesh to bind the material to
  82574. */
  82575. bind(world: Matrix, mesh?: Mesh): void;
  82576. /**
  82577. * Gets the active textures from the material
  82578. * @returns an array of textures
  82579. */
  82580. getActiveTextures(): BaseTexture[];
  82581. /**
  82582. * Specifies if the material uses a texture
  82583. * @param texture defines the texture to check against the material
  82584. * @returns a boolean specifying if the material uses the texture
  82585. */
  82586. hasTexture(texture: BaseTexture): boolean;
  82587. /**
  82588. * Makes a duplicate of the material, and gives it a new name
  82589. * @param name defines the new name for the duplicated material
  82590. * @returns the cloned material
  82591. */
  82592. clone(name: string): ShaderMaterial;
  82593. /**
  82594. * Disposes the material
  82595. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82596. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82597. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82598. */
  82599. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82600. /**
  82601. * Serializes this material in a JSON representation
  82602. * @returns the serialized material object
  82603. */
  82604. serialize(): any;
  82605. /**
  82606. * Creates a shader material from parsed shader material data
  82607. * @param source defines the JSON represnetation of the material
  82608. * @param scene defines the hosting scene
  82609. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82610. * @returns a new material
  82611. */
  82612. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  82613. }
  82614. }
  82615. declare module BABYLON {
  82616. /** @hidden */
  82617. export var colorPixelShader: {
  82618. name: string;
  82619. shader: string;
  82620. };
  82621. }
  82622. declare module BABYLON {
  82623. /** @hidden */
  82624. export var colorVertexShader: {
  82625. name: string;
  82626. shader: string;
  82627. };
  82628. }
  82629. declare module BABYLON {
  82630. /**
  82631. * Line mesh
  82632. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  82633. */
  82634. export class LinesMesh extends Mesh {
  82635. /**
  82636. * If vertex color should be applied to the mesh
  82637. */
  82638. readonly useVertexColor?: boolean | undefined;
  82639. /**
  82640. * If vertex alpha should be applied to the mesh
  82641. */
  82642. readonly useVertexAlpha?: boolean | undefined;
  82643. /**
  82644. * Color of the line (Default: White)
  82645. */
  82646. color: Color3;
  82647. /**
  82648. * Alpha of the line (Default: 1)
  82649. */
  82650. alpha: number;
  82651. /**
  82652. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82653. * This margin is expressed in world space coordinates, so its value may vary.
  82654. * Default value is 0.1
  82655. */
  82656. intersectionThreshold: number;
  82657. private _colorShader;
  82658. private color4;
  82659. /**
  82660. * Creates a new LinesMesh
  82661. * @param name defines the name
  82662. * @param scene defines the hosting scene
  82663. * @param parent defines the parent mesh if any
  82664. * @param source defines the optional source LinesMesh used to clone data from
  82665. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  82666. * When false, achieved by calling a clone(), also passing False.
  82667. * This will make creation of children, recursive.
  82668. * @param useVertexColor defines if this LinesMesh supports vertex color
  82669. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  82670. */
  82671. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  82672. /**
  82673. * If vertex color should be applied to the mesh
  82674. */
  82675. useVertexColor?: boolean | undefined,
  82676. /**
  82677. * If vertex alpha should be applied to the mesh
  82678. */
  82679. useVertexAlpha?: boolean | undefined);
  82680. private _addClipPlaneDefine;
  82681. private _removeClipPlaneDefine;
  82682. isReady(): boolean;
  82683. /**
  82684. * Returns the string "LineMesh"
  82685. */
  82686. getClassName(): string;
  82687. /**
  82688. * @hidden
  82689. */
  82690. /**
  82691. * @hidden
  82692. */
  82693. material: Material;
  82694. /**
  82695. * @hidden
  82696. */
  82697. readonly checkCollisions: boolean;
  82698. /** @hidden */
  82699. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  82700. /** @hidden */
  82701. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  82702. /**
  82703. * Disposes of the line mesh
  82704. * @param doNotRecurse If children should be disposed
  82705. */
  82706. dispose(doNotRecurse?: boolean): void;
  82707. /**
  82708. * Returns a new LineMesh object cloned from the current one.
  82709. */
  82710. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  82711. /**
  82712. * Creates a new InstancedLinesMesh object from the mesh model.
  82713. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82714. * @param name defines the name of the new instance
  82715. * @returns a new InstancedLinesMesh
  82716. */
  82717. createInstance(name: string): InstancedLinesMesh;
  82718. }
  82719. /**
  82720. * Creates an instance based on a source LinesMesh
  82721. */
  82722. export class InstancedLinesMesh extends InstancedMesh {
  82723. /**
  82724. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82725. * This margin is expressed in world space coordinates, so its value may vary.
  82726. * Initilized with the intersectionThreshold value of the source LinesMesh
  82727. */
  82728. intersectionThreshold: number;
  82729. constructor(name: string, source: LinesMesh);
  82730. /**
  82731. * Returns the string "InstancedLinesMesh".
  82732. */
  82733. getClassName(): string;
  82734. }
  82735. }
  82736. declare module BABYLON {
  82737. /** @hidden */
  82738. export var linePixelShader: {
  82739. name: string;
  82740. shader: string;
  82741. };
  82742. }
  82743. declare module BABYLON {
  82744. /** @hidden */
  82745. export var lineVertexShader: {
  82746. name: string;
  82747. shader: string;
  82748. };
  82749. }
  82750. declare module BABYLON {
  82751. interface AbstractMesh {
  82752. /**
  82753. * Gets the edgesRenderer associated with the mesh
  82754. */
  82755. edgesRenderer: Nullable<EdgesRenderer>;
  82756. }
  82757. interface LinesMesh {
  82758. /**
  82759. * Enables the edge rendering mode on the mesh.
  82760. * This mode makes the mesh edges visible
  82761. * @param epsilon defines the maximal distance between two angles to detect a face
  82762. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  82763. * @returns the currentAbstractMesh
  82764. * @see https://www.babylonjs-playground.com/#19O9TU#0
  82765. */
  82766. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  82767. }
  82768. interface InstancedLinesMesh {
  82769. /**
  82770. * Enables the edge rendering mode on the mesh.
  82771. * This mode makes the mesh edges visible
  82772. * @param epsilon defines the maximal distance between two angles to detect a face
  82773. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  82774. * @returns the current InstancedLinesMesh
  82775. * @see https://www.babylonjs-playground.com/#19O9TU#0
  82776. */
  82777. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  82778. }
  82779. /**
  82780. * Defines the minimum contract an Edges renderer should follow.
  82781. */
  82782. export interface IEdgesRenderer extends IDisposable {
  82783. /**
  82784. * Gets or sets a boolean indicating if the edgesRenderer is active
  82785. */
  82786. isEnabled: boolean;
  82787. /**
  82788. * Renders the edges of the attached mesh,
  82789. */
  82790. render(): void;
  82791. /**
  82792. * Checks wether or not the edges renderer is ready to render.
  82793. * @return true if ready, otherwise false.
  82794. */
  82795. isReady(): boolean;
  82796. }
  82797. /**
  82798. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  82799. */
  82800. export class EdgesRenderer implements IEdgesRenderer {
  82801. /**
  82802. * Define the size of the edges with an orthographic camera
  82803. */
  82804. edgesWidthScalerForOrthographic: number;
  82805. /**
  82806. * Define the size of the edges with a perspective camera
  82807. */
  82808. edgesWidthScalerForPerspective: number;
  82809. protected _source: AbstractMesh;
  82810. protected _linesPositions: number[];
  82811. protected _linesNormals: number[];
  82812. protected _linesIndices: number[];
  82813. protected _epsilon: number;
  82814. protected _indicesCount: number;
  82815. protected _lineShader: ShaderMaterial;
  82816. protected _ib: DataBuffer;
  82817. protected _buffers: {
  82818. [key: string]: Nullable<VertexBuffer>;
  82819. };
  82820. protected _checkVerticesInsteadOfIndices: boolean;
  82821. private _meshRebuildObserver;
  82822. private _meshDisposeObserver;
  82823. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  82824. isEnabled: boolean;
  82825. /**
  82826. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  82827. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  82828. * @param source Mesh used to create edges
  82829. * @param epsilon sum of angles in adjacency to check for edge
  82830. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  82831. * @param generateEdgesLines - should generate Lines or only prepare resources.
  82832. */
  82833. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  82834. protected _prepareRessources(): void;
  82835. /** @hidden */
  82836. _rebuild(): void;
  82837. /**
  82838. * Releases the required resources for the edges renderer
  82839. */
  82840. dispose(): void;
  82841. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  82842. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  82843. /**
  82844. * Checks if the pair of p0 and p1 is en edge
  82845. * @param faceIndex
  82846. * @param edge
  82847. * @param faceNormals
  82848. * @param p0
  82849. * @param p1
  82850. * @private
  82851. */
  82852. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  82853. /**
  82854. * push line into the position, normal and index buffer
  82855. * @protected
  82856. */
  82857. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  82858. /**
  82859. * Generates lines edges from adjacencjes
  82860. * @private
  82861. */
  82862. _generateEdgesLines(): void;
  82863. /**
  82864. * Checks wether or not the edges renderer is ready to render.
  82865. * @return true if ready, otherwise false.
  82866. */
  82867. isReady(): boolean;
  82868. /**
  82869. * Renders the edges of the attached mesh,
  82870. */
  82871. render(): void;
  82872. }
  82873. /**
  82874. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  82875. */
  82876. export class LineEdgesRenderer extends EdgesRenderer {
  82877. /**
  82878. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  82879. * @param source LineMesh used to generate edges
  82880. * @param epsilon not important (specified angle for edge detection)
  82881. * @param checkVerticesInsteadOfIndices not important for LineMesh
  82882. */
  82883. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  82884. /**
  82885. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  82886. */
  82887. _generateEdgesLines(): void;
  82888. }
  82889. }
  82890. declare module BABYLON {
  82891. /**
  82892. * This represents the object necessary to create a rendering group.
  82893. * This is exclusively used and created by the rendering manager.
  82894. * To modify the behavior, you use the available helpers in your scene or meshes.
  82895. * @hidden
  82896. */
  82897. export class RenderingGroup {
  82898. index: number;
  82899. private static _zeroVector;
  82900. private _scene;
  82901. private _opaqueSubMeshes;
  82902. private _transparentSubMeshes;
  82903. private _alphaTestSubMeshes;
  82904. private _depthOnlySubMeshes;
  82905. private _particleSystems;
  82906. private _spriteManagers;
  82907. private _opaqueSortCompareFn;
  82908. private _alphaTestSortCompareFn;
  82909. private _transparentSortCompareFn;
  82910. private _renderOpaque;
  82911. private _renderAlphaTest;
  82912. private _renderTransparent;
  82913. /** @hidden */
  82914. _edgesRenderers: SmartArray<IEdgesRenderer>;
  82915. onBeforeTransparentRendering: () => void;
  82916. /**
  82917. * Set the opaque sort comparison function.
  82918. * If null the sub meshes will be render in the order they were created
  82919. */
  82920. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  82921. /**
  82922. * Set the alpha test sort comparison function.
  82923. * If null the sub meshes will be render in the order they were created
  82924. */
  82925. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  82926. /**
  82927. * Set the transparent sort comparison function.
  82928. * If null the sub meshes will be render in the order they were created
  82929. */
  82930. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  82931. /**
  82932. * Creates a new rendering group.
  82933. * @param index The rendering group index
  82934. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  82935. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  82936. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  82937. */
  82938. 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>);
  82939. /**
  82940. * Render all the sub meshes contained in the group.
  82941. * @param customRenderFunction Used to override the default render behaviour of the group.
  82942. * @returns true if rendered some submeshes.
  82943. */
  82944. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  82945. /**
  82946. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  82947. * @param subMeshes The submeshes to render
  82948. */
  82949. private renderOpaqueSorted;
  82950. /**
  82951. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  82952. * @param subMeshes The submeshes to render
  82953. */
  82954. private renderAlphaTestSorted;
  82955. /**
  82956. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  82957. * @param subMeshes The submeshes to render
  82958. */
  82959. private renderTransparentSorted;
  82960. /**
  82961. * Renders the submeshes in a specified order.
  82962. * @param subMeshes The submeshes to sort before render
  82963. * @param sortCompareFn The comparison function use to sort
  82964. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  82965. * @param transparent Specifies to activate blending if true
  82966. */
  82967. private static renderSorted;
  82968. /**
  82969. * Renders the submeshes in the order they were dispatched (no sort applied).
  82970. * @param subMeshes The submeshes to render
  82971. */
  82972. private static renderUnsorted;
  82973. /**
  82974. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  82975. * are rendered back to front if in the same alpha index.
  82976. *
  82977. * @param a The first submesh
  82978. * @param b The second submesh
  82979. * @returns The result of the comparison
  82980. */
  82981. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  82982. /**
  82983. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  82984. * are rendered back to front.
  82985. *
  82986. * @param a The first submesh
  82987. * @param b The second submesh
  82988. * @returns The result of the comparison
  82989. */
  82990. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  82991. /**
  82992. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  82993. * are rendered front to back (prevent overdraw).
  82994. *
  82995. * @param a The first submesh
  82996. * @param b The second submesh
  82997. * @returns The result of the comparison
  82998. */
  82999. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83000. /**
  83001. * Resets the different lists of submeshes to prepare a new frame.
  83002. */
  83003. prepare(): void;
  83004. dispose(): void;
  83005. /**
  83006. * Inserts the submesh in its correct queue depending on its material.
  83007. * @param subMesh The submesh to dispatch
  83008. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83009. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83010. */
  83011. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83012. dispatchSprites(spriteManager: ISpriteManager): void;
  83013. dispatchParticles(particleSystem: IParticleSystem): void;
  83014. private _renderParticles;
  83015. private _renderSprites;
  83016. }
  83017. }
  83018. declare module BABYLON {
  83019. /**
  83020. * Interface describing the different options available in the rendering manager
  83021. * regarding Auto Clear between groups.
  83022. */
  83023. export interface IRenderingManagerAutoClearSetup {
  83024. /**
  83025. * Defines whether or not autoclear is enable.
  83026. */
  83027. autoClear: boolean;
  83028. /**
  83029. * Defines whether or not to autoclear the depth buffer.
  83030. */
  83031. depth: boolean;
  83032. /**
  83033. * Defines whether or not to autoclear the stencil buffer.
  83034. */
  83035. stencil: boolean;
  83036. }
  83037. /**
  83038. * This class is used by the onRenderingGroupObservable
  83039. */
  83040. export class RenderingGroupInfo {
  83041. /**
  83042. * The Scene that being rendered
  83043. */
  83044. scene: Scene;
  83045. /**
  83046. * The camera currently used for the rendering pass
  83047. */
  83048. camera: Nullable<Camera>;
  83049. /**
  83050. * The ID of the renderingGroup being processed
  83051. */
  83052. renderingGroupId: number;
  83053. }
  83054. /**
  83055. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83056. * It is enable to manage the different groups as well as the different necessary sort functions.
  83057. * This should not be used directly aside of the few static configurations
  83058. */
  83059. export class RenderingManager {
  83060. /**
  83061. * The max id used for rendering groups (not included)
  83062. */
  83063. static MAX_RENDERINGGROUPS: number;
  83064. /**
  83065. * The min id used for rendering groups (included)
  83066. */
  83067. static MIN_RENDERINGGROUPS: number;
  83068. /**
  83069. * Used to globally prevent autoclearing scenes.
  83070. */
  83071. static AUTOCLEAR: boolean;
  83072. /**
  83073. * @hidden
  83074. */
  83075. _useSceneAutoClearSetup: boolean;
  83076. private _scene;
  83077. private _renderingGroups;
  83078. private _depthStencilBufferAlreadyCleaned;
  83079. private _autoClearDepthStencil;
  83080. private _customOpaqueSortCompareFn;
  83081. private _customAlphaTestSortCompareFn;
  83082. private _customTransparentSortCompareFn;
  83083. private _renderingGroupInfo;
  83084. /**
  83085. * Instantiates a new rendering group for a particular scene
  83086. * @param scene Defines the scene the groups belongs to
  83087. */
  83088. constructor(scene: Scene);
  83089. private _clearDepthStencilBuffer;
  83090. /**
  83091. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  83092. * @hidden
  83093. */
  83094. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  83095. /**
  83096. * Resets the different information of the group to prepare a new frame
  83097. * @hidden
  83098. */
  83099. reset(): void;
  83100. /**
  83101. * Dispose and release the group and its associated resources.
  83102. * @hidden
  83103. */
  83104. dispose(): void;
  83105. /**
  83106. * Clear the info related to rendering groups preventing retention points during dispose.
  83107. */
  83108. freeRenderingGroups(): void;
  83109. private _prepareRenderingGroup;
  83110. /**
  83111. * Add a sprite manager to the rendering manager in order to render it this frame.
  83112. * @param spriteManager Define the sprite manager to render
  83113. */
  83114. dispatchSprites(spriteManager: ISpriteManager): void;
  83115. /**
  83116. * Add a particle system to the rendering manager in order to render it this frame.
  83117. * @param particleSystem Define the particle system to render
  83118. */
  83119. dispatchParticles(particleSystem: IParticleSystem): void;
  83120. /**
  83121. * Add a submesh to the manager in order to render it this frame
  83122. * @param subMesh The submesh to dispatch
  83123. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83124. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83125. */
  83126. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83127. /**
  83128. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83129. * This allowed control for front to back rendering or reversly depending of the special needs.
  83130. *
  83131. * @param renderingGroupId The rendering group id corresponding to its index
  83132. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83133. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83134. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83135. */
  83136. 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;
  83137. /**
  83138. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83139. *
  83140. * @param renderingGroupId The rendering group id corresponding to its index
  83141. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83142. * @param depth Automatically clears depth between groups if true and autoClear is true.
  83143. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  83144. */
  83145. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  83146. /**
  83147. * Gets the current auto clear configuration for one rendering group of the rendering
  83148. * manager.
  83149. * @param index the rendering group index to get the information for
  83150. * @returns The auto clear setup for the requested rendering group
  83151. */
  83152. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  83153. }
  83154. }
  83155. declare module BABYLON {
  83156. /**
  83157. * This Helps creating a texture that will be created from a camera in your scene.
  83158. * It is basically a dynamic texture that could be used to create special effects for instance.
  83159. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  83160. */
  83161. export class RenderTargetTexture extends Texture {
  83162. isCube: boolean;
  83163. /**
  83164. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  83165. */
  83166. static readonly REFRESHRATE_RENDER_ONCE: number;
  83167. /**
  83168. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  83169. */
  83170. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  83171. /**
  83172. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  83173. * the central point of your effect and can save a lot of performances.
  83174. */
  83175. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  83176. /**
  83177. * Use this predicate to dynamically define the list of mesh you want to render.
  83178. * If set, the renderList property will be overwritten.
  83179. */
  83180. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  83181. private _renderList;
  83182. /**
  83183. * Use this list to define the list of mesh you want to render.
  83184. */
  83185. renderList: Nullable<Array<AbstractMesh>>;
  83186. private _hookArray;
  83187. /**
  83188. * Define if particles should be rendered in your texture.
  83189. */
  83190. renderParticles: boolean;
  83191. /**
  83192. * Define if sprites should be rendered in your texture.
  83193. */
  83194. renderSprites: boolean;
  83195. /**
  83196. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  83197. */
  83198. coordinatesMode: number;
  83199. /**
  83200. * Define the camera used to render the texture.
  83201. */
  83202. activeCamera: Nullable<Camera>;
  83203. /**
  83204. * Override the render function of the texture with your own one.
  83205. */
  83206. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  83207. /**
  83208. * Define if camera post processes should be use while rendering the texture.
  83209. */
  83210. useCameraPostProcesses: boolean;
  83211. /**
  83212. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  83213. */
  83214. ignoreCameraViewport: boolean;
  83215. private _postProcessManager;
  83216. private _postProcesses;
  83217. private _resizeObserver;
  83218. /**
  83219. * An event triggered when the texture is unbind.
  83220. */
  83221. onBeforeBindObservable: Observable<RenderTargetTexture>;
  83222. /**
  83223. * An event triggered when the texture is unbind.
  83224. */
  83225. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  83226. private _onAfterUnbindObserver;
  83227. /**
  83228. * Set a after unbind callback in the texture.
  83229. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  83230. */
  83231. onAfterUnbind: () => void;
  83232. /**
  83233. * An event triggered before rendering the texture
  83234. */
  83235. onBeforeRenderObservable: Observable<number>;
  83236. private _onBeforeRenderObserver;
  83237. /**
  83238. * Set a before render callback in the texture.
  83239. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  83240. */
  83241. onBeforeRender: (faceIndex: number) => void;
  83242. /**
  83243. * An event triggered after rendering the texture
  83244. */
  83245. onAfterRenderObservable: Observable<number>;
  83246. private _onAfterRenderObserver;
  83247. /**
  83248. * Set a after render callback in the texture.
  83249. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  83250. */
  83251. onAfterRender: (faceIndex: number) => void;
  83252. /**
  83253. * An event triggered after the texture clear
  83254. */
  83255. onClearObservable: Observable<Engine>;
  83256. private _onClearObserver;
  83257. /**
  83258. * Set a clear callback in the texture.
  83259. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  83260. */
  83261. onClear: (Engine: Engine) => void;
  83262. /**
  83263. * Define the clear color of the Render Target if it should be different from the scene.
  83264. */
  83265. clearColor: Color4;
  83266. protected _size: number | {
  83267. width: number;
  83268. height: number;
  83269. };
  83270. protected _initialSizeParameter: number | {
  83271. width: number;
  83272. height: number;
  83273. } | {
  83274. ratio: number;
  83275. };
  83276. protected _sizeRatio: Nullable<number>;
  83277. /** @hidden */
  83278. _generateMipMaps: boolean;
  83279. protected _renderingManager: RenderingManager;
  83280. /** @hidden */
  83281. _waitingRenderList: string[];
  83282. protected _doNotChangeAspectRatio: boolean;
  83283. protected _currentRefreshId: number;
  83284. protected _refreshRate: number;
  83285. protected _textureMatrix: Matrix;
  83286. protected _samples: number;
  83287. protected _renderTargetOptions: RenderTargetCreationOptions;
  83288. /**
  83289. * Gets render target creation options that were used.
  83290. */
  83291. readonly renderTargetOptions: RenderTargetCreationOptions;
  83292. protected _engine: Engine;
  83293. protected _onRatioRescale(): void;
  83294. /**
  83295. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  83296. * It must define where the camera used to render the texture is set
  83297. */
  83298. boundingBoxPosition: Vector3;
  83299. private _boundingBoxSize;
  83300. /**
  83301. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  83302. * When defined, the cubemap will switch to local mode
  83303. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83304. * @example https://www.babylonjs-playground.com/#RNASML
  83305. */
  83306. boundingBoxSize: Vector3;
  83307. /**
  83308. * In case the RTT has been created with a depth texture, get the associated
  83309. * depth texture.
  83310. * Otherwise, return null.
  83311. */
  83312. depthStencilTexture: Nullable<InternalTexture>;
  83313. /**
  83314. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  83315. * or used a shadow, depth texture...
  83316. * @param name The friendly name of the texture
  83317. * @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)
  83318. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  83319. * @param generateMipMaps True if mip maps need to be generated after render.
  83320. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  83321. * @param type The type of the buffer in the RTT (int, half float, float...)
  83322. * @param isCube True if a cube texture needs to be created
  83323. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  83324. * @param generateDepthBuffer True to generate a depth buffer
  83325. * @param generateStencilBuffer True to generate a stencil buffer
  83326. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  83327. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  83328. * @param delayAllocation if the texture allocation should be delayed (default: false)
  83329. */
  83330. constructor(name: string, size: number | {
  83331. width: number;
  83332. height: number;
  83333. } | {
  83334. ratio: number;
  83335. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  83336. /**
  83337. * Creates a depth stencil texture.
  83338. * This is only available in WebGL 2 or with the depth texture extension available.
  83339. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  83340. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  83341. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  83342. */
  83343. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  83344. private _processSizeParameter;
  83345. /**
  83346. * Define the number of samples to use in case of MSAA.
  83347. * It defaults to one meaning no MSAA has been enabled.
  83348. */
  83349. samples: number;
  83350. /**
  83351. * Resets the refresh counter of the texture and start bak from scratch.
  83352. * Could be useful to regenerate the texture if it is setup to render only once.
  83353. */
  83354. resetRefreshCounter(): void;
  83355. /**
  83356. * Define the refresh rate of the texture or the rendering frequency.
  83357. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83358. */
  83359. refreshRate: number;
  83360. /**
  83361. * Adds a post process to the render target rendering passes.
  83362. * @param postProcess define the post process to add
  83363. */
  83364. addPostProcess(postProcess: PostProcess): void;
  83365. /**
  83366. * Clear all the post processes attached to the render target
  83367. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  83368. */
  83369. clearPostProcesses(dispose?: boolean): void;
  83370. /**
  83371. * Remove one of the post process from the list of attached post processes to the texture
  83372. * @param postProcess define the post process to remove from the list
  83373. */
  83374. removePostProcess(postProcess: PostProcess): void;
  83375. /** @hidden */
  83376. _shouldRender(): boolean;
  83377. /**
  83378. * Gets the actual render size of the texture.
  83379. * @returns the width of the render size
  83380. */
  83381. getRenderSize(): number;
  83382. /**
  83383. * Gets the actual render width of the texture.
  83384. * @returns the width of the render size
  83385. */
  83386. getRenderWidth(): number;
  83387. /**
  83388. * Gets the actual render height of the texture.
  83389. * @returns the height of the render size
  83390. */
  83391. getRenderHeight(): number;
  83392. /**
  83393. * Get if the texture can be rescaled or not.
  83394. */
  83395. readonly canRescale: boolean;
  83396. /**
  83397. * Resize the texture using a ratio.
  83398. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  83399. */
  83400. scale(ratio: number): void;
  83401. /**
  83402. * Get the texture reflection matrix used to rotate/transform the reflection.
  83403. * @returns the reflection matrix
  83404. */
  83405. getReflectionTextureMatrix(): Matrix;
  83406. /**
  83407. * Resize the texture to a new desired size.
  83408. * Be carrefull as it will recreate all the data in the new texture.
  83409. * @param size Define the new size. It can be:
  83410. * - a number for squared texture,
  83411. * - an object containing { width: number, height: number }
  83412. * - or an object containing a ratio { ratio: number }
  83413. */
  83414. resize(size: number | {
  83415. width: number;
  83416. height: number;
  83417. } | {
  83418. ratio: number;
  83419. }): void;
  83420. /**
  83421. * Renders all the objects from the render list into the texture.
  83422. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  83423. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  83424. */
  83425. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  83426. private _bestReflectionRenderTargetDimension;
  83427. /**
  83428. * @hidden
  83429. * @param faceIndex face index to bind to if this is a cubetexture
  83430. */
  83431. _bindFrameBuffer(faceIndex?: number): void;
  83432. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83433. private renderToTarget;
  83434. /**
  83435. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83436. * This allowed control for front to back rendering or reversly depending of the special needs.
  83437. *
  83438. * @param renderingGroupId The rendering group id corresponding to its index
  83439. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83440. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83441. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83442. */
  83443. 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;
  83444. /**
  83445. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83446. *
  83447. * @param renderingGroupId The rendering group id corresponding to its index
  83448. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83449. */
  83450. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  83451. /**
  83452. * Clones the texture.
  83453. * @returns the cloned texture
  83454. */
  83455. clone(): RenderTargetTexture;
  83456. /**
  83457. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83458. * @returns The JSON representation of the texture
  83459. */
  83460. serialize(): any;
  83461. /**
  83462. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  83463. */
  83464. disposeFramebufferObjects(): void;
  83465. /**
  83466. * Dispose the texture and release its associated resources.
  83467. */
  83468. dispose(): void;
  83469. /** @hidden */
  83470. _rebuild(): void;
  83471. /**
  83472. * Clear the info related to rendering groups preventing retention point in material dispose.
  83473. */
  83474. freeRenderingGroups(): void;
  83475. /**
  83476. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83477. * @returns the view count
  83478. */
  83479. getViewCount(): number;
  83480. }
  83481. }
  83482. declare module BABYLON {
  83483. /**
  83484. * Base class for the main features of a material in Babylon.js
  83485. */
  83486. export class Material implements IAnimatable {
  83487. /**
  83488. * Returns the triangle fill mode
  83489. */
  83490. static readonly TriangleFillMode: number;
  83491. /**
  83492. * Returns the wireframe mode
  83493. */
  83494. static readonly WireFrameFillMode: number;
  83495. /**
  83496. * Returns the point fill mode
  83497. */
  83498. static readonly PointFillMode: number;
  83499. /**
  83500. * Returns the point list draw mode
  83501. */
  83502. static readonly PointListDrawMode: number;
  83503. /**
  83504. * Returns the line list draw mode
  83505. */
  83506. static readonly LineListDrawMode: number;
  83507. /**
  83508. * Returns the line loop draw mode
  83509. */
  83510. static readonly LineLoopDrawMode: number;
  83511. /**
  83512. * Returns the line strip draw mode
  83513. */
  83514. static readonly LineStripDrawMode: number;
  83515. /**
  83516. * Returns the triangle strip draw mode
  83517. */
  83518. static readonly TriangleStripDrawMode: number;
  83519. /**
  83520. * Returns the triangle fan draw mode
  83521. */
  83522. static readonly TriangleFanDrawMode: number;
  83523. /**
  83524. * Stores the clock-wise side orientation
  83525. */
  83526. static readonly ClockWiseSideOrientation: number;
  83527. /**
  83528. * Stores the counter clock-wise side orientation
  83529. */
  83530. static readonly CounterClockWiseSideOrientation: number;
  83531. /**
  83532. * The dirty texture flag value
  83533. */
  83534. static readonly TextureDirtyFlag: number;
  83535. /**
  83536. * The dirty light flag value
  83537. */
  83538. static readonly LightDirtyFlag: number;
  83539. /**
  83540. * The dirty fresnel flag value
  83541. */
  83542. static readonly FresnelDirtyFlag: number;
  83543. /**
  83544. * The dirty attribute flag value
  83545. */
  83546. static readonly AttributesDirtyFlag: number;
  83547. /**
  83548. * The dirty misc flag value
  83549. */
  83550. static readonly MiscDirtyFlag: number;
  83551. /**
  83552. * The all dirty flag value
  83553. */
  83554. static readonly AllDirtyFlag: number;
  83555. /**
  83556. * The ID of the material
  83557. */
  83558. id: string;
  83559. /**
  83560. * Gets or sets the unique id of the material
  83561. */
  83562. uniqueId: number;
  83563. /**
  83564. * The name of the material
  83565. */
  83566. name: string;
  83567. /**
  83568. * Gets or sets user defined metadata
  83569. */
  83570. metadata: any;
  83571. /**
  83572. * For internal use only. Please do not use.
  83573. */
  83574. reservedDataStore: any;
  83575. /**
  83576. * Specifies if the ready state should be checked on each call
  83577. */
  83578. checkReadyOnEveryCall: boolean;
  83579. /**
  83580. * Specifies if the ready state should be checked once
  83581. */
  83582. checkReadyOnlyOnce: boolean;
  83583. /**
  83584. * The state of the material
  83585. */
  83586. state: string;
  83587. /**
  83588. * The alpha value of the material
  83589. */
  83590. protected _alpha: number;
  83591. /**
  83592. * List of inspectable custom properties (used by the Inspector)
  83593. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83594. */
  83595. inspectableCustomProperties: IInspectable[];
  83596. /**
  83597. * Sets the alpha value of the material
  83598. */
  83599. /**
  83600. * Gets the alpha value of the material
  83601. */
  83602. alpha: number;
  83603. /**
  83604. * Specifies if back face culling is enabled
  83605. */
  83606. protected _backFaceCulling: boolean;
  83607. /**
  83608. * Sets the back-face culling state
  83609. */
  83610. /**
  83611. * Gets the back-face culling state
  83612. */
  83613. backFaceCulling: boolean;
  83614. /**
  83615. * Stores the value for side orientation
  83616. */
  83617. sideOrientation: number;
  83618. /**
  83619. * Callback triggered when the material is compiled
  83620. */
  83621. onCompiled: Nullable<(effect: Effect) => void>;
  83622. /**
  83623. * Callback triggered when an error occurs
  83624. */
  83625. onError: Nullable<(effect: Effect, errors: string) => void>;
  83626. /**
  83627. * Callback triggered to get the render target textures
  83628. */
  83629. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  83630. /**
  83631. * Gets a boolean indicating that current material needs to register RTT
  83632. */
  83633. readonly hasRenderTargetTextures: boolean;
  83634. /**
  83635. * Specifies if the material should be serialized
  83636. */
  83637. doNotSerialize: boolean;
  83638. /**
  83639. * @hidden
  83640. */
  83641. _storeEffectOnSubMeshes: boolean;
  83642. /**
  83643. * Stores the animations for the material
  83644. */
  83645. animations: Nullable<Array<Animation>>;
  83646. /**
  83647. * An event triggered when the material is disposed
  83648. */
  83649. onDisposeObservable: Observable<Material>;
  83650. /**
  83651. * An observer which watches for dispose events
  83652. */
  83653. private _onDisposeObserver;
  83654. private _onUnBindObservable;
  83655. /**
  83656. * Called during a dispose event
  83657. */
  83658. onDispose: () => void;
  83659. private _onBindObservable;
  83660. /**
  83661. * An event triggered when the material is bound
  83662. */
  83663. readonly onBindObservable: Observable<AbstractMesh>;
  83664. /**
  83665. * An observer which watches for bind events
  83666. */
  83667. private _onBindObserver;
  83668. /**
  83669. * Called during a bind event
  83670. */
  83671. onBind: (Mesh: AbstractMesh) => void;
  83672. /**
  83673. * An event triggered when the material is unbound
  83674. */
  83675. readonly onUnBindObservable: Observable<Material>;
  83676. /**
  83677. * Stores the value of the alpha mode
  83678. */
  83679. private _alphaMode;
  83680. /**
  83681. * Sets the value of the alpha mode.
  83682. *
  83683. * | Value | Type | Description |
  83684. * | --- | --- | --- |
  83685. * | 0 | ALPHA_DISABLE | |
  83686. * | 1 | ALPHA_ADD | |
  83687. * | 2 | ALPHA_COMBINE | |
  83688. * | 3 | ALPHA_SUBTRACT | |
  83689. * | 4 | ALPHA_MULTIPLY | |
  83690. * | 5 | ALPHA_MAXIMIZED | |
  83691. * | 6 | ALPHA_ONEONE | |
  83692. * | 7 | ALPHA_PREMULTIPLIED | |
  83693. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  83694. * | 9 | ALPHA_INTERPOLATE | |
  83695. * | 10 | ALPHA_SCREENMODE | |
  83696. *
  83697. */
  83698. /**
  83699. * Gets the value of the alpha mode
  83700. */
  83701. alphaMode: number;
  83702. /**
  83703. * Stores the state of the need depth pre-pass value
  83704. */
  83705. private _needDepthPrePass;
  83706. /**
  83707. * Sets the need depth pre-pass value
  83708. */
  83709. /**
  83710. * Gets the depth pre-pass value
  83711. */
  83712. needDepthPrePass: boolean;
  83713. /**
  83714. * Specifies if depth writing should be disabled
  83715. */
  83716. disableDepthWrite: boolean;
  83717. /**
  83718. * Specifies if depth writing should be forced
  83719. */
  83720. forceDepthWrite: boolean;
  83721. /**
  83722. * Specifies if there should be a separate pass for culling
  83723. */
  83724. separateCullingPass: boolean;
  83725. /**
  83726. * Stores the state specifing if fog should be enabled
  83727. */
  83728. private _fogEnabled;
  83729. /**
  83730. * Sets the state for enabling fog
  83731. */
  83732. /**
  83733. * Gets the value of the fog enabled state
  83734. */
  83735. fogEnabled: boolean;
  83736. /**
  83737. * Stores the size of points
  83738. */
  83739. pointSize: number;
  83740. /**
  83741. * Stores the z offset value
  83742. */
  83743. zOffset: number;
  83744. /**
  83745. * Gets a value specifying if wireframe mode is enabled
  83746. */
  83747. /**
  83748. * Sets the state of wireframe mode
  83749. */
  83750. wireframe: boolean;
  83751. /**
  83752. * Gets the value specifying if point clouds are enabled
  83753. */
  83754. /**
  83755. * Sets the state of point cloud mode
  83756. */
  83757. pointsCloud: boolean;
  83758. /**
  83759. * Gets the material fill mode
  83760. */
  83761. /**
  83762. * Sets the material fill mode
  83763. */
  83764. fillMode: number;
  83765. /**
  83766. * @hidden
  83767. * Stores the effects for the material
  83768. */
  83769. _effect: Nullable<Effect>;
  83770. /**
  83771. * @hidden
  83772. * Specifies if the material was previously ready
  83773. */
  83774. _wasPreviouslyReady: boolean;
  83775. /**
  83776. * Specifies if uniform buffers should be used
  83777. */
  83778. private _useUBO;
  83779. /**
  83780. * Stores a reference to the scene
  83781. */
  83782. private _scene;
  83783. /**
  83784. * Stores the fill mode state
  83785. */
  83786. private _fillMode;
  83787. /**
  83788. * Specifies if the depth write state should be cached
  83789. */
  83790. private _cachedDepthWriteState;
  83791. /**
  83792. * Stores the uniform buffer
  83793. */
  83794. protected _uniformBuffer: UniformBuffer;
  83795. /** @hidden */
  83796. _indexInSceneMaterialArray: number;
  83797. /** @hidden */
  83798. meshMap: Nullable<{
  83799. [id: string]: AbstractMesh | undefined;
  83800. }>;
  83801. /**
  83802. * Creates a material instance
  83803. * @param name defines the name of the material
  83804. * @param scene defines the scene to reference
  83805. * @param doNotAdd specifies if the material should be added to the scene
  83806. */
  83807. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  83808. /**
  83809. * Returns a string representation of the current material
  83810. * @param fullDetails defines a boolean indicating which levels of logging is desired
  83811. * @returns a string with material information
  83812. */
  83813. toString(fullDetails?: boolean): string;
  83814. /**
  83815. * Gets the class name of the material
  83816. * @returns a string with the class name of the material
  83817. */
  83818. getClassName(): string;
  83819. /**
  83820. * Specifies if updates for the material been locked
  83821. */
  83822. readonly isFrozen: boolean;
  83823. /**
  83824. * Locks updates for the material
  83825. */
  83826. freeze(): void;
  83827. /**
  83828. * Unlocks updates for the material
  83829. */
  83830. unfreeze(): void;
  83831. /**
  83832. * Specifies if the material is ready to be used
  83833. * @param mesh defines the mesh to check
  83834. * @param useInstances specifies if instances should be used
  83835. * @returns a boolean indicating if the material is ready to be used
  83836. */
  83837. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83838. /**
  83839. * Specifies that the submesh is ready to be used
  83840. * @param mesh defines the mesh to check
  83841. * @param subMesh defines which submesh to check
  83842. * @param useInstances specifies that instances should be used
  83843. * @returns a boolean indicating that the submesh is ready or not
  83844. */
  83845. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83846. /**
  83847. * Returns the material effect
  83848. * @returns the effect associated with the material
  83849. */
  83850. getEffect(): Nullable<Effect>;
  83851. /**
  83852. * Returns the current scene
  83853. * @returns a Scene
  83854. */
  83855. getScene(): Scene;
  83856. /**
  83857. * Specifies if the material will require alpha blending
  83858. * @returns a boolean specifying if alpha blending is needed
  83859. */
  83860. needAlphaBlending(): boolean;
  83861. /**
  83862. * Specifies if the mesh will require alpha blending
  83863. * @param mesh defines the mesh to check
  83864. * @returns a boolean specifying if alpha blending is needed for the mesh
  83865. */
  83866. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  83867. /**
  83868. * Specifies if this material should be rendered in alpha test mode
  83869. * @returns a boolean specifying if an alpha test is needed.
  83870. */
  83871. needAlphaTesting(): boolean;
  83872. /**
  83873. * Gets the texture used for the alpha test
  83874. * @returns the texture to use for alpha testing
  83875. */
  83876. getAlphaTestTexture(): Nullable<BaseTexture>;
  83877. /**
  83878. * Marks the material to indicate that it needs to be re-calculated
  83879. */
  83880. markDirty(): void;
  83881. /** @hidden */
  83882. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  83883. /**
  83884. * Binds the material to the mesh
  83885. * @param world defines the world transformation matrix
  83886. * @param mesh defines the mesh to bind the material to
  83887. */
  83888. bind(world: Matrix, mesh?: Mesh): void;
  83889. /**
  83890. * Binds the submesh to the material
  83891. * @param world defines the world transformation matrix
  83892. * @param mesh defines the mesh containing the submesh
  83893. * @param subMesh defines the submesh to bind the material to
  83894. */
  83895. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  83896. /**
  83897. * Binds the world matrix to the material
  83898. * @param world defines the world transformation matrix
  83899. */
  83900. bindOnlyWorldMatrix(world: Matrix): void;
  83901. /**
  83902. * Binds the scene's uniform buffer to the effect.
  83903. * @param effect defines the effect to bind to the scene uniform buffer
  83904. * @param sceneUbo defines the uniform buffer storing scene data
  83905. */
  83906. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  83907. /**
  83908. * Binds the view matrix to the effect
  83909. * @param effect defines the effect to bind the view matrix to
  83910. */
  83911. bindView(effect: Effect): void;
  83912. /**
  83913. * Binds the view projection matrix to the effect
  83914. * @param effect defines the effect to bind the view projection matrix to
  83915. */
  83916. bindViewProjection(effect: Effect): void;
  83917. /**
  83918. * Specifies if material alpha testing should be turned on for the mesh
  83919. * @param mesh defines the mesh to check
  83920. */
  83921. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  83922. /**
  83923. * Processes to execute after binding the material to a mesh
  83924. * @param mesh defines the rendered mesh
  83925. */
  83926. protected _afterBind(mesh?: Mesh): void;
  83927. /**
  83928. * Unbinds the material from the mesh
  83929. */
  83930. unbind(): void;
  83931. /**
  83932. * Gets the active textures from the material
  83933. * @returns an array of textures
  83934. */
  83935. getActiveTextures(): BaseTexture[];
  83936. /**
  83937. * Specifies if the material uses a texture
  83938. * @param texture defines the texture to check against the material
  83939. * @returns a boolean specifying if the material uses the texture
  83940. */
  83941. hasTexture(texture: BaseTexture): boolean;
  83942. /**
  83943. * Makes a duplicate of the material, and gives it a new name
  83944. * @param name defines the new name for the duplicated material
  83945. * @returns the cloned material
  83946. */
  83947. clone(name: string): Nullable<Material>;
  83948. /**
  83949. * Gets the meshes bound to the material
  83950. * @returns an array of meshes bound to the material
  83951. */
  83952. getBindedMeshes(): AbstractMesh[];
  83953. /**
  83954. * Force shader compilation
  83955. * @param mesh defines the mesh associated with this material
  83956. * @param onCompiled defines a function to execute once the material is compiled
  83957. * @param options defines the options to configure the compilation
  83958. */
  83959. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  83960. clipPlane: boolean;
  83961. }>): void;
  83962. /**
  83963. * Force shader compilation
  83964. * @param mesh defines the mesh that will use this material
  83965. * @param options defines additional options for compiling the shaders
  83966. * @returns a promise that resolves when the compilation completes
  83967. */
  83968. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  83969. clipPlane: boolean;
  83970. }>): Promise<void>;
  83971. private static readonly _AllDirtyCallBack;
  83972. private static readonly _ImageProcessingDirtyCallBack;
  83973. private static readonly _TextureDirtyCallBack;
  83974. private static readonly _FresnelDirtyCallBack;
  83975. private static readonly _MiscDirtyCallBack;
  83976. private static readonly _LightsDirtyCallBack;
  83977. private static readonly _AttributeDirtyCallBack;
  83978. private static _FresnelAndMiscDirtyCallBack;
  83979. private static _TextureAndMiscDirtyCallBack;
  83980. private static readonly _DirtyCallbackArray;
  83981. private static readonly _RunDirtyCallBacks;
  83982. /**
  83983. * Marks a define in the material to indicate that it needs to be re-computed
  83984. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  83985. */
  83986. markAsDirty(flag: number): void;
  83987. /**
  83988. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  83989. * @param func defines a function which checks material defines against the submeshes
  83990. */
  83991. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  83992. /**
  83993. * Indicates that we need to re-calculated for all submeshes
  83994. */
  83995. protected _markAllSubMeshesAsAllDirty(): void;
  83996. /**
  83997. * Indicates that image processing needs to be re-calculated for all submeshes
  83998. */
  83999. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84000. /**
  84001. * Indicates that textures need to be re-calculated for all submeshes
  84002. */
  84003. protected _markAllSubMeshesAsTexturesDirty(): void;
  84004. /**
  84005. * Indicates that fresnel needs to be re-calculated for all submeshes
  84006. */
  84007. protected _markAllSubMeshesAsFresnelDirty(): void;
  84008. /**
  84009. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84010. */
  84011. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84012. /**
  84013. * Indicates that lights need to be re-calculated for all submeshes
  84014. */
  84015. protected _markAllSubMeshesAsLightsDirty(): void;
  84016. /**
  84017. * Indicates that attributes need to be re-calculated for all submeshes
  84018. */
  84019. protected _markAllSubMeshesAsAttributesDirty(): void;
  84020. /**
  84021. * Indicates that misc needs to be re-calculated for all submeshes
  84022. */
  84023. protected _markAllSubMeshesAsMiscDirty(): void;
  84024. /**
  84025. * Indicates that textures and misc need to be re-calculated for all submeshes
  84026. */
  84027. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84028. /**
  84029. * Disposes the material
  84030. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84031. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84032. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84033. */
  84034. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84035. /** @hidden */
  84036. private releaseVertexArrayObject;
  84037. /**
  84038. * Serializes this material
  84039. * @returns the serialized material object
  84040. */
  84041. serialize(): any;
  84042. /**
  84043. * Creates a material from parsed material data
  84044. * @param parsedMaterial defines parsed material data
  84045. * @param scene defines the hosting scene
  84046. * @param rootUrl defines the root URL to use to load textures
  84047. * @returns a new material
  84048. */
  84049. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84050. }
  84051. }
  84052. declare module BABYLON {
  84053. /**
  84054. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84055. * separate meshes. This can be use to improve performances.
  84056. * @see http://doc.babylonjs.com/how_to/multi_materials
  84057. */
  84058. export class MultiMaterial extends Material {
  84059. private _subMaterials;
  84060. /**
  84061. * Gets or Sets the list of Materials used within the multi material.
  84062. * They need to be ordered according to the submeshes order in the associated mesh
  84063. */
  84064. subMaterials: Nullable<Material>[];
  84065. /**
  84066. * Function used to align with Node.getChildren()
  84067. * @returns the list of Materials used within the multi material
  84068. */
  84069. getChildren(): Nullable<Material>[];
  84070. /**
  84071. * Instantiates a new Multi Material
  84072. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84073. * separate meshes. This can be use to improve performances.
  84074. * @see http://doc.babylonjs.com/how_to/multi_materials
  84075. * @param name Define the name in the scene
  84076. * @param scene Define the scene the material belongs to
  84077. */
  84078. constructor(name: string, scene: Scene);
  84079. private _hookArray;
  84080. /**
  84081. * Get one of the submaterial by its index in the submaterials array
  84082. * @param index The index to look the sub material at
  84083. * @returns The Material if the index has been defined
  84084. */
  84085. getSubMaterial(index: number): Nullable<Material>;
  84086. /**
  84087. * Get the list of active textures for the whole sub materials list.
  84088. * @returns All the textures that will be used during the rendering
  84089. */
  84090. getActiveTextures(): BaseTexture[];
  84091. /**
  84092. * Gets the current class name of the material e.g. "MultiMaterial"
  84093. * Mainly use in serialization.
  84094. * @returns the class name
  84095. */
  84096. getClassName(): string;
  84097. /**
  84098. * Checks if the material is ready to render the requested sub mesh
  84099. * @param mesh Define the mesh the submesh belongs to
  84100. * @param subMesh Define the sub mesh to look readyness for
  84101. * @param useInstances Define whether or not the material is used with instances
  84102. * @returns true if ready, otherwise false
  84103. */
  84104. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84105. /**
  84106. * Clones the current material and its related sub materials
  84107. * @param name Define the name of the newly cloned material
  84108. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  84109. * @returns the cloned material
  84110. */
  84111. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  84112. /**
  84113. * Serializes the materials into a JSON representation.
  84114. * @returns the JSON representation
  84115. */
  84116. serialize(): any;
  84117. /**
  84118. * Dispose the material and release its associated resources
  84119. * @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)
  84120. * @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)
  84121. * @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)
  84122. */
  84123. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  84124. /**
  84125. * Creates a MultiMaterial from parsed MultiMaterial data.
  84126. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  84127. * @param scene defines the hosting scene
  84128. * @returns a new MultiMaterial
  84129. */
  84130. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  84131. }
  84132. }
  84133. declare module BABYLON {
  84134. /**
  84135. * Base class for submeshes
  84136. */
  84137. export class BaseSubMesh {
  84138. /** @hidden */
  84139. _materialDefines: Nullable<MaterialDefines>;
  84140. /** @hidden */
  84141. _materialEffect: Nullable<Effect>;
  84142. /**
  84143. * Gets associated effect
  84144. */
  84145. readonly effect: Nullable<Effect>;
  84146. /**
  84147. * Sets associated effect (effect used to render this submesh)
  84148. * @param effect defines the effect to associate with
  84149. * @param defines defines the set of defines used to compile this effect
  84150. */
  84151. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84152. }
  84153. /**
  84154. * Defines a subdivision inside a mesh
  84155. */
  84156. export class SubMesh extends BaseSubMesh implements ICullable {
  84157. /** the material index to use */
  84158. materialIndex: number;
  84159. /** vertex index start */
  84160. verticesStart: number;
  84161. /** vertices count */
  84162. verticesCount: number;
  84163. /** index start */
  84164. indexStart: number;
  84165. /** indices count */
  84166. indexCount: number;
  84167. /** @hidden */
  84168. _linesIndexCount: number;
  84169. private _mesh;
  84170. private _renderingMesh;
  84171. private _boundingInfo;
  84172. private _linesIndexBuffer;
  84173. /** @hidden */
  84174. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84175. /** @hidden */
  84176. _trianglePlanes: Plane[];
  84177. /** @hidden */
  84178. _lastColliderTransformMatrix: Nullable<Matrix>;
  84179. /** @hidden */
  84180. _renderId: number;
  84181. /** @hidden */
  84182. _alphaIndex: number;
  84183. /** @hidden */
  84184. _distanceToCamera: number;
  84185. /** @hidden */
  84186. _id: number;
  84187. private _currentMaterial;
  84188. /**
  84189. * Add a new submesh to a mesh
  84190. * @param materialIndex defines the material index to use
  84191. * @param verticesStart defines vertex index start
  84192. * @param verticesCount defines vertices count
  84193. * @param indexStart defines index start
  84194. * @param indexCount defines indices count
  84195. * @param mesh defines the parent mesh
  84196. * @param renderingMesh defines an optional rendering mesh
  84197. * @param createBoundingBox defines if bounding box should be created for this submesh
  84198. * @returns the new submesh
  84199. */
  84200. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84201. /**
  84202. * Creates a new submesh
  84203. * @param materialIndex defines the material index to use
  84204. * @param verticesStart defines vertex index start
  84205. * @param verticesCount defines vertices count
  84206. * @param indexStart defines index start
  84207. * @param indexCount defines indices count
  84208. * @param mesh defines the parent mesh
  84209. * @param renderingMesh defines an optional rendering mesh
  84210. * @param createBoundingBox defines if bounding box should be created for this submesh
  84211. */
  84212. constructor(
  84213. /** the material index to use */
  84214. materialIndex: number,
  84215. /** vertex index start */
  84216. verticesStart: number,
  84217. /** vertices count */
  84218. verticesCount: number,
  84219. /** index start */
  84220. indexStart: number,
  84221. /** indices count */
  84222. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84223. /**
  84224. * Returns true if this submesh covers the entire parent mesh
  84225. * @ignorenaming
  84226. */
  84227. readonly IsGlobal: boolean;
  84228. /**
  84229. * Returns the submesh BoudingInfo object
  84230. * @returns current bounding info (or mesh's one if the submesh is global)
  84231. */
  84232. getBoundingInfo(): BoundingInfo;
  84233. /**
  84234. * Sets the submesh BoundingInfo
  84235. * @param boundingInfo defines the new bounding info to use
  84236. * @returns the SubMesh
  84237. */
  84238. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84239. /**
  84240. * Returns the mesh of the current submesh
  84241. * @return the parent mesh
  84242. */
  84243. getMesh(): AbstractMesh;
  84244. /**
  84245. * Returns the rendering mesh of the submesh
  84246. * @returns the rendering mesh (could be different from parent mesh)
  84247. */
  84248. getRenderingMesh(): Mesh;
  84249. /**
  84250. * Returns the submesh material
  84251. * @returns null or the current material
  84252. */
  84253. getMaterial(): Nullable<Material>;
  84254. /**
  84255. * Sets a new updated BoundingInfo object to the submesh
  84256. * @param data defines an optional position array to use to determine the bounding info
  84257. * @returns the SubMesh
  84258. */
  84259. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84260. /** @hidden */
  84261. _checkCollision(collider: Collider): boolean;
  84262. /**
  84263. * Updates the submesh BoundingInfo
  84264. * @param world defines the world matrix to use to update the bounding info
  84265. * @returns the submesh
  84266. */
  84267. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84268. /**
  84269. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84270. * @param frustumPlanes defines the frustum planes
  84271. * @returns true if the submesh is intersecting with the frustum
  84272. */
  84273. isInFrustum(frustumPlanes: Plane[]): boolean;
  84274. /**
  84275. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84276. * @param frustumPlanes defines the frustum planes
  84277. * @returns true if the submesh is inside the frustum
  84278. */
  84279. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84280. /**
  84281. * Renders the submesh
  84282. * @param enableAlphaMode defines if alpha needs to be used
  84283. * @returns the submesh
  84284. */
  84285. render(enableAlphaMode: boolean): SubMesh;
  84286. /**
  84287. * @hidden
  84288. */
  84289. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84290. /**
  84291. * Checks if the submesh intersects with a ray
  84292. * @param ray defines the ray to test
  84293. * @returns true is the passed ray intersects the submesh bounding box
  84294. */
  84295. canIntersects(ray: Ray): boolean;
  84296. /**
  84297. * Intersects current submesh with a ray
  84298. * @param ray defines the ray to test
  84299. * @param positions defines mesh's positions array
  84300. * @param indices defines mesh's indices array
  84301. * @param fastCheck defines if only bounding info should be used
  84302. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84303. * @returns intersection info or null if no intersection
  84304. */
  84305. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84306. /** @hidden */
  84307. private _intersectLines;
  84308. /** @hidden */
  84309. private _intersectUnIndexedLines;
  84310. /** @hidden */
  84311. private _intersectTriangles;
  84312. /** @hidden */
  84313. private _intersectUnIndexedTriangles;
  84314. /** @hidden */
  84315. _rebuild(): void;
  84316. /**
  84317. * Creates a new submesh from the passed mesh
  84318. * @param newMesh defines the new hosting mesh
  84319. * @param newRenderingMesh defines an optional rendering mesh
  84320. * @returns the new submesh
  84321. */
  84322. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84323. /**
  84324. * Release associated resources
  84325. */
  84326. dispose(): void;
  84327. /**
  84328. * Gets the class name
  84329. * @returns the string "SubMesh".
  84330. */
  84331. getClassName(): string;
  84332. /**
  84333. * Creates a new submesh from indices data
  84334. * @param materialIndex the index of the main mesh material
  84335. * @param startIndex the index where to start the copy in the mesh indices array
  84336. * @param indexCount the number of indices to copy then from the startIndex
  84337. * @param mesh the main mesh to create the submesh from
  84338. * @param renderingMesh the optional rendering mesh
  84339. * @returns a new submesh
  84340. */
  84341. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84342. }
  84343. }
  84344. declare module BABYLON {
  84345. /**
  84346. * Class used to represent data loading progression
  84347. */
  84348. export class SceneLoaderFlags {
  84349. private static _ForceFullSceneLoadingForIncremental;
  84350. private static _ShowLoadingScreen;
  84351. private static _CleanBoneMatrixWeights;
  84352. private static _loggingLevel;
  84353. /**
  84354. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  84355. */
  84356. static ForceFullSceneLoadingForIncremental: boolean;
  84357. /**
  84358. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  84359. */
  84360. static ShowLoadingScreen: boolean;
  84361. /**
  84362. * Defines the current logging level (while loading the scene)
  84363. * @ignorenaming
  84364. */
  84365. static loggingLevel: number;
  84366. /**
  84367. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  84368. */
  84369. static CleanBoneMatrixWeights: boolean;
  84370. }
  84371. }
  84372. declare module BABYLON {
  84373. /**
  84374. * Class used to store geometry data (vertex buffers + index buffer)
  84375. */
  84376. export class Geometry implements IGetSetVerticesData {
  84377. /**
  84378. * Gets or sets the ID of the geometry
  84379. */
  84380. id: string;
  84381. /**
  84382. * Gets or sets the unique ID of the geometry
  84383. */
  84384. uniqueId: number;
  84385. /**
  84386. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84387. */
  84388. delayLoadState: number;
  84389. /**
  84390. * Gets the file containing the data to load when running in delay load state
  84391. */
  84392. delayLoadingFile: Nullable<string>;
  84393. /**
  84394. * Callback called when the geometry is updated
  84395. */
  84396. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84397. private _scene;
  84398. private _engine;
  84399. private _meshes;
  84400. private _totalVertices;
  84401. /** @hidden */
  84402. _indices: IndicesArray;
  84403. /** @hidden */
  84404. _vertexBuffers: {
  84405. [key: string]: VertexBuffer;
  84406. };
  84407. private _isDisposed;
  84408. private _extend;
  84409. private _boundingBias;
  84410. /** @hidden */
  84411. _delayInfo: Array<string>;
  84412. private _indexBuffer;
  84413. private _indexBufferIsUpdatable;
  84414. /** @hidden */
  84415. _boundingInfo: Nullable<BoundingInfo>;
  84416. /** @hidden */
  84417. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  84418. /** @hidden */
  84419. _softwareSkinningFrameId: number;
  84420. private _vertexArrayObjects;
  84421. private _updatable;
  84422. /** @hidden */
  84423. _positions: Nullable<Vector3[]>;
  84424. /**
  84425. * 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
  84426. */
  84427. /**
  84428. * 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
  84429. */
  84430. boundingBias: Vector2;
  84431. /**
  84432. * Static function used to attach a new empty geometry to a mesh
  84433. * @param mesh defines the mesh to attach the geometry to
  84434. * @returns the new Geometry
  84435. */
  84436. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  84437. /**
  84438. * Creates a new geometry
  84439. * @param id defines the unique ID
  84440. * @param scene defines the hosting scene
  84441. * @param vertexData defines the VertexData used to get geometry data
  84442. * @param updatable defines if geometry must be updatable (false by default)
  84443. * @param mesh defines the mesh that will be associated with the geometry
  84444. */
  84445. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  84446. /**
  84447. * Gets the current extend of the geometry
  84448. */
  84449. readonly extend: {
  84450. minimum: Vector3;
  84451. maximum: Vector3;
  84452. };
  84453. /**
  84454. * Gets the hosting scene
  84455. * @returns the hosting Scene
  84456. */
  84457. getScene(): Scene;
  84458. /**
  84459. * Gets the hosting engine
  84460. * @returns the hosting Engine
  84461. */
  84462. getEngine(): Engine;
  84463. /**
  84464. * Defines if the geometry is ready to use
  84465. * @returns true if the geometry is ready to be used
  84466. */
  84467. isReady(): boolean;
  84468. /**
  84469. * Gets a value indicating that the geometry should not be serialized
  84470. */
  84471. readonly doNotSerialize: boolean;
  84472. /** @hidden */
  84473. _rebuild(): void;
  84474. /**
  84475. * Affects all geometry data in one call
  84476. * @param vertexData defines the geometry data
  84477. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84478. */
  84479. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  84480. /**
  84481. * Set specific vertex data
  84482. * @param kind defines the data kind (Position, normal, etc...)
  84483. * @param data defines the vertex data to use
  84484. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84485. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84486. */
  84487. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  84488. /**
  84489. * Removes a specific vertex data
  84490. * @param kind defines the data kind (Position, normal, etc...)
  84491. */
  84492. removeVerticesData(kind: string): void;
  84493. /**
  84494. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84495. * @param buffer defines the vertex buffer to use
  84496. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84497. */
  84498. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  84499. /**
  84500. * Update a specific vertex buffer
  84501. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  84502. * It will do nothing if the buffer is not updatable
  84503. * @param kind defines the data kind (Position, normal, etc...)
  84504. * @param data defines the data to use
  84505. * @param offset defines the offset in the target buffer where to store the data
  84506. * @param useBytes set to true if the offset is in bytes
  84507. */
  84508. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  84509. /**
  84510. * Update a specific vertex buffer
  84511. * This function will create a new buffer if the current one is not updatable
  84512. * @param kind defines the data kind (Position, normal, etc...)
  84513. * @param data defines the data to use
  84514. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84515. */
  84516. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  84517. private _updateBoundingInfo;
  84518. /** @hidden */
  84519. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  84520. /**
  84521. * Gets total number of vertices
  84522. * @returns the total number of vertices
  84523. */
  84524. getTotalVertices(): number;
  84525. /**
  84526. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84527. * @param kind defines the data kind (Position, normal, etc...)
  84528. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84529. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84530. * @returns a float array containing vertex data
  84531. */
  84532. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84533. /**
  84534. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84535. * @param kind defines the data kind (Position, normal, etc...)
  84536. * @returns true if the vertex buffer with the specified kind is updatable
  84537. */
  84538. isVertexBufferUpdatable(kind: string): boolean;
  84539. /**
  84540. * Gets a specific vertex buffer
  84541. * @param kind defines the data kind (Position, normal, etc...)
  84542. * @returns a VertexBuffer
  84543. */
  84544. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  84545. /**
  84546. * Returns all vertex buffers
  84547. * @return an object holding all vertex buffers indexed by kind
  84548. */
  84549. getVertexBuffers(): Nullable<{
  84550. [key: string]: VertexBuffer;
  84551. }>;
  84552. /**
  84553. * Gets a boolean indicating if specific vertex buffer is present
  84554. * @param kind defines the data kind (Position, normal, etc...)
  84555. * @returns true if data is present
  84556. */
  84557. isVerticesDataPresent(kind: string): boolean;
  84558. /**
  84559. * Gets a list of all attached data kinds (Position, normal, etc...)
  84560. * @returns a list of string containing all kinds
  84561. */
  84562. getVerticesDataKinds(): string[];
  84563. /**
  84564. * Update index buffer
  84565. * @param indices defines the indices to store in the index buffer
  84566. * @param offset defines the offset in the target buffer where to store the data
  84567. * @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)
  84568. */
  84569. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  84570. /**
  84571. * Creates a new index buffer
  84572. * @param indices defines the indices to store in the index buffer
  84573. * @param totalVertices defines the total number of vertices (could be null)
  84574. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84575. */
  84576. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  84577. /**
  84578. * Return the total number of indices
  84579. * @returns the total number of indices
  84580. */
  84581. getTotalIndices(): number;
  84582. /**
  84583. * Gets the index buffer array
  84584. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84586. * @returns the index buffer array
  84587. */
  84588. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84589. /**
  84590. * Gets the index buffer
  84591. * @return the index buffer
  84592. */
  84593. getIndexBuffer(): Nullable<DataBuffer>;
  84594. /** @hidden */
  84595. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  84596. /**
  84597. * Release the associated resources for a specific mesh
  84598. * @param mesh defines the source mesh
  84599. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84600. */
  84601. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  84602. /**
  84603. * Apply current geometry to a given mesh
  84604. * @param mesh defines the mesh to apply geometry to
  84605. */
  84606. applyToMesh(mesh: Mesh): void;
  84607. private _updateExtend;
  84608. private _applyToMesh;
  84609. private notifyUpdate;
  84610. /**
  84611. * Load the geometry if it was flagged as delay loaded
  84612. * @param scene defines the hosting scene
  84613. * @param onLoaded defines a callback called when the geometry is loaded
  84614. */
  84615. load(scene: Scene, onLoaded?: () => void): void;
  84616. private _queueLoad;
  84617. /**
  84618. * Invert the geometry to move from a right handed system to a left handed one.
  84619. */
  84620. toLeftHanded(): void;
  84621. /** @hidden */
  84622. _resetPointsArrayCache(): void;
  84623. /** @hidden */
  84624. _generatePointsArray(): boolean;
  84625. /**
  84626. * Gets a value indicating if the geometry is disposed
  84627. * @returns true if the geometry was disposed
  84628. */
  84629. isDisposed(): boolean;
  84630. private _disposeVertexArrayObjects;
  84631. /**
  84632. * Free all associated resources
  84633. */
  84634. dispose(): void;
  84635. /**
  84636. * Clone the current geometry into a new geometry
  84637. * @param id defines the unique ID of the new geometry
  84638. * @returns a new geometry object
  84639. */
  84640. copy(id: string): Geometry;
  84641. /**
  84642. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84643. * @return a JSON representation of the current geometry data (without the vertices data)
  84644. */
  84645. serialize(): any;
  84646. private toNumberArray;
  84647. /**
  84648. * Serialize all vertices data into a JSON oject
  84649. * @returns a JSON representation of the current geometry data
  84650. */
  84651. serializeVerticeData(): any;
  84652. /**
  84653. * Extracts a clone of a mesh geometry
  84654. * @param mesh defines the source mesh
  84655. * @param id defines the unique ID of the new geometry object
  84656. * @returns the new geometry object
  84657. */
  84658. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  84659. /**
  84660. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84661. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84662. * Be aware Math.random() could cause collisions, but:
  84663. * "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"
  84664. * @returns a string containing a new GUID
  84665. */
  84666. static RandomId(): string;
  84667. /** @hidden */
  84668. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  84669. private static _CleanMatricesWeights;
  84670. /**
  84671. * Create a new geometry from persisted data (Using .babylon file format)
  84672. * @param parsedVertexData defines the persisted data
  84673. * @param scene defines the hosting scene
  84674. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84675. * @returns the new geometry object
  84676. */
  84677. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  84678. }
  84679. }
  84680. declare module BABYLON {
  84681. /**
  84682. * Define an interface for all classes that will get and set the data on vertices
  84683. */
  84684. export interface IGetSetVerticesData {
  84685. /**
  84686. * Gets a boolean indicating if specific vertex data is present
  84687. * @param kind defines the vertex data kind to use
  84688. * @returns true is data kind is present
  84689. */
  84690. isVerticesDataPresent(kind: string): boolean;
  84691. /**
  84692. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84693. * @param kind defines the data kind (Position, normal, etc...)
  84694. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84695. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84696. * @returns a float array containing vertex data
  84697. */
  84698. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84699. /**
  84700. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84701. * @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.
  84702. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84703. * @returns the indices array or an empty array if the mesh has no geometry
  84704. */
  84705. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84706. /**
  84707. * Set specific vertex data
  84708. * @param kind defines the data kind (Position, normal, etc...)
  84709. * @param data defines the vertex data to use
  84710. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84711. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84712. */
  84713. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  84714. /**
  84715. * Update a specific associated vertex buffer
  84716. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84717. * - VertexBuffer.PositionKind
  84718. * - VertexBuffer.UVKind
  84719. * - VertexBuffer.UV2Kind
  84720. * - VertexBuffer.UV3Kind
  84721. * - VertexBuffer.UV4Kind
  84722. * - VertexBuffer.UV5Kind
  84723. * - VertexBuffer.UV6Kind
  84724. * - VertexBuffer.ColorKind
  84725. * - VertexBuffer.MatricesIndicesKind
  84726. * - VertexBuffer.MatricesIndicesExtraKind
  84727. * - VertexBuffer.MatricesWeightsKind
  84728. * - VertexBuffer.MatricesWeightsExtraKind
  84729. * @param data defines the data source
  84730. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84731. * @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)
  84732. */
  84733. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  84734. /**
  84735. * Creates a new index buffer
  84736. * @param indices defines the indices to store in the index buffer
  84737. * @param totalVertices defines the total number of vertices (could be null)
  84738. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84739. */
  84740. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  84741. }
  84742. /**
  84743. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  84744. */
  84745. export class VertexData {
  84746. /**
  84747. * Mesh side orientation : usually the external or front surface
  84748. */
  84749. static readonly FRONTSIDE: number;
  84750. /**
  84751. * Mesh side orientation : usually the internal or back surface
  84752. */
  84753. static readonly BACKSIDE: number;
  84754. /**
  84755. * Mesh side orientation : both internal and external or front and back surfaces
  84756. */
  84757. static readonly DOUBLESIDE: number;
  84758. /**
  84759. * Mesh side orientation : by default, `FRONTSIDE`
  84760. */
  84761. static readonly DEFAULTSIDE: number;
  84762. /**
  84763. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  84764. */
  84765. positions: Nullable<FloatArray>;
  84766. /**
  84767. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  84768. */
  84769. normals: Nullable<FloatArray>;
  84770. /**
  84771. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  84772. */
  84773. tangents: Nullable<FloatArray>;
  84774. /**
  84775. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84776. */
  84777. uvs: Nullable<FloatArray>;
  84778. /**
  84779. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84780. */
  84781. uvs2: Nullable<FloatArray>;
  84782. /**
  84783. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84784. */
  84785. uvs3: Nullable<FloatArray>;
  84786. /**
  84787. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84788. */
  84789. uvs4: Nullable<FloatArray>;
  84790. /**
  84791. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84792. */
  84793. uvs5: Nullable<FloatArray>;
  84794. /**
  84795. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84796. */
  84797. uvs6: Nullable<FloatArray>;
  84798. /**
  84799. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  84800. */
  84801. colors: Nullable<FloatArray>;
  84802. /**
  84803. * 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).
  84804. */
  84805. matricesIndices: Nullable<FloatArray>;
  84806. /**
  84807. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  84808. */
  84809. matricesWeights: Nullable<FloatArray>;
  84810. /**
  84811. * An array extending the number of possible indices
  84812. */
  84813. matricesIndicesExtra: Nullable<FloatArray>;
  84814. /**
  84815. * An array extending the number of possible weights when the number of indices is extended
  84816. */
  84817. matricesWeightsExtra: Nullable<FloatArray>;
  84818. /**
  84819. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  84820. */
  84821. indices: Nullable<IndicesArray>;
  84822. /**
  84823. * Uses the passed data array to set the set the values for the specified kind of data
  84824. * @param data a linear array of floating numbers
  84825. * @param kind the type of data that is being set, eg positions, colors etc
  84826. */
  84827. set(data: FloatArray, kind: string): void;
  84828. /**
  84829. * Associates the vertexData to the passed Mesh.
  84830. * Sets it as updatable or not (default `false`)
  84831. * @param mesh the mesh the vertexData is applied to
  84832. * @param updatable when used and having the value true allows new data to update the vertexData
  84833. * @returns the VertexData
  84834. */
  84835. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  84836. /**
  84837. * Associates the vertexData to the passed Geometry.
  84838. * Sets it as updatable or not (default `false`)
  84839. * @param geometry the geometry the vertexData is applied to
  84840. * @param updatable when used and having the value true allows new data to update the vertexData
  84841. * @returns VertexData
  84842. */
  84843. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  84844. /**
  84845. * Updates the associated mesh
  84846. * @param mesh the mesh to be updated
  84847. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  84848. * @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
  84849. * @returns VertexData
  84850. */
  84851. updateMesh(mesh: Mesh): VertexData;
  84852. /**
  84853. * Updates the associated geometry
  84854. * @param geometry the geometry to be updated
  84855. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  84856. * @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
  84857. * @returns VertexData.
  84858. */
  84859. updateGeometry(geometry: Geometry): VertexData;
  84860. private _applyTo;
  84861. private _update;
  84862. /**
  84863. * Transforms each position and each normal of the vertexData according to the passed Matrix
  84864. * @param matrix the transforming matrix
  84865. * @returns the VertexData
  84866. */
  84867. transform(matrix: Matrix): VertexData;
  84868. /**
  84869. * Merges the passed VertexData into the current one
  84870. * @param other the VertexData to be merged into the current one
  84871. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  84872. * @returns the modified VertexData
  84873. */
  84874. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  84875. private _mergeElement;
  84876. private _validate;
  84877. /**
  84878. * Serializes the VertexData
  84879. * @returns a serialized object
  84880. */
  84881. serialize(): any;
  84882. /**
  84883. * Extracts the vertexData from a mesh
  84884. * @param mesh the mesh from which to extract the VertexData
  84885. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  84886. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  84887. * @returns the object VertexData associated to the passed mesh
  84888. */
  84889. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  84890. /**
  84891. * Extracts the vertexData from the geometry
  84892. * @param geometry the geometry from which to extract the VertexData
  84893. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  84894. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  84895. * @returns the object VertexData associated to the passed mesh
  84896. */
  84897. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  84898. private static _ExtractFrom;
  84899. /**
  84900. * Creates the VertexData for a Ribbon
  84901. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  84902. * * pathArray array of paths, each of which an array of successive Vector3
  84903. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  84904. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  84905. * * 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
  84906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84907. * * 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)
  84908. * * 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)
  84909. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  84910. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  84911. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  84912. * @returns the VertexData of the ribbon
  84913. */
  84914. static CreateRibbon(options: {
  84915. pathArray: Vector3[][];
  84916. closeArray?: boolean;
  84917. closePath?: boolean;
  84918. offset?: number;
  84919. sideOrientation?: number;
  84920. frontUVs?: Vector4;
  84921. backUVs?: Vector4;
  84922. invertUV?: boolean;
  84923. uvs?: Vector2[];
  84924. colors?: Color4[];
  84925. }): VertexData;
  84926. /**
  84927. * Creates the VertexData for a box
  84928. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84929. * * size sets the width, height and depth of the box to the value of size, optional default 1
  84930. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  84931. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  84932. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  84933. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  84934. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  84935. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84936. * * 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)
  84937. * * 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)
  84938. * @returns the VertexData of the box
  84939. */
  84940. static CreateBox(options: {
  84941. size?: number;
  84942. width?: number;
  84943. height?: number;
  84944. depth?: number;
  84945. faceUV?: Vector4[];
  84946. faceColors?: Color4[];
  84947. sideOrientation?: number;
  84948. frontUVs?: Vector4;
  84949. backUVs?: Vector4;
  84950. }): VertexData;
  84951. /**
  84952. * Creates the VertexData for a tiled box
  84953. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84954. * * faceTiles sets the pattern, tile size and number of tiles for a face
  84955. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  84956. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  84957. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84958. * @returns the VertexData of the box
  84959. */
  84960. static CreateTiledBox(options: {
  84961. pattern?: number;
  84962. width?: number;
  84963. height?: number;
  84964. depth?: number;
  84965. tileSize?: number;
  84966. tileWidth?: number;
  84967. tileHeight?: number;
  84968. alignHorizontal?: number;
  84969. alignVertical?: number;
  84970. faceUV?: Vector4[];
  84971. faceColors?: Color4[];
  84972. sideOrientation?: number;
  84973. }): VertexData;
  84974. /**
  84975. * Creates the VertexData for a tiled plane
  84976. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84977. * * pattern a limited pattern arrangement depending on the number
  84978. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  84979. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  84980. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  84981. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84982. * * 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)
  84983. * * 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)
  84984. * @returns the VertexData of the tiled plane
  84985. */
  84986. static CreateTiledPlane(options: {
  84987. pattern?: number;
  84988. tileSize?: number;
  84989. tileWidth?: number;
  84990. tileHeight?: number;
  84991. size?: number;
  84992. width?: number;
  84993. height?: number;
  84994. alignHorizontal?: number;
  84995. alignVertical?: number;
  84996. sideOrientation?: number;
  84997. frontUVs?: Vector4;
  84998. backUVs?: Vector4;
  84999. }): VertexData;
  85000. /**
  85001. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85002. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85003. * * segments sets the number of horizontal strips optional, default 32
  85004. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85005. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85006. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85007. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85008. * * 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
  85009. * * 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
  85010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85011. * * 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)
  85012. * * 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)
  85013. * @returns the VertexData of the ellipsoid
  85014. */
  85015. static CreateSphere(options: {
  85016. segments?: number;
  85017. diameter?: number;
  85018. diameterX?: number;
  85019. diameterY?: number;
  85020. diameterZ?: number;
  85021. arc?: number;
  85022. slice?: number;
  85023. sideOrientation?: number;
  85024. frontUVs?: Vector4;
  85025. backUVs?: Vector4;
  85026. }): VertexData;
  85027. /**
  85028. * Creates the VertexData for a cylinder, cone or prism
  85029. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85030. * * height sets the height (y direction) of the cylinder, optional, default 2
  85031. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85032. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85033. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85034. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85035. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85036. * * 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
  85037. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85038. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85039. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85040. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85041. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85042. * * 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)
  85043. * * 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)
  85044. * @returns the VertexData of the cylinder, cone or prism
  85045. */
  85046. static CreateCylinder(options: {
  85047. height?: number;
  85048. diameterTop?: number;
  85049. diameterBottom?: number;
  85050. diameter?: number;
  85051. tessellation?: number;
  85052. subdivisions?: number;
  85053. arc?: number;
  85054. faceColors?: Color4[];
  85055. faceUV?: Vector4[];
  85056. hasRings?: boolean;
  85057. enclose?: boolean;
  85058. sideOrientation?: number;
  85059. frontUVs?: Vector4;
  85060. backUVs?: Vector4;
  85061. }): VertexData;
  85062. /**
  85063. * Creates the VertexData for a torus
  85064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85065. * * diameter the diameter of the torus, optional default 1
  85066. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85067. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85068. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85069. * * 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)
  85070. * * 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)
  85071. * @returns the VertexData of the torus
  85072. */
  85073. static CreateTorus(options: {
  85074. diameter?: number;
  85075. thickness?: number;
  85076. tessellation?: number;
  85077. sideOrientation?: number;
  85078. frontUVs?: Vector4;
  85079. backUVs?: Vector4;
  85080. }): VertexData;
  85081. /**
  85082. * Creates the VertexData of the LineSystem
  85083. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85084. * - lines an array of lines, each line being an array of successive Vector3
  85085. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85086. * @returns the VertexData of the LineSystem
  85087. */
  85088. static CreateLineSystem(options: {
  85089. lines: Vector3[][];
  85090. colors?: Nullable<Color4[][]>;
  85091. }): VertexData;
  85092. /**
  85093. * Create the VertexData for a DashedLines
  85094. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85095. * - points an array successive Vector3
  85096. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85097. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85098. * - dashNb the intended total number of dashes, optional, default 200
  85099. * @returns the VertexData for the DashedLines
  85100. */
  85101. static CreateDashedLines(options: {
  85102. points: Vector3[];
  85103. dashSize?: number;
  85104. gapSize?: number;
  85105. dashNb?: number;
  85106. }): VertexData;
  85107. /**
  85108. * Creates the VertexData for a Ground
  85109. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85110. * - width the width (x direction) of the ground, optional, default 1
  85111. * - height the height (z direction) of the ground, optional, default 1
  85112. * - subdivisions the number of subdivisions per side, optional, default 1
  85113. * @returns the VertexData of the Ground
  85114. */
  85115. static CreateGround(options: {
  85116. width?: number;
  85117. height?: number;
  85118. subdivisions?: number;
  85119. subdivisionsX?: number;
  85120. subdivisionsY?: number;
  85121. }): VertexData;
  85122. /**
  85123. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85124. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85125. * * xmin the ground minimum X coordinate, optional, default -1
  85126. * * zmin the ground minimum Z coordinate, optional, default -1
  85127. * * xmax the ground maximum X coordinate, optional, default 1
  85128. * * zmax the ground maximum Z coordinate, optional, default 1
  85129. * * 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}
  85130. * * 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}
  85131. * @returns the VertexData of the TiledGround
  85132. */
  85133. static CreateTiledGround(options: {
  85134. xmin: number;
  85135. zmin: number;
  85136. xmax: number;
  85137. zmax: number;
  85138. subdivisions?: {
  85139. w: number;
  85140. h: number;
  85141. };
  85142. precision?: {
  85143. w: number;
  85144. h: number;
  85145. };
  85146. }): VertexData;
  85147. /**
  85148. * Creates the VertexData of the Ground designed from a heightmap
  85149. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85150. * * width the width (x direction) of the ground
  85151. * * height the height (z direction) of the ground
  85152. * * subdivisions the number of subdivisions per side
  85153. * * minHeight the minimum altitude on the ground, optional, default 0
  85154. * * maxHeight the maximum altitude on the ground, optional default 1
  85155. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85156. * * buffer the array holding the image color data
  85157. * * bufferWidth the width of image
  85158. * * bufferHeight the height of image
  85159. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85160. * @returns the VertexData of the Ground designed from a heightmap
  85161. */
  85162. static CreateGroundFromHeightMap(options: {
  85163. width: number;
  85164. height: number;
  85165. subdivisions: number;
  85166. minHeight: number;
  85167. maxHeight: number;
  85168. colorFilter: Color3;
  85169. buffer: Uint8Array;
  85170. bufferWidth: number;
  85171. bufferHeight: number;
  85172. alphaFilter: number;
  85173. }): VertexData;
  85174. /**
  85175. * Creates the VertexData for a Plane
  85176. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85177. * * size sets the width and height of the plane to the value of size, optional default 1
  85178. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85179. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85181. * * 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)
  85182. * * 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)
  85183. * @returns the VertexData of the box
  85184. */
  85185. static CreatePlane(options: {
  85186. size?: number;
  85187. width?: number;
  85188. height?: number;
  85189. sideOrientation?: number;
  85190. frontUVs?: Vector4;
  85191. backUVs?: Vector4;
  85192. }): VertexData;
  85193. /**
  85194. * Creates the VertexData of the Disc or regular Polygon
  85195. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85196. * * radius the radius of the disc, optional default 0.5
  85197. * * tessellation the number of polygon sides, optional, default 64
  85198. * * 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
  85199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85200. * * 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)
  85201. * * 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)
  85202. * @returns the VertexData of the box
  85203. */
  85204. static CreateDisc(options: {
  85205. radius?: number;
  85206. tessellation?: number;
  85207. arc?: number;
  85208. sideOrientation?: number;
  85209. frontUVs?: Vector4;
  85210. backUVs?: Vector4;
  85211. }): VertexData;
  85212. /**
  85213. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85214. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85215. * @param polygon a mesh built from polygonTriangulation.build()
  85216. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85217. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85218. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85219. * @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)
  85220. * @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)
  85221. * @returns the VertexData of the Polygon
  85222. */
  85223. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85224. /**
  85225. * Creates the VertexData of the IcoSphere
  85226. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85227. * * radius the radius of the IcoSphere, optional default 1
  85228. * * radiusX allows stretching in the x direction, optional, default radius
  85229. * * radiusY allows stretching in the y direction, optional, default radius
  85230. * * radiusZ allows stretching in the z direction, optional, default radius
  85231. * * flat when true creates a flat shaded mesh, optional, default true
  85232. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85234. * * 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)
  85235. * * 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)
  85236. * @returns the VertexData of the IcoSphere
  85237. */
  85238. static CreateIcoSphere(options: {
  85239. radius?: number;
  85240. radiusX?: number;
  85241. radiusY?: number;
  85242. radiusZ?: number;
  85243. flat?: boolean;
  85244. subdivisions?: number;
  85245. sideOrientation?: number;
  85246. frontUVs?: Vector4;
  85247. backUVs?: Vector4;
  85248. }): VertexData;
  85249. /**
  85250. * Creates the VertexData for a Polyhedron
  85251. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85252. * * type provided types are:
  85253. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85254. * * 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)
  85255. * * size the size of the IcoSphere, optional default 1
  85256. * * sizeX allows stretching in the x direction, optional, default size
  85257. * * sizeY allows stretching in the y direction, optional, default size
  85258. * * sizeZ allows stretching in the z direction, optional, default size
  85259. * * 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
  85260. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85261. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85262. * * flat when true creates a flat shaded mesh, optional, default true
  85263. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85265. * * 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)
  85266. * * 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)
  85267. * @returns the VertexData of the Polyhedron
  85268. */
  85269. static CreatePolyhedron(options: {
  85270. type?: number;
  85271. size?: number;
  85272. sizeX?: number;
  85273. sizeY?: number;
  85274. sizeZ?: number;
  85275. custom?: any;
  85276. faceUV?: Vector4[];
  85277. faceColors?: Color4[];
  85278. flat?: boolean;
  85279. sideOrientation?: number;
  85280. frontUVs?: Vector4;
  85281. backUVs?: Vector4;
  85282. }): VertexData;
  85283. /**
  85284. * Creates the VertexData for a TorusKnot
  85285. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85286. * * radius the radius of the torus knot, optional, default 2
  85287. * * tube the thickness of the tube, optional, default 0.5
  85288. * * radialSegments the number of sides on each tube segments, optional, default 32
  85289. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85290. * * p the number of windings around the z axis, optional, default 2
  85291. * * q the number of windings around the x axis, optional, default 3
  85292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85293. * * 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)
  85294. * * 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)
  85295. * @returns the VertexData of the Torus Knot
  85296. */
  85297. static CreateTorusKnot(options: {
  85298. radius?: number;
  85299. tube?: number;
  85300. radialSegments?: number;
  85301. tubularSegments?: number;
  85302. p?: number;
  85303. q?: number;
  85304. sideOrientation?: number;
  85305. frontUVs?: Vector4;
  85306. backUVs?: Vector4;
  85307. }): VertexData;
  85308. /**
  85309. * Compute normals for given positions and indices
  85310. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85311. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85312. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85313. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85314. * * facetNormals : optional array of facet normals (vector3)
  85315. * * facetPositions : optional array of facet positions (vector3)
  85316. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85317. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85318. * * bInfo : optional bounding info, required for facetPartitioning computation
  85319. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85320. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85321. * * useRightHandedSystem: optional boolean to for right handed system computation
  85322. * * depthSort : optional boolean to enable the facet depth sort computation
  85323. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85324. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85325. */
  85326. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85327. facetNormals?: any;
  85328. facetPositions?: any;
  85329. facetPartitioning?: any;
  85330. ratio?: number;
  85331. bInfo?: any;
  85332. bbSize?: Vector3;
  85333. subDiv?: any;
  85334. useRightHandedSystem?: boolean;
  85335. depthSort?: boolean;
  85336. distanceTo?: Vector3;
  85337. depthSortedFacets?: any;
  85338. }): void;
  85339. /** @hidden */
  85340. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85341. /**
  85342. * Applies VertexData created from the imported parameters to the geometry
  85343. * @param parsedVertexData the parsed data from an imported file
  85344. * @param geometry the geometry to apply the VertexData to
  85345. */
  85346. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85347. }
  85348. }
  85349. declare module BABYLON {
  85350. /**
  85351. * Defines a target to use with MorphTargetManager
  85352. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85353. */
  85354. export class MorphTarget implements IAnimatable {
  85355. /** defines the name of the target */
  85356. name: string;
  85357. /**
  85358. * Gets or sets the list of animations
  85359. */
  85360. animations: Animation[];
  85361. private _scene;
  85362. private _positions;
  85363. private _normals;
  85364. private _tangents;
  85365. private _uvs;
  85366. private _influence;
  85367. /**
  85368. * Observable raised when the influence changes
  85369. */
  85370. onInfluenceChanged: Observable<boolean>;
  85371. /** @hidden */
  85372. _onDataLayoutChanged: Observable<void>;
  85373. /**
  85374. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  85375. */
  85376. influence: number;
  85377. /**
  85378. * Gets or sets the id of the morph Target
  85379. */
  85380. id: string;
  85381. private _animationPropertiesOverride;
  85382. /**
  85383. * Gets or sets the animation properties override
  85384. */
  85385. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85386. /**
  85387. * Creates a new MorphTarget
  85388. * @param name defines the name of the target
  85389. * @param influence defines the influence to use
  85390. * @param scene defines the scene the morphtarget belongs to
  85391. */
  85392. constructor(
  85393. /** defines the name of the target */
  85394. name: string, influence?: number, scene?: Nullable<Scene>);
  85395. /**
  85396. * Gets a boolean defining if the target contains position data
  85397. */
  85398. readonly hasPositions: boolean;
  85399. /**
  85400. * Gets a boolean defining if the target contains normal data
  85401. */
  85402. readonly hasNormals: boolean;
  85403. /**
  85404. * Gets a boolean defining if the target contains tangent data
  85405. */
  85406. readonly hasTangents: boolean;
  85407. /**
  85408. * Gets a boolean defining if the target contains texture coordinates data
  85409. */
  85410. readonly hasUVs: boolean;
  85411. /**
  85412. * Affects position data to this target
  85413. * @param data defines the position data to use
  85414. */
  85415. setPositions(data: Nullable<FloatArray>): void;
  85416. /**
  85417. * Gets the position data stored in this target
  85418. * @returns a FloatArray containing the position data (or null if not present)
  85419. */
  85420. getPositions(): Nullable<FloatArray>;
  85421. /**
  85422. * Affects normal data to this target
  85423. * @param data defines the normal data to use
  85424. */
  85425. setNormals(data: Nullable<FloatArray>): void;
  85426. /**
  85427. * Gets the normal data stored in this target
  85428. * @returns a FloatArray containing the normal data (or null if not present)
  85429. */
  85430. getNormals(): Nullable<FloatArray>;
  85431. /**
  85432. * Affects tangent data to this target
  85433. * @param data defines the tangent data to use
  85434. */
  85435. setTangents(data: Nullable<FloatArray>): void;
  85436. /**
  85437. * Gets the tangent data stored in this target
  85438. * @returns a FloatArray containing the tangent data (or null if not present)
  85439. */
  85440. getTangents(): Nullable<FloatArray>;
  85441. /**
  85442. * Affects texture coordinates data to this target
  85443. * @param data defines the texture coordinates data to use
  85444. */
  85445. setUVs(data: Nullable<FloatArray>): void;
  85446. /**
  85447. * Gets the texture coordinates data stored in this target
  85448. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  85449. */
  85450. getUVs(): Nullable<FloatArray>;
  85451. /**
  85452. * Serializes the current target into a Serialization object
  85453. * @returns the serialized object
  85454. */
  85455. serialize(): any;
  85456. /**
  85457. * Returns the string "MorphTarget"
  85458. * @returns "MorphTarget"
  85459. */
  85460. getClassName(): string;
  85461. /**
  85462. * Creates a new target from serialized data
  85463. * @param serializationObject defines the serialized data to use
  85464. * @returns a new MorphTarget
  85465. */
  85466. static Parse(serializationObject: any): MorphTarget;
  85467. /**
  85468. * Creates a MorphTarget from mesh data
  85469. * @param mesh defines the source mesh
  85470. * @param name defines the name to use for the new target
  85471. * @param influence defines the influence to attach to the target
  85472. * @returns a new MorphTarget
  85473. */
  85474. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  85475. }
  85476. }
  85477. declare module BABYLON {
  85478. /**
  85479. * This class is used to deform meshes using morphing between different targets
  85480. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85481. */
  85482. export class MorphTargetManager {
  85483. private _targets;
  85484. private _targetInfluenceChangedObservers;
  85485. private _targetDataLayoutChangedObservers;
  85486. private _activeTargets;
  85487. private _scene;
  85488. private _influences;
  85489. private _supportsNormals;
  85490. private _supportsTangents;
  85491. private _supportsUVs;
  85492. private _vertexCount;
  85493. private _uniqueId;
  85494. private _tempInfluences;
  85495. /**
  85496. * Gets or sets a boolean indicating if normals must be morphed
  85497. */
  85498. enableNormalMorphing: boolean;
  85499. /**
  85500. * Gets or sets a boolean indicating if tangents must be morphed
  85501. */
  85502. enableTangentMorphing: boolean;
  85503. /**
  85504. * Gets or sets a boolean indicating if UV must be morphed
  85505. */
  85506. enableUVMorphing: boolean;
  85507. /**
  85508. * Creates a new MorphTargetManager
  85509. * @param scene defines the current scene
  85510. */
  85511. constructor(scene?: Nullable<Scene>);
  85512. /**
  85513. * Gets the unique ID of this manager
  85514. */
  85515. readonly uniqueId: number;
  85516. /**
  85517. * Gets the number of vertices handled by this manager
  85518. */
  85519. readonly vertexCount: number;
  85520. /**
  85521. * Gets a boolean indicating if this manager supports morphing of normals
  85522. */
  85523. readonly supportsNormals: boolean;
  85524. /**
  85525. * Gets a boolean indicating if this manager supports morphing of tangents
  85526. */
  85527. readonly supportsTangents: boolean;
  85528. /**
  85529. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  85530. */
  85531. readonly supportsUVs: boolean;
  85532. /**
  85533. * Gets the number of targets stored in this manager
  85534. */
  85535. readonly numTargets: number;
  85536. /**
  85537. * Gets the number of influencers (ie. the number of targets with influences > 0)
  85538. */
  85539. readonly numInfluencers: number;
  85540. /**
  85541. * Gets the list of influences (one per target)
  85542. */
  85543. readonly influences: Float32Array;
  85544. /**
  85545. * Gets the active target at specified index. An active target is a target with an influence > 0
  85546. * @param index defines the index to check
  85547. * @returns the requested target
  85548. */
  85549. getActiveTarget(index: number): MorphTarget;
  85550. /**
  85551. * Gets the target at specified index
  85552. * @param index defines the index to check
  85553. * @returns the requested target
  85554. */
  85555. getTarget(index: number): MorphTarget;
  85556. /**
  85557. * Add a new target to this manager
  85558. * @param target defines the target to add
  85559. */
  85560. addTarget(target: MorphTarget): void;
  85561. /**
  85562. * Removes a target from the manager
  85563. * @param target defines the target to remove
  85564. */
  85565. removeTarget(target: MorphTarget): void;
  85566. /**
  85567. * Serializes the current manager into a Serialization object
  85568. * @returns the serialized object
  85569. */
  85570. serialize(): any;
  85571. private _syncActiveTargets;
  85572. /**
  85573. * Syncrhonize the targets with all the meshes using this morph target manager
  85574. */
  85575. synchronize(): void;
  85576. /**
  85577. * Creates a new MorphTargetManager from serialized data
  85578. * @param serializationObject defines the serialized data
  85579. * @param scene defines the hosting scene
  85580. * @returns the new MorphTargetManager
  85581. */
  85582. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  85583. }
  85584. }
  85585. declare module BABYLON {
  85586. /**
  85587. * Class used to represent a specific level of detail of a mesh
  85588. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85589. */
  85590. export class MeshLODLevel {
  85591. /** Defines the distance where this level should star being displayed */
  85592. distance: number;
  85593. /** Defines the mesh to use to render this level */
  85594. mesh: Nullable<Mesh>;
  85595. /**
  85596. * Creates a new LOD level
  85597. * @param distance defines the distance where this level should star being displayed
  85598. * @param mesh defines the mesh to use to render this level
  85599. */
  85600. constructor(
  85601. /** Defines the distance where this level should star being displayed */
  85602. distance: number,
  85603. /** Defines the mesh to use to render this level */
  85604. mesh: Nullable<Mesh>);
  85605. }
  85606. }
  85607. declare module BABYLON {
  85608. /**
  85609. * Mesh representing the gorund
  85610. */
  85611. export class GroundMesh extends Mesh {
  85612. /** If octree should be generated */
  85613. generateOctree: boolean;
  85614. private _heightQuads;
  85615. /** @hidden */
  85616. _subdivisionsX: number;
  85617. /** @hidden */
  85618. _subdivisionsY: number;
  85619. /** @hidden */
  85620. _width: number;
  85621. /** @hidden */
  85622. _height: number;
  85623. /** @hidden */
  85624. _minX: number;
  85625. /** @hidden */
  85626. _maxX: number;
  85627. /** @hidden */
  85628. _minZ: number;
  85629. /** @hidden */
  85630. _maxZ: number;
  85631. constructor(name: string, scene: Scene);
  85632. /**
  85633. * "GroundMesh"
  85634. * @returns "GroundMesh"
  85635. */
  85636. getClassName(): string;
  85637. /**
  85638. * The minimum of x and y subdivisions
  85639. */
  85640. readonly subdivisions: number;
  85641. /**
  85642. * X subdivisions
  85643. */
  85644. readonly subdivisionsX: number;
  85645. /**
  85646. * Y subdivisions
  85647. */
  85648. readonly subdivisionsY: number;
  85649. /**
  85650. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  85651. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  85652. * @param chunksCount the number of subdivisions for x and y
  85653. * @param octreeBlocksSize (Default: 32)
  85654. */
  85655. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  85656. /**
  85657. * Returns a height (y) value in the Worl system :
  85658. * the ground altitude at the coordinates (x, z) expressed in the World system.
  85659. * @param x x coordinate
  85660. * @param z z coordinate
  85661. * @returns the ground y position if (x, z) are outside the ground surface.
  85662. */
  85663. getHeightAtCoordinates(x: number, z: number): number;
  85664. /**
  85665. * Returns a normalized vector (Vector3) orthogonal to the ground
  85666. * at the ground coordinates (x, z) expressed in the World system.
  85667. * @param x x coordinate
  85668. * @param z z coordinate
  85669. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  85670. */
  85671. getNormalAtCoordinates(x: number, z: number): Vector3;
  85672. /**
  85673. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  85674. * at the ground coordinates (x, z) expressed in the World system.
  85675. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  85676. * @param x x coordinate
  85677. * @param z z coordinate
  85678. * @param ref vector to store the result
  85679. * @returns the GroundMesh.
  85680. */
  85681. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  85682. /**
  85683. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  85684. * if the ground has been updated.
  85685. * This can be used in the render loop.
  85686. * @returns the GroundMesh.
  85687. */
  85688. updateCoordinateHeights(): GroundMesh;
  85689. private _getFacetAt;
  85690. private _initHeightQuads;
  85691. private _computeHeightQuads;
  85692. /**
  85693. * Serializes this ground mesh
  85694. * @param serializationObject object to write serialization to
  85695. */
  85696. serialize(serializationObject: any): void;
  85697. /**
  85698. * Parses a serialized ground mesh
  85699. * @param parsedMesh the serialized mesh
  85700. * @param scene the scene to create the ground mesh in
  85701. * @returns the created ground mesh
  85702. */
  85703. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  85704. }
  85705. }
  85706. declare module BABYLON {
  85707. /**
  85708. * Interface for Physics-Joint data
  85709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85710. */
  85711. export interface PhysicsJointData {
  85712. /**
  85713. * The main pivot of the joint
  85714. */
  85715. mainPivot?: Vector3;
  85716. /**
  85717. * The connected pivot of the joint
  85718. */
  85719. connectedPivot?: Vector3;
  85720. /**
  85721. * The main axis of the joint
  85722. */
  85723. mainAxis?: Vector3;
  85724. /**
  85725. * The connected axis of the joint
  85726. */
  85727. connectedAxis?: Vector3;
  85728. /**
  85729. * The collision of the joint
  85730. */
  85731. collision?: boolean;
  85732. /**
  85733. * Native Oimo/Cannon/Energy data
  85734. */
  85735. nativeParams?: any;
  85736. }
  85737. /**
  85738. * This is a holder class for the physics joint created by the physics plugin
  85739. * It holds a set of functions to control the underlying joint
  85740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85741. */
  85742. export class PhysicsJoint {
  85743. /**
  85744. * The type of the physics joint
  85745. */
  85746. type: number;
  85747. /**
  85748. * The data for the physics joint
  85749. */
  85750. jointData: PhysicsJointData;
  85751. private _physicsJoint;
  85752. protected _physicsPlugin: IPhysicsEnginePlugin;
  85753. /**
  85754. * Initializes the physics joint
  85755. * @param type The type of the physics joint
  85756. * @param jointData The data for the physics joint
  85757. */
  85758. constructor(
  85759. /**
  85760. * The type of the physics joint
  85761. */
  85762. type: number,
  85763. /**
  85764. * The data for the physics joint
  85765. */
  85766. jointData: PhysicsJointData);
  85767. /**
  85768. * Gets the physics joint
  85769. */
  85770. /**
  85771. * Sets the physics joint
  85772. */
  85773. physicsJoint: any;
  85774. /**
  85775. * Sets the physics plugin
  85776. */
  85777. physicsPlugin: IPhysicsEnginePlugin;
  85778. /**
  85779. * Execute a function that is physics-plugin specific.
  85780. * @param {Function} func the function that will be executed.
  85781. * It accepts two parameters: the physics world and the physics joint
  85782. */
  85783. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  85784. /**
  85785. * Distance-Joint type
  85786. */
  85787. static DistanceJoint: number;
  85788. /**
  85789. * Hinge-Joint type
  85790. */
  85791. static HingeJoint: number;
  85792. /**
  85793. * Ball-and-Socket joint type
  85794. */
  85795. static BallAndSocketJoint: number;
  85796. /**
  85797. * Wheel-Joint type
  85798. */
  85799. static WheelJoint: number;
  85800. /**
  85801. * Slider-Joint type
  85802. */
  85803. static SliderJoint: number;
  85804. /**
  85805. * Prismatic-Joint type
  85806. */
  85807. static PrismaticJoint: number;
  85808. /**
  85809. * Universal-Joint type
  85810. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  85811. */
  85812. static UniversalJoint: number;
  85813. /**
  85814. * Hinge-Joint 2 type
  85815. */
  85816. static Hinge2Joint: number;
  85817. /**
  85818. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  85819. */
  85820. static PointToPointJoint: number;
  85821. /**
  85822. * Spring-Joint type
  85823. */
  85824. static SpringJoint: number;
  85825. /**
  85826. * Lock-Joint type
  85827. */
  85828. static LockJoint: number;
  85829. }
  85830. /**
  85831. * A class representing a physics distance joint
  85832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85833. */
  85834. export class DistanceJoint extends PhysicsJoint {
  85835. /**
  85836. *
  85837. * @param jointData The data for the Distance-Joint
  85838. */
  85839. constructor(jointData: DistanceJointData);
  85840. /**
  85841. * Update the predefined distance.
  85842. * @param maxDistance The maximum preferred distance
  85843. * @param minDistance The minimum preferred distance
  85844. */
  85845. updateDistance(maxDistance: number, minDistance?: number): void;
  85846. }
  85847. /**
  85848. * Represents a Motor-Enabled Joint
  85849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85850. */
  85851. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  85852. /**
  85853. * Initializes the Motor-Enabled Joint
  85854. * @param type The type of the joint
  85855. * @param jointData The physica joint data for the joint
  85856. */
  85857. constructor(type: number, jointData: PhysicsJointData);
  85858. /**
  85859. * Set the motor values.
  85860. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85861. * @param force the force to apply
  85862. * @param maxForce max force for this motor.
  85863. */
  85864. setMotor(force?: number, maxForce?: number): void;
  85865. /**
  85866. * Set the motor's limits.
  85867. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85868. * @param upperLimit The upper limit of the motor
  85869. * @param lowerLimit The lower limit of the motor
  85870. */
  85871. setLimit(upperLimit: number, lowerLimit?: number): void;
  85872. }
  85873. /**
  85874. * This class represents a single physics Hinge-Joint
  85875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85876. */
  85877. export class HingeJoint extends MotorEnabledJoint {
  85878. /**
  85879. * Initializes the Hinge-Joint
  85880. * @param jointData The joint data for the Hinge-Joint
  85881. */
  85882. constructor(jointData: PhysicsJointData);
  85883. /**
  85884. * Set the motor values.
  85885. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85886. * @param {number} force the force to apply
  85887. * @param {number} maxForce max force for this motor.
  85888. */
  85889. setMotor(force?: number, maxForce?: number): void;
  85890. /**
  85891. * Set the motor's limits.
  85892. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85893. * @param upperLimit The upper limit of the motor
  85894. * @param lowerLimit The lower limit of the motor
  85895. */
  85896. setLimit(upperLimit: number, lowerLimit?: number): void;
  85897. }
  85898. /**
  85899. * This class represents a dual hinge physics joint (same as wheel joint)
  85900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85901. */
  85902. export class Hinge2Joint extends MotorEnabledJoint {
  85903. /**
  85904. * Initializes the Hinge2-Joint
  85905. * @param jointData The joint data for the Hinge2-Joint
  85906. */
  85907. constructor(jointData: PhysicsJointData);
  85908. /**
  85909. * Set the motor values.
  85910. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85911. * @param {number} targetSpeed the speed the motor is to reach
  85912. * @param {number} maxForce max force for this motor.
  85913. * @param {motorIndex} the motor's index, 0 or 1.
  85914. */
  85915. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  85916. /**
  85917. * Set the motor limits.
  85918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85919. * @param {number} upperLimit the upper limit
  85920. * @param {number} lowerLimit lower limit
  85921. * @param {motorIndex} the motor's index, 0 or 1.
  85922. */
  85923. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  85924. }
  85925. /**
  85926. * Interface for a motor enabled joint
  85927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85928. */
  85929. export interface IMotorEnabledJoint {
  85930. /**
  85931. * Physics joint
  85932. */
  85933. physicsJoint: any;
  85934. /**
  85935. * Sets the motor of the motor-enabled joint
  85936. * @param force The force of the motor
  85937. * @param maxForce The maximum force of the motor
  85938. * @param motorIndex The index of the motor
  85939. */
  85940. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  85941. /**
  85942. * Sets the limit of the motor
  85943. * @param upperLimit The upper limit of the motor
  85944. * @param lowerLimit The lower limit of the motor
  85945. * @param motorIndex The index of the motor
  85946. */
  85947. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  85948. }
  85949. /**
  85950. * Joint data for a Distance-Joint
  85951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85952. */
  85953. export interface DistanceJointData extends PhysicsJointData {
  85954. /**
  85955. * Max distance the 2 joint objects can be apart
  85956. */
  85957. maxDistance: number;
  85958. }
  85959. /**
  85960. * Joint data from a spring joint
  85961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85962. */
  85963. export interface SpringJointData extends PhysicsJointData {
  85964. /**
  85965. * Length of the spring
  85966. */
  85967. length: number;
  85968. /**
  85969. * Stiffness of the spring
  85970. */
  85971. stiffness: number;
  85972. /**
  85973. * Damping of the spring
  85974. */
  85975. damping: number;
  85976. /** this callback will be called when applying the force to the impostors. */
  85977. forceApplicationCallback: () => void;
  85978. }
  85979. }
  85980. declare module BABYLON {
  85981. /**
  85982. * Holds the data for the raycast result
  85983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85984. */
  85985. export class PhysicsRaycastResult {
  85986. private _hasHit;
  85987. private _hitDistance;
  85988. private _hitNormalWorld;
  85989. private _hitPointWorld;
  85990. private _rayFromWorld;
  85991. private _rayToWorld;
  85992. /**
  85993. * Gets if there was a hit
  85994. */
  85995. readonly hasHit: boolean;
  85996. /**
  85997. * Gets the distance from the hit
  85998. */
  85999. readonly hitDistance: number;
  86000. /**
  86001. * Gets the hit normal/direction in the world
  86002. */
  86003. readonly hitNormalWorld: Vector3;
  86004. /**
  86005. * Gets the hit point in the world
  86006. */
  86007. readonly hitPointWorld: Vector3;
  86008. /**
  86009. * Gets the ray "start point" of the ray in the world
  86010. */
  86011. readonly rayFromWorld: Vector3;
  86012. /**
  86013. * Gets the ray "end point" of the ray in the world
  86014. */
  86015. readonly rayToWorld: Vector3;
  86016. /**
  86017. * Sets the hit data (normal & point in world space)
  86018. * @param hitNormalWorld defines the normal in world space
  86019. * @param hitPointWorld defines the point in world space
  86020. */
  86021. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86022. /**
  86023. * Sets the distance from the start point to the hit point
  86024. * @param distance
  86025. */
  86026. setHitDistance(distance: number): void;
  86027. /**
  86028. * Calculates the distance manually
  86029. */
  86030. calculateHitDistance(): void;
  86031. /**
  86032. * Resets all the values to default
  86033. * @param from The from point on world space
  86034. * @param to The to point on world space
  86035. */
  86036. reset(from?: Vector3, to?: Vector3): void;
  86037. }
  86038. /**
  86039. * Interface for the size containing width and height
  86040. */
  86041. interface IXYZ {
  86042. /**
  86043. * X
  86044. */
  86045. x: number;
  86046. /**
  86047. * Y
  86048. */
  86049. y: number;
  86050. /**
  86051. * Z
  86052. */
  86053. z: number;
  86054. }
  86055. }
  86056. declare module BABYLON {
  86057. /**
  86058. * Interface used to describe a physics joint
  86059. */
  86060. export interface PhysicsImpostorJoint {
  86061. /** Defines the main impostor to which the joint is linked */
  86062. mainImpostor: PhysicsImpostor;
  86063. /** Defines the impostor that is connected to the main impostor using this joint */
  86064. connectedImpostor: PhysicsImpostor;
  86065. /** Defines the joint itself */
  86066. joint: PhysicsJoint;
  86067. }
  86068. /** @hidden */
  86069. export interface IPhysicsEnginePlugin {
  86070. world: any;
  86071. name: string;
  86072. setGravity(gravity: Vector3): void;
  86073. setTimeStep(timeStep: number): void;
  86074. getTimeStep(): number;
  86075. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86076. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86077. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86078. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86079. removePhysicsBody(impostor: PhysicsImpostor): void;
  86080. generateJoint(joint: PhysicsImpostorJoint): void;
  86081. removeJoint(joint: PhysicsImpostorJoint): void;
  86082. isSupported(): boolean;
  86083. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  86084. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  86085. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86086. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86087. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86088. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86089. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  86090. getBodyMass(impostor: PhysicsImpostor): number;
  86091. getBodyFriction(impostor: PhysicsImpostor): number;
  86092. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  86093. getBodyRestitution(impostor: PhysicsImpostor): number;
  86094. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  86095. getBodyPressure?(impostor: PhysicsImpostor): number;
  86096. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  86097. getBodyStiffness?(impostor: PhysicsImpostor): number;
  86098. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  86099. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  86100. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  86101. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  86102. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  86103. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86104. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86105. sleepBody(impostor: PhysicsImpostor): void;
  86106. wakeUpBody(impostor: PhysicsImpostor): void;
  86107. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86108. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  86109. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  86110. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86111. getRadius(impostor: PhysicsImpostor): number;
  86112. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  86113. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  86114. dispose(): void;
  86115. }
  86116. /**
  86117. * Interface used to define a physics engine
  86118. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  86119. */
  86120. export interface IPhysicsEngine {
  86121. /**
  86122. * Gets the gravity vector used by the simulation
  86123. */
  86124. gravity: Vector3;
  86125. /**
  86126. * Sets the gravity vector used by the simulation
  86127. * @param gravity defines the gravity vector to use
  86128. */
  86129. setGravity(gravity: Vector3): void;
  86130. /**
  86131. * Set the time step of the physics engine.
  86132. * Default is 1/60.
  86133. * To slow it down, enter 1/600 for example.
  86134. * To speed it up, 1/30
  86135. * @param newTimeStep the new timestep to apply to this world.
  86136. */
  86137. setTimeStep(newTimeStep: number): void;
  86138. /**
  86139. * Get the time step of the physics engine.
  86140. * @returns the current time step
  86141. */
  86142. getTimeStep(): number;
  86143. /**
  86144. * Release all resources
  86145. */
  86146. dispose(): void;
  86147. /**
  86148. * Gets the name of the current physics plugin
  86149. * @returns the name of the plugin
  86150. */
  86151. getPhysicsPluginName(): string;
  86152. /**
  86153. * Adding a new impostor for the impostor tracking.
  86154. * This will be done by the impostor itself.
  86155. * @param impostor the impostor to add
  86156. */
  86157. addImpostor(impostor: PhysicsImpostor): void;
  86158. /**
  86159. * Remove an impostor from the engine.
  86160. * This impostor and its mesh will not longer be updated by the physics engine.
  86161. * @param impostor the impostor to remove
  86162. */
  86163. removeImpostor(impostor: PhysicsImpostor): void;
  86164. /**
  86165. * Add a joint to the physics engine
  86166. * @param mainImpostor defines the main impostor to which the joint is added.
  86167. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  86168. * @param joint defines the joint that will connect both impostors.
  86169. */
  86170. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86171. /**
  86172. * Removes a joint from the simulation
  86173. * @param mainImpostor defines the impostor used with the joint
  86174. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  86175. * @param joint defines the joint to remove
  86176. */
  86177. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86178. /**
  86179. * Gets the current plugin used to run the simulation
  86180. * @returns current plugin
  86181. */
  86182. getPhysicsPlugin(): IPhysicsEnginePlugin;
  86183. /**
  86184. * Gets the list of physic impostors
  86185. * @returns an array of PhysicsImpostor
  86186. */
  86187. getImpostors(): Array<PhysicsImpostor>;
  86188. /**
  86189. * Gets the impostor for a physics enabled object
  86190. * @param object defines the object impersonated by the impostor
  86191. * @returns the PhysicsImpostor or null if not found
  86192. */
  86193. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86194. /**
  86195. * Gets the impostor for a physics body object
  86196. * @param body defines physics body used by the impostor
  86197. * @returns the PhysicsImpostor or null if not found
  86198. */
  86199. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  86200. /**
  86201. * Does a raycast in the physics world
  86202. * @param from when should the ray start?
  86203. * @param to when should the ray end?
  86204. * @returns PhysicsRaycastResult
  86205. */
  86206. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86207. /**
  86208. * Called by the scene. No need to call it.
  86209. * @param delta defines the timespam between frames
  86210. */
  86211. _step(delta: number): void;
  86212. }
  86213. }
  86214. declare module BABYLON {
  86215. /**
  86216. * The interface for the physics imposter parameters
  86217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86218. */
  86219. export interface PhysicsImpostorParameters {
  86220. /**
  86221. * The mass of the physics imposter
  86222. */
  86223. mass: number;
  86224. /**
  86225. * The friction of the physics imposter
  86226. */
  86227. friction?: number;
  86228. /**
  86229. * The coefficient of restitution of the physics imposter
  86230. */
  86231. restitution?: number;
  86232. /**
  86233. * The native options of the physics imposter
  86234. */
  86235. nativeOptions?: any;
  86236. /**
  86237. * Specifies if the parent should be ignored
  86238. */
  86239. ignoreParent?: boolean;
  86240. /**
  86241. * Specifies if bi-directional transformations should be disabled
  86242. */
  86243. disableBidirectionalTransformation?: boolean;
  86244. /**
  86245. * The pressure inside the physics imposter, soft object only
  86246. */
  86247. pressure?: number;
  86248. /**
  86249. * The stiffness the physics imposter, soft object only
  86250. */
  86251. stiffness?: number;
  86252. /**
  86253. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  86254. */
  86255. velocityIterations?: number;
  86256. /**
  86257. * The number of iterations used in maintaining consistent vertex positions, soft object only
  86258. */
  86259. positionIterations?: number;
  86260. /**
  86261. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  86262. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  86263. * Add to fix multiple points
  86264. */
  86265. fixedPoints?: number;
  86266. /**
  86267. * The collision margin around a soft object
  86268. */
  86269. margin?: number;
  86270. /**
  86271. * The collision margin around a soft object
  86272. */
  86273. damping?: number;
  86274. /**
  86275. * The path for a rope based on an extrusion
  86276. */
  86277. path?: any;
  86278. /**
  86279. * The shape of an extrusion used for a rope based on an extrusion
  86280. */
  86281. shape?: any;
  86282. }
  86283. /**
  86284. * Interface for a physics-enabled object
  86285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86286. */
  86287. export interface IPhysicsEnabledObject {
  86288. /**
  86289. * The position of the physics-enabled object
  86290. */
  86291. position: Vector3;
  86292. /**
  86293. * The rotation of the physics-enabled object
  86294. */
  86295. rotationQuaternion: Nullable<Quaternion>;
  86296. /**
  86297. * The scale of the physics-enabled object
  86298. */
  86299. scaling: Vector3;
  86300. /**
  86301. * The rotation of the physics-enabled object
  86302. */
  86303. rotation?: Vector3;
  86304. /**
  86305. * The parent of the physics-enabled object
  86306. */
  86307. parent?: any;
  86308. /**
  86309. * The bounding info of the physics-enabled object
  86310. * @returns The bounding info of the physics-enabled object
  86311. */
  86312. getBoundingInfo(): BoundingInfo;
  86313. /**
  86314. * Computes the world matrix
  86315. * @param force Specifies if the world matrix should be computed by force
  86316. * @returns A world matrix
  86317. */
  86318. computeWorldMatrix(force: boolean): Matrix;
  86319. /**
  86320. * Gets the world matrix
  86321. * @returns A world matrix
  86322. */
  86323. getWorldMatrix?(): Matrix;
  86324. /**
  86325. * Gets the child meshes
  86326. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  86327. * @returns An array of abstract meshes
  86328. */
  86329. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  86330. /**
  86331. * Gets the vertex data
  86332. * @param kind The type of vertex data
  86333. * @returns A nullable array of numbers, or a float32 array
  86334. */
  86335. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  86336. /**
  86337. * Gets the indices from the mesh
  86338. * @returns A nullable array of index arrays
  86339. */
  86340. getIndices?(): Nullable<IndicesArray>;
  86341. /**
  86342. * Gets the scene from the mesh
  86343. * @returns the indices array or null
  86344. */
  86345. getScene?(): Scene;
  86346. /**
  86347. * Gets the absolute position from the mesh
  86348. * @returns the absolute position
  86349. */
  86350. getAbsolutePosition(): Vector3;
  86351. /**
  86352. * Gets the absolute pivot point from the mesh
  86353. * @returns the absolute pivot point
  86354. */
  86355. getAbsolutePivotPoint(): Vector3;
  86356. /**
  86357. * Rotates the mesh
  86358. * @param axis The axis of rotation
  86359. * @param amount The amount of rotation
  86360. * @param space The space of the rotation
  86361. * @returns The rotation transform node
  86362. */
  86363. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86364. /**
  86365. * Translates the mesh
  86366. * @param axis The axis of translation
  86367. * @param distance The distance of translation
  86368. * @param space The space of the translation
  86369. * @returns The transform node
  86370. */
  86371. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86372. /**
  86373. * Sets the absolute position of the mesh
  86374. * @param absolutePosition The absolute position of the mesh
  86375. * @returns The transform node
  86376. */
  86377. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86378. /**
  86379. * Gets the class name of the mesh
  86380. * @returns The class name
  86381. */
  86382. getClassName(): string;
  86383. }
  86384. /**
  86385. * Represents a physics imposter
  86386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86387. */
  86388. export class PhysicsImpostor {
  86389. /**
  86390. * The physics-enabled object used as the physics imposter
  86391. */
  86392. object: IPhysicsEnabledObject;
  86393. /**
  86394. * The type of the physics imposter
  86395. */
  86396. type: number;
  86397. private _options;
  86398. private _scene?;
  86399. /**
  86400. * The default object size of the imposter
  86401. */
  86402. static DEFAULT_OBJECT_SIZE: Vector3;
  86403. /**
  86404. * The identity quaternion of the imposter
  86405. */
  86406. static IDENTITY_QUATERNION: Quaternion;
  86407. /** @hidden */
  86408. _pluginData: any;
  86409. private _physicsEngine;
  86410. private _physicsBody;
  86411. private _bodyUpdateRequired;
  86412. private _onBeforePhysicsStepCallbacks;
  86413. private _onAfterPhysicsStepCallbacks;
  86414. /** @hidden */
  86415. _onPhysicsCollideCallbacks: Array<{
  86416. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  86417. otherImpostors: Array<PhysicsImpostor>;
  86418. }>;
  86419. private _deltaPosition;
  86420. private _deltaRotation;
  86421. private _deltaRotationConjugated;
  86422. /** @hidden */
  86423. _isFromLine: boolean;
  86424. private _parent;
  86425. private _isDisposed;
  86426. private static _tmpVecs;
  86427. private static _tmpQuat;
  86428. /**
  86429. * Specifies if the physics imposter is disposed
  86430. */
  86431. readonly isDisposed: boolean;
  86432. /**
  86433. * Gets the mass of the physics imposter
  86434. */
  86435. mass: number;
  86436. /**
  86437. * Gets the coefficient of friction
  86438. */
  86439. /**
  86440. * Sets the coefficient of friction
  86441. */
  86442. friction: number;
  86443. /**
  86444. * Gets the coefficient of restitution
  86445. */
  86446. /**
  86447. * Sets the coefficient of restitution
  86448. */
  86449. restitution: number;
  86450. /**
  86451. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  86452. */
  86453. /**
  86454. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  86455. */
  86456. pressure: number;
  86457. /**
  86458. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86459. */
  86460. /**
  86461. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86462. */
  86463. stiffness: number;
  86464. /**
  86465. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86466. */
  86467. /**
  86468. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86469. */
  86470. velocityIterations: number;
  86471. /**
  86472. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86473. */
  86474. /**
  86475. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86476. */
  86477. positionIterations: number;
  86478. /**
  86479. * The unique id of the physics imposter
  86480. * set by the physics engine when adding this impostor to the array
  86481. */
  86482. uniqueId: number;
  86483. /**
  86484. * @hidden
  86485. */
  86486. soft: boolean;
  86487. /**
  86488. * @hidden
  86489. */
  86490. segments: number;
  86491. private _joints;
  86492. /**
  86493. * Initializes the physics imposter
  86494. * @param object The physics-enabled object used as the physics imposter
  86495. * @param type The type of the physics imposter
  86496. * @param _options The options for the physics imposter
  86497. * @param _scene The Babylon scene
  86498. */
  86499. constructor(
  86500. /**
  86501. * The physics-enabled object used as the physics imposter
  86502. */
  86503. object: IPhysicsEnabledObject,
  86504. /**
  86505. * The type of the physics imposter
  86506. */
  86507. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  86508. /**
  86509. * This function will completly initialize this impostor.
  86510. * It will create a new body - but only if this mesh has no parent.
  86511. * If it has, this impostor will not be used other than to define the impostor
  86512. * of the child mesh.
  86513. * @hidden
  86514. */
  86515. _init(): void;
  86516. private _getPhysicsParent;
  86517. /**
  86518. * Should a new body be generated.
  86519. * @returns boolean specifying if body initialization is required
  86520. */
  86521. isBodyInitRequired(): boolean;
  86522. /**
  86523. * Sets the updated scaling
  86524. * @param updated Specifies if the scaling is updated
  86525. */
  86526. setScalingUpdated(): void;
  86527. /**
  86528. * Force a regeneration of this or the parent's impostor's body.
  86529. * Use under cautious - This will remove all joints already implemented.
  86530. */
  86531. forceUpdate(): void;
  86532. /**
  86533. * Gets the body that holds this impostor. Either its own, or its parent.
  86534. */
  86535. /**
  86536. * Set the physics body. Used mainly by the physics engine/plugin
  86537. */
  86538. physicsBody: any;
  86539. /**
  86540. * Get the parent of the physics imposter
  86541. * @returns Physics imposter or null
  86542. */
  86543. /**
  86544. * Sets the parent of the physics imposter
  86545. */
  86546. parent: Nullable<PhysicsImpostor>;
  86547. /**
  86548. * Resets the update flags
  86549. */
  86550. resetUpdateFlags(): void;
  86551. /**
  86552. * Gets the object extend size
  86553. * @returns the object extend size
  86554. */
  86555. getObjectExtendSize(): Vector3;
  86556. /**
  86557. * Gets the object center
  86558. * @returns The object center
  86559. */
  86560. getObjectCenter(): Vector3;
  86561. /**
  86562. * Get a specific parametes from the options parameter
  86563. * @param paramName The object parameter name
  86564. * @returns The object parameter
  86565. */
  86566. getParam(paramName: string): any;
  86567. /**
  86568. * Sets a specific parameter in the options given to the physics plugin
  86569. * @param paramName The parameter name
  86570. * @param value The value of the parameter
  86571. */
  86572. setParam(paramName: string, value: number): void;
  86573. /**
  86574. * Specifically change the body's mass option. Won't recreate the physics body object
  86575. * @param mass The mass of the physics imposter
  86576. */
  86577. setMass(mass: number): void;
  86578. /**
  86579. * Gets the linear velocity
  86580. * @returns linear velocity or null
  86581. */
  86582. getLinearVelocity(): Nullable<Vector3>;
  86583. /**
  86584. * Sets the linear velocity
  86585. * @param velocity linear velocity or null
  86586. */
  86587. setLinearVelocity(velocity: Nullable<Vector3>): void;
  86588. /**
  86589. * Gets the angular velocity
  86590. * @returns angular velocity or null
  86591. */
  86592. getAngularVelocity(): Nullable<Vector3>;
  86593. /**
  86594. * Sets the angular velocity
  86595. * @param velocity The velocity or null
  86596. */
  86597. setAngularVelocity(velocity: Nullable<Vector3>): void;
  86598. /**
  86599. * Execute a function with the physics plugin native code
  86600. * Provide a function the will have two variables - the world object and the physics body object
  86601. * @param func The function to execute with the physics plugin native code
  86602. */
  86603. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  86604. /**
  86605. * Register a function that will be executed before the physics world is stepping forward
  86606. * @param func The function to execute before the physics world is stepped forward
  86607. */
  86608. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86609. /**
  86610. * Unregister a function that will be executed before the physics world is stepping forward
  86611. * @param func The function to execute before the physics world is stepped forward
  86612. */
  86613. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86614. /**
  86615. * Register a function that will be executed after the physics step
  86616. * @param func The function to execute after physics step
  86617. */
  86618. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86619. /**
  86620. * Unregisters a function that will be executed after the physics step
  86621. * @param func The function to execute after physics step
  86622. */
  86623. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86624. /**
  86625. * register a function that will be executed when this impostor collides against a different body
  86626. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  86627. * @param func Callback that is executed on collision
  86628. */
  86629. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  86630. /**
  86631. * Unregisters the physics imposter on contact
  86632. * @param collideAgainst The physics object to collide against
  86633. * @param func Callback to execute on collision
  86634. */
  86635. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  86636. private _tmpQuat;
  86637. private _tmpQuat2;
  86638. /**
  86639. * Get the parent rotation
  86640. * @returns The parent rotation
  86641. */
  86642. getParentsRotation(): Quaternion;
  86643. /**
  86644. * this function is executed by the physics engine.
  86645. */
  86646. beforeStep: () => void;
  86647. /**
  86648. * this function is executed by the physics engine
  86649. */
  86650. afterStep: () => void;
  86651. /**
  86652. * Legacy collision detection event support
  86653. */
  86654. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  86655. /**
  86656. * event and body object due to cannon's event-based architecture.
  86657. */
  86658. onCollide: (e: {
  86659. body: any;
  86660. }) => void;
  86661. /**
  86662. * Apply a force
  86663. * @param force The force to apply
  86664. * @param contactPoint The contact point for the force
  86665. * @returns The physics imposter
  86666. */
  86667. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86668. /**
  86669. * Apply an impulse
  86670. * @param force The impulse force
  86671. * @param contactPoint The contact point for the impulse force
  86672. * @returns The physics imposter
  86673. */
  86674. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86675. /**
  86676. * A help function to create a joint
  86677. * @param otherImpostor A physics imposter used to create a joint
  86678. * @param jointType The type of joint
  86679. * @param jointData The data for the joint
  86680. * @returns The physics imposter
  86681. */
  86682. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  86683. /**
  86684. * Add a joint to this impostor with a different impostor
  86685. * @param otherImpostor A physics imposter used to add a joint
  86686. * @param joint The joint to add
  86687. * @returns The physics imposter
  86688. */
  86689. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  86690. /**
  86691. * Add an anchor to a cloth impostor
  86692. * @param otherImpostor rigid impostor to anchor to
  86693. * @param width ratio across width from 0 to 1
  86694. * @param height ratio up height from 0 to 1
  86695. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  86696. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  86697. * @returns impostor the soft imposter
  86698. */
  86699. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86700. /**
  86701. * Add a hook to a rope impostor
  86702. * @param otherImpostor rigid impostor to anchor to
  86703. * @param length ratio across rope from 0 to 1
  86704. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  86705. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  86706. * @returns impostor the rope imposter
  86707. */
  86708. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86709. /**
  86710. * Will keep this body still, in a sleep mode.
  86711. * @returns the physics imposter
  86712. */
  86713. sleep(): PhysicsImpostor;
  86714. /**
  86715. * Wake the body up.
  86716. * @returns The physics imposter
  86717. */
  86718. wakeUp(): PhysicsImpostor;
  86719. /**
  86720. * Clones the physics imposter
  86721. * @param newObject The physics imposter clones to this physics-enabled object
  86722. * @returns A nullable physics imposter
  86723. */
  86724. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86725. /**
  86726. * Disposes the physics imposter
  86727. */
  86728. dispose(): void;
  86729. /**
  86730. * Sets the delta position
  86731. * @param position The delta position amount
  86732. */
  86733. setDeltaPosition(position: Vector3): void;
  86734. /**
  86735. * Sets the delta rotation
  86736. * @param rotation The delta rotation amount
  86737. */
  86738. setDeltaRotation(rotation: Quaternion): void;
  86739. /**
  86740. * Gets the box size of the physics imposter and stores the result in the input parameter
  86741. * @param result Stores the box size
  86742. * @returns The physics imposter
  86743. */
  86744. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  86745. /**
  86746. * Gets the radius of the physics imposter
  86747. * @returns Radius of the physics imposter
  86748. */
  86749. getRadius(): number;
  86750. /**
  86751. * Sync a bone with this impostor
  86752. * @param bone The bone to sync to the impostor.
  86753. * @param boneMesh The mesh that the bone is influencing.
  86754. * @param jointPivot The pivot of the joint / bone in local space.
  86755. * @param distToJoint Optional distance from the impostor to the joint.
  86756. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  86757. */
  86758. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  86759. /**
  86760. * Sync impostor to a bone
  86761. * @param bone The bone that the impostor will be synced to.
  86762. * @param boneMesh The mesh that the bone is influencing.
  86763. * @param jointPivot The pivot of the joint / bone in local space.
  86764. * @param distToJoint Optional distance from the impostor to the joint.
  86765. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  86766. * @param boneAxis Optional vector3 axis the bone is aligned with
  86767. */
  86768. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  86769. /**
  86770. * No-Imposter type
  86771. */
  86772. static NoImpostor: number;
  86773. /**
  86774. * Sphere-Imposter type
  86775. */
  86776. static SphereImpostor: number;
  86777. /**
  86778. * Box-Imposter type
  86779. */
  86780. static BoxImpostor: number;
  86781. /**
  86782. * Plane-Imposter type
  86783. */
  86784. static PlaneImpostor: number;
  86785. /**
  86786. * Mesh-imposter type
  86787. */
  86788. static MeshImpostor: number;
  86789. /**
  86790. * Capsule-Impostor type (Ammo.js plugin only)
  86791. */
  86792. static CapsuleImpostor: number;
  86793. /**
  86794. * Cylinder-Imposter type
  86795. */
  86796. static CylinderImpostor: number;
  86797. /**
  86798. * Particle-Imposter type
  86799. */
  86800. static ParticleImpostor: number;
  86801. /**
  86802. * Heightmap-Imposter type
  86803. */
  86804. static HeightmapImpostor: number;
  86805. /**
  86806. * ConvexHull-Impostor type (Ammo.js plugin only)
  86807. */
  86808. static ConvexHullImpostor: number;
  86809. /**
  86810. * Rope-Imposter type
  86811. */
  86812. static RopeImpostor: number;
  86813. /**
  86814. * Cloth-Imposter type
  86815. */
  86816. static ClothImpostor: number;
  86817. /**
  86818. * Softbody-Imposter type
  86819. */
  86820. static SoftbodyImpostor: number;
  86821. }
  86822. }
  86823. declare module BABYLON {
  86824. /**
  86825. * @hidden
  86826. **/
  86827. export class _CreationDataStorage {
  86828. closePath?: boolean;
  86829. closeArray?: boolean;
  86830. idx: number[];
  86831. dashSize: number;
  86832. gapSize: number;
  86833. path3D: Path3D;
  86834. pathArray: Vector3[][];
  86835. arc: number;
  86836. radius: number;
  86837. cap: number;
  86838. tessellation: number;
  86839. }
  86840. /**
  86841. * @hidden
  86842. **/
  86843. class _InstanceDataStorage {
  86844. visibleInstances: any;
  86845. batchCache: _InstancesBatch;
  86846. instancesBufferSize: number;
  86847. instancesBuffer: Nullable<Buffer>;
  86848. instancesData: Float32Array;
  86849. overridenInstanceCount: number;
  86850. isFrozen: boolean;
  86851. previousBatch: Nullable<_InstancesBatch>;
  86852. hardwareInstancedRendering: boolean;
  86853. sideOrientation: number;
  86854. }
  86855. /**
  86856. * @hidden
  86857. **/
  86858. export class _InstancesBatch {
  86859. mustReturn: boolean;
  86860. visibleInstances: Nullable<InstancedMesh[]>[];
  86861. renderSelf: boolean[];
  86862. hardwareInstancedRendering: boolean[];
  86863. }
  86864. /**
  86865. * Class used to represent renderable models
  86866. */
  86867. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  86868. /**
  86869. * Mesh side orientation : usually the external or front surface
  86870. */
  86871. static readonly FRONTSIDE: number;
  86872. /**
  86873. * Mesh side orientation : usually the internal or back surface
  86874. */
  86875. static readonly BACKSIDE: number;
  86876. /**
  86877. * Mesh side orientation : both internal and external or front and back surfaces
  86878. */
  86879. static readonly DOUBLESIDE: number;
  86880. /**
  86881. * Mesh side orientation : by default, `FRONTSIDE`
  86882. */
  86883. static readonly DEFAULTSIDE: number;
  86884. /**
  86885. * Mesh cap setting : no cap
  86886. */
  86887. static readonly NO_CAP: number;
  86888. /**
  86889. * Mesh cap setting : one cap at the beginning of the mesh
  86890. */
  86891. static readonly CAP_START: number;
  86892. /**
  86893. * Mesh cap setting : one cap at the end of the mesh
  86894. */
  86895. static readonly CAP_END: number;
  86896. /**
  86897. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  86898. */
  86899. static readonly CAP_ALL: number;
  86900. /**
  86901. * Mesh pattern setting : no flip or rotate
  86902. */
  86903. static readonly NO_FLIP: number;
  86904. /**
  86905. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  86906. */
  86907. static readonly FLIP_TILE: number;
  86908. /**
  86909. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  86910. */
  86911. static readonly ROTATE_TILE: number;
  86912. /**
  86913. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  86914. */
  86915. static readonly FLIP_ROW: number;
  86916. /**
  86917. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  86918. */
  86919. static readonly ROTATE_ROW: number;
  86920. /**
  86921. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  86922. */
  86923. static readonly FLIP_N_ROTATE_TILE: number;
  86924. /**
  86925. * Mesh pattern setting : rotate pattern and rotate
  86926. */
  86927. static readonly FLIP_N_ROTATE_ROW: number;
  86928. /**
  86929. * Mesh tile positioning : part tiles same on left/right or top/bottom
  86930. */
  86931. static readonly CENTER: number;
  86932. /**
  86933. * Mesh tile positioning : part tiles on left
  86934. */
  86935. static readonly LEFT: number;
  86936. /**
  86937. * Mesh tile positioning : part tiles on right
  86938. */
  86939. static readonly RIGHT: number;
  86940. /**
  86941. * Mesh tile positioning : part tiles on top
  86942. */
  86943. static readonly TOP: number;
  86944. /**
  86945. * Mesh tile positioning : part tiles on bottom
  86946. */
  86947. static readonly BOTTOM: number;
  86948. /**
  86949. * Gets the default side orientation.
  86950. * @param orientation the orientation to value to attempt to get
  86951. * @returns the default orientation
  86952. * @hidden
  86953. */
  86954. static _GetDefaultSideOrientation(orientation?: number): number;
  86955. private _internalMeshDataInfo;
  86956. /**
  86957. * An event triggered before rendering the mesh
  86958. */
  86959. readonly onBeforeRenderObservable: Observable<Mesh>;
  86960. /**
  86961. * An event triggered before binding the mesh
  86962. */
  86963. readonly onBeforeBindObservable: Observable<Mesh>;
  86964. /**
  86965. * An event triggered after rendering the mesh
  86966. */
  86967. readonly onAfterRenderObservable: Observable<Mesh>;
  86968. /**
  86969. * An event triggered before drawing the mesh
  86970. */
  86971. readonly onBeforeDrawObservable: Observable<Mesh>;
  86972. private _onBeforeDrawObserver;
  86973. /**
  86974. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  86975. */
  86976. onBeforeDraw: () => void;
  86977. /**
  86978. * Gets the delay loading state of the mesh (when delay loading is turned on)
  86979. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  86980. */
  86981. delayLoadState: number;
  86982. /**
  86983. * Gets the list of instances created from this mesh
  86984. * it is not supposed to be modified manually.
  86985. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  86986. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86987. */
  86988. instances: InstancedMesh[];
  86989. /**
  86990. * Gets the file containing delay loading data for this mesh
  86991. */
  86992. delayLoadingFile: string;
  86993. /** @hidden */
  86994. _binaryInfo: any;
  86995. /**
  86996. * User defined function used to change how LOD level selection is done
  86997. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86998. */
  86999. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87000. /**
  87001. * Gets or sets the morph target manager
  87002. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87003. */
  87004. morphTargetManager: Nullable<MorphTargetManager>;
  87005. /** @hidden */
  87006. _creationDataStorage: Nullable<_CreationDataStorage>;
  87007. /** @hidden */
  87008. _geometry: Nullable<Geometry>;
  87009. /** @hidden */
  87010. _delayInfo: Array<string>;
  87011. /** @hidden */
  87012. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87013. /** @hidden */
  87014. _instanceDataStorage: _InstanceDataStorage;
  87015. private _effectiveMaterial;
  87016. /** @hidden */
  87017. _shouldGenerateFlatShading: boolean;
  87018. /** @hidden */
  87019. _originalBuilderSideOrientation: number;
  87020. /**
  87021. * Use this property to change the original side orientation defined at construction time
  87022. */
  87023. overrideMaterialSideOrientation: Nullable<number>;
  87024. /**
  87025. * Gets the source mesh (the one used to clone this one from)
  87026. */
  87027. readonly source: Nullable<Mesh>;
  87028. /**
  87029. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87030. */
  87031. isUnIndexed: boolean;
  87032. /**
  87033. * @constructor
  87034. * @param name The value used by scene.getMeshByName() to do a lookup.
  87035. * @param scene The scene to add this mesh to.
  87036. * @param parent The parent of this mesh, if it has one
  87037. * @param source An optional Mesh from which geometry is shared, cloned.
  87038. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87039. * When false, achieved by calling a clone(), also passing False.
  87040. * This will make creation of children, recursive.
  87041. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87042. */
  87043. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87044. /**
  87045. * Gets the class name
  87046. * @returns the string "Mesh".
  87047. */
  87048. getClassName(): string;
  87049. /** @hidden */
  87050. readonly _isMesh: boolean;
  87051. /**
  87052. * Returns a description of this mesh
  87053. * @param fullDetails define if full details about this mesh must be used
  87054. * @returns a descriptive string representing this mesh
  87055. */
  87056. toString(fullDetails?: boolean): string;
  87057. /** @hidden */
  87058. _unBindEffect(): void;
  87059. /**
  87060. * Gets a boolean indicating if this mesh has LOD
  87061. */
  87062. readonly hasLODLevels: boolean;
  87063. /**
  87064. * Gets the list of MeshLODLevel associated with the current mesh
  87065. * @returns an array of MeshLODLevel
  87066. */
  87067. getLODLevels(): MeshLODLevel[];
  87068. private _sortLODLevels;
  87069. /**
  87070. * Add a mesh as LOD level triggered at the given distance.
  87071. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87072. * @param distance The distance from the center of the object to show this level
  87073. * @param mesh The mesh to be added as LOD level (can be null)
  87074. * @return This mesh (for chaining)
  87075. */
  87076. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87077. /**
  87078. * Returns the LOD level mesh at the passed distance or null if not found.
  87079. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87080. * @param distance The distance from the center of the object to show this level
  87081. * @returns a Mesh or `null`
  87082. */
  87083. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  87084. /**
  87085. * Remove a mesh from the LOD array
  87086. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87087. * @param mesh defines the mesh to be removed
  87088. * @return This mesh (for chaining)
  87089. */
  87090. removeLODLevel(mesh: Mesh): Mesh;
  87091. /**
  87092. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87093. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87094. * @param camera defines the camera to use to compute distance
  87095. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87096. * @return This mesh (for chaining)
  87097. */
  87098. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  87099. /**
  87100. * Gets the mesh internal Geometry object
  87101. */
  87102. readonly geometry: Nullable<Geometry>;
  87103. /**
  87104. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87105. * @returns the total number of vertices
  87106. */
  87107. getTotalVertices(): number;
  87108. /**
  87109. * Returns the content of an associated vertex buffer
  87110. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87111. * - VertexBuffer.PositionKind
  87112. * - VertexBuffer.UVKind
  87113. * - VertexBuffer.UV2Kind
  87114. * - VertexBuffer.UV3Kind
  87115. * - VertexBuffer.UV4Kind
  87116. * - VertexBuffer.UV5Kind
  87117. * - VertexBuffer.UV6Kind
  87118. * - VertexBuffer.ColorKind
  87119. * - VertexBuffer.MatricesIndicesKind
  87120. * - VertexBuffer.MatricesIndicesExtraKind
  87121. * - VertexBuffer.MatricesWeightsKind
  87122. * - VertexBuffer.MatricesWeightsExtraKind
  87123. * @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
  87124. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87125. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87126. */
  87127. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87128. /**
  87129. * Returns the mesh VertexBuffer object from the requested `kind`
  87130. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87131. * - VertexBuffer.PositionKind
  87132. * - VertexBuffer.NormalKind
  87133. * - VertexBuffer.UVKind
  87134. * - VertexBuffer.UV2Kind
  87135. * - VertexBuffer.UV3Kind
  87136. * - VertexBuffer.UV4Kind
  87137. * - VertexBuffer.UV5Kind
  87138. * - VertexBuffer.UV6Kind
  87139. * - VertexBuffer.ColorKind
  87140. * - VertexBuffer.MatricesIndicesKind
  87141. * - VertexBuffer.MatricesIndicesExtraKind
  87142. * - VertexBuffer.MatricesWeightsKind
  87143. * - VertexBuffer.MatricesWeightsExtraKind
  87144. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87145. */
  87146. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87147. /**
  87148. * Tests if a specific vertex buffer is associated with this mesh
  87149. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87150. * - VertexBuffer.PositionKind
  87151. * - VertexBuffer.NormalKind
  87152. * - VertexBuffer.UVKind
  87153. * - VertexBuffer.UV2Kind
  87154. * - VertexBuffer.UV3Kind
  87155. * - VertexBuffer.UV4Kind
  87156. * - VertexBuffer.UV5Kind
  87157. * - VertexBuffer.UV6Kind
  87158. * - VertexBuffer.ColorKind
  87159. * - VertexBuffer.MatricesIndicesKind
  87160. * - VertexBuffer.MatricesIndicesExtraKind
  87161. * - VertexBuffer.MatricesWeightsKind
  87162. * - VertexBuffer.MatricesWeightsExtraKind
  87163. * @returns a boolean
  87164. */
  87165. isVerticesDataPresent(kind: string): boolean;
  87166. /**
  87167. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87168. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87169. * - VertexBuffer.PositionKind
  87170. * - VertexBuffer.UVKind
  87171. * - VertexBuffer.UV2Kind
  87172. * - VertexBuffer.UV3Kind
  87173. * - VertexBuffer.UV4Kind
  87174. * - VertexBuffer.UV5Kind
  87175. * - VertexBuffer.UV6Kind
  87176. * - VertexBuffer.ColorKind
  87177. * - VertexBuffer.MatricesIndicesKind
  87178. * - VertexBuffer.MatricesIndicesExtraKind
  87179. * - VertexBuffer.MatricesWeightsKind
  87180. * - VertexBuffer.MatricesWeightsExtraKind
  87181. * @returns a boolean
  87182. */
  87183. isVertexBufferUpdatable(kind: string): boolean;
  87184. /**
  87185. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87186. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87187. * - VertexBuffer.PositionKind
  87188. * - VertexBuffer.NormalKind
  87189. * - VertexBuffer.UVKind
  87190. * - VertexBuffer.UV2Kind
  87191. * - VertexBuffer.UV3Kind
  87192. * - VertexBuffer.UV4Kind
  87193. * - VertexBuffer.UV5Kind
  87194. * - VertexBuffer.UV6Kind
  87195. * - VertexBuffer.ColorKind
  87196. * - VertexBuffer.MatricesIndicesKind
  87197. * - VertexBuffer.MatricesIndicesExtraKind
  87198. * - VertexBuffer.MatricesWeightsKind
  87199. * - VertexBuffer.MatricesWeightsExtraKind
  87200. * @returns an array of strings
  87201. */
  87202. getVerticesDataKinds(): string[];
  87203. /**
  87204. * Returns a positive integer : the total number of indices in this mesh geometry.
  87205. * @returns the numner of indices or zero if the mesh has no geometry.
  87206. */
  87207. getTotalIndices(): number;
  87208. /**
  87209. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87210. * @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.
  87211. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87212. * @returns the indices array or an empty array if the mesh has no geometry
  87213. */
  87214. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87215. readonly isBlocked: boolean;
  87216. /**
  87217. * Determine if the current mesh is ready to be rendered
  87218. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87219. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87220. * @returns true if all associated assets are ready (material, textures, shaders)
  87221. */
  87222. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  87223. /**
  87224. * 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.
  87225. */
  87226. readonly areNormalsFrozen: boolean;
  87227. /**
  87228. * 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.
  87229. * @returns the current mesh
  87230. */
  87231. freezeNormals(): Mesh;
  87232. /**
  87233. * 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
  87234. * @returns the current mesh
  87235. */
  87236. unfreezeNormals(): Mesh;
  87237. /**
  87238. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87239. */
  87240. overridenInstanceCount: number;
  87241. /** @hidden */
  87242. _preActivate(): Mesh;
  87243. /** @hidden */
  87244. _preActivateForIntermediateRendering(renderId: number): Mesh;
  87245. /** @hidden */
  87246. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  87247. /**
  87248. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87249. * This means the mesh underlying bounding box and sphere are recomputed.
  87250. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87251. * @returns the current mesh
  87252. */
  87253. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  87254. /** @hidden */
  87255. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  87256. /**
  87257. * This function will subdivide the mesh into multiple submeshes
  87258. * @param count defines the expected number of submeshes
  87259. */
  87260. subdivide(count: number): void;
  87261. /**
  87262. * Copy a FloatArray into a specific associated vertex buffer
  87263. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87264. * - VertexBuffer.PositionKind
  87265. * - VertexBuffer.UVKind
  87266. * - VertexBuffer.UV2Kind
  87267. * - VertexBuffer.UV3Kind
  87268. * - VertexBuffer.UV4Kind
  87269. * - VertexBuffer.UV5Kind
  87270. * - VertexBuffer.UV6Kind
  87271. * - VertexBuffer.ColorKind
  87272. * - VertexBuffer.MatricesIndicesKind
  87273. * - VertexBuffer.MatricesIndicesExtraKind
  87274. * - VertexBuffer.MatricesWeightsKind
  87275. * - VertexBuffer.MatricesWeightsExtraKind
  87276. * @param data defines the data source
  87277. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87278. * @param stride defines the data stride size (can be null)
  87279. * @returns the current mesh
  87280. */
  87281. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  87282. /**
  87283. * Flags an associated vertex buffer as updatable
  87284. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87285. * - VertexBuffer.PositionKind
  87286. * - VertexBuffer.UVKind
  87287. * - VertexBuffer.UV2Kind
  87288. * - VertexBuffer.UV3Kind
  87289. * - VertexBuffer.UV4Kind
  87290. * - VertexBuffer.UV5Kind
  87291. * - VertexBuffer.UV6Kind
  87292. * - VertexBuffer.ColorKind
  87293. * - VertexBuffer.MatricesIndicesKind
  87294. * - VertexBuffer.MatricesIndicesExtraKind
  87295. * - VertexBuffer.MatricesWeightsKind
  87296. * - VertexBuffer.MatricesWeightsExtraKind
  87297. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87298. */
  87299. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  87300. /**
  87301. * Sets the mesh global Vertex Buffer
  87302. * @param buffer defines the buffer to use
  87303. * @returns the current mesh
  87304. */
  87305. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  87306. /**
  87307. * Update a specific associated vertex buffer
  87308. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87309. * - VertexBuffer.PositionKind
  87310. * - VertexBuffer.UVKind
  87311. * - VertexBuffer.UV2Kind
  87312. * - VertexBuffer.UV3Kind
  87313. * - VertexBuffer.UV4Kind
  87314. * - VertexBuffer.UV5Kind
  87315. * - VertexBuffer.UV6Kind
  87316. * - VertexBuffer.ColorKind
  87317. * - VertexBuffer.MatricesIndicesKind
  87318. * - VertexBuffer.MatricesIndicesExtraKind
  87319. * - VertexBuffer.MatricesWeightsKind
  87320. * - VertexBuffer.MatricesWeightsExtraKind
  87321. * @param data defines the data source
  87322. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87323. * @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)
  87324. * @returns the current mesh
  87325. */
  87326. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87327. /**
  87328. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87329. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87330. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87331. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87332. * @returns the current mesh
  87333. */
  87334. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  87335. /**
  87336. * Creates a un-shared specific occurence of the geometry for the mesh.
  87337. * @returns the current mesh
  87338. */
  87339. makeGeometryUnique(): Mesh;
  87340. /**
  87341. * Set the index buffer of this mesh
  87342. * @param indices defines the source data
  87343. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87344. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87345. * @returns the current mesh
  87346. */
  87347. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  87348. /**
  87349. * Update the current index buffer
  87350. * @param indices defines the source data
  87351. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87352. * @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)
  87353. * @returns the current mesh
  87354. */
  87355. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  87356. /**
  87357. * Invert the geometry to move from a right handed system to a left handed one.
  87358. * @returns the current mesh
  87359. */
  87360. toLeftHanded(): Mesh;
  87361. /** @hidden */
  87362. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87363. /** @hidden */
  87364. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87365. /**
  87366. * Registers for this mesh a javascript function called just before the rendering process
  87367. * @param func defines the function to call before rendering this mesh
  87368. * @returns the current mesh
  87369. */
  87370. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87371. /**
  87372. * Disposes a previously registered javascript function called before the rendering
  87373. * @param func defines the function to remove
  87374. * @returns the current mesh
  87375. */
  87376. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87377. /**
  87378. * Registers for this mesh a javascript function called just after the rendering is complete
  87379. * @param func defines the function to call after rendering this mesh
  87380. * @returns the current mesh
  87381. */
  87382. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87383. /**
  87384. * Disposes a previously registered javascript function called after the rendering.
  87385. * @param func defines the function to remove
  87386. * @returns the current mesh
  87387. */
  87388. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87389. /** @hidden */
  87390. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  87391. /** @hidden */
  87392. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  87393. /** @hidden */
  87394. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  87395. /** @hidden */
  87396. _rebuild(): void;
  87397. /** @hidden */
  87398. _freeze(): void;
  87399. /** @hidden */
  87400. _unFreeze(): void;
  87401. /**
  87402. * 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
  87403. * @param subMesh defines the subMesh to render
  87404. * @param enableAlphaMode defines if alpha mode can be changed
  87405. * @returns the current mesh
  87406. */
  87407. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  87408. private _onBeforeDraw;
  87409. /**
  87410. * Renormalize the mesh and patch it up if there are no weights
  87411. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87412. * However in the case of zero weights then we set just a single influence to 1.
  87413. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87414. */
  87415. cleanMatrixWeights(): void;
  87416. private normalizeSkinFourWeights;
  87417. private normalizeSkinWeightsAndExtra;
  87418. /**
  87419. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  87420. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  87421. * the user know there was an issue with importing the mesh
  87422. * @returns a validation object with skinned, valid and report string
  87423. */
  87424. validateSkinning(): {
  87425. skinned: boolean;
  87426. valid: boolean;
  87427. report: string;
  87428. };
  87429. /** @hidden */
  87430. _checkDelayState(): Mesh;
  87431. private _queueLoad;
  87432. /**
  87433. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87434. * A mesh is in the frustum if its bounding box intersects the frustum
  87435. * @param frustumPlanes defines the frustum to test
  87436. * @returns true if the mesh is in the frustum planes
  87437. */
  87438. isInFrustum(frustumPlanes: Plane[]): boolean;
  87439. /**
  87440. * Sets the mesh material by the material or multiMaterial `id` property
  87441. * @param id is a string identifying the material or the multiMaterial
  87442. * @returns the current mesh
  87443. */
  87444. setMaterialByID(id: string): Mesh;
  87445. /**
  87446. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  87447. * @returns an array of IAnimatable
  87448. */
  87449. getAnimatables(): IAnimatable[];
  87450. /**
  87451. * Modifies the mesh geometry according to the passed transformation matrix.
  87452. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  87453. * The mesh normals are modified using the same transformation.
  87454. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87455. * @param transform defines the transform matrix to use
  87456. * @see http://doc.babylonjs.com/resources/baking_transformations
  87457. * @returns the current mesh
  87458. */
  87459. bakeTransformIntoVertices(transform: Matrix): Mesh;
  87460. /**
  87461. * Modifies the mesh geometry according to its own current World Matrix.
  87462. * The mesh World Matrix is then reset.
  87463. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  87464. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87465. * @see http://doc.babylonjs.com/resources/baking_transformations
  87466. * @returns the current mesh
  87467. */
  87468. bakeCurrentTransformIntoVertices(): Mesh;
  87469. /** @hidden */
  87470. readonly _positions: Nullable<Vector3[]>;
  87471. /** @hidden */
  87472. _resetPointsArrayCache(): Mesh;
  87473. /** @hidden */
  87474. _generatePointsArray(): boolean;
  87475. /**
  87476. * Returns a new Mesh object generated from the current mesh properties.
  87477. * This method must not get confused with createInstance()
  87478. * @param name is a string, the name given to the new mesh
  87479. * @param newParent can be any Node object (default `null`)
  87480. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87481. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87482. * @returns a new mesh
  87483. */
  87484. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  87485. /**
  87486. * Releases resources associated with this mesh.
  87487. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87488. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87489. */
  87490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87491. /**
  87492. * Modifies the mesh geometry according to a displacement map.
  87493. * 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.
  87494. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87495. * @param url is a string, the URL from the image file is to be downloaded.
  87496. * @param minHeight is the lower limit of the displacement.
  87497. * @param maxHeight is the upper limit of the displacement.
  87498. * @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.
  87499. * @param uvOffset is an optional vector2 used to offset UV.
  87500. * @param uvScale is an optional vector2 used to scale UV.
  87501. * @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.
  87502. * @returns the Mesh.
  87503. */
  87504. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87505. /**
  87506. * Modifies the mesh geometry according to a displacementMap buffer.
  87507. * 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.
  87508. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87509. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  87510. * @param heightMapWidth is the width of the buffer image.
  87511. * @param heightMapHeight is the height of the buffer image.
  87512. * @param minHeight is the lower limit of the displacement.
  87513. * @param maxHeight is the upper limit of the displacement.
  87514. * @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.
  87515. * @param uvOffset is an optional vector2 used to offset UV.
  87516. * @param uvScale is an optional vector2 used to scale UV.
  87517. * @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.
  87518. * @returns the Mesh.
  87519. */
  87520. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87521. /**
  87522. * Modify the mesh to get a flat shading rendering.
  87523. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  87524. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  87525. * @returns current mesh
  87526. */
  87527. convertToFlatShadedMesh(): Mesh;
  87528. /**
  87529. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87530. * In other words, more vertices, no more indices and a single bigger VBO.
  87531. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87532. * @returns current mesh
  87533. */
  87534. convertToUnIndexedMesh(): Mesh;
  87535. /**
  87536. * Inverses facet orientations.
  87537. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87538. * @param flipNormals will also inverts the normals
  87539. * @returns current mesh
  87540. */
  87541. flipFaces(flipNormals?: boolean): Mesh;
  87542. /**
  87543. * Increase the number of facets and hence vertices in a mesh
  87544. * Vertex normals are interpolated from existing vertex normals
  87545. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87546. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  87547. */
  87548. increaseVertices(numberPerEdge: number): void;
  87549. /**
  87550. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  87551. * This will undo any application of covertToFlatShadedMesh
  87552. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87553. */
  87554. forceSharedVertices(): void;
  87555. /** @hidden */
  87556. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  87557. /** @hidden */
  87558. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  87559. /**
  87560. * Creates a new InstancedMesh object from the mesh model.
  87561. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87562. * @param name defines the name of the new instance
  87563. * @returns a new InstancedMesh
  87564. */
  87565. createInstance(name: string): InstancedMesh;
  87566. /**
  87567. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  87568. * After this call, all the mesh instances have the same submeshes than the current mesh.
  87569. * @returns the current mesh
  87570. */
  87571. synchronizeInstances(): Mesh;
  87572. /**
  87573. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  87574. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  87575. * This should be used together with the simplification to avoid disappearing triangles.
  87576. * @param successCallback an optional success callback to be called after the optimization finished.
  87577. * @returns the current mesh
  87578. */
  87579. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  87580. /**
  87581. * Serialize current mesh
  87582. * @param serializationObject defines the object which will receive the serialization data
  87583. */
  87584. serialize(serializationObject: any): void;
  87585. /** @hidden */
  87586. _syncGeometryWithMorphTargetManager(): void;
  87587. /** @hidden */
  87588. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  87589. /**
  87590. * Returns a new Mesh object parsed from the source provided.
  87591. * @param parsedMesh is the source
  87592. * @param scene defines the hosting scene
  87593. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  87594. * @returns a new Mesh
  87595. */
  87596. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  87597. /**
  87598. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  87599. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87600. * @param name defines the name of the mesh to create
  87601. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  87602. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  87603. * @param closePath creates a seam between the first and the last points of each path of the path array
  87604. * @param offset is taken in account only if the `pathArray` is containing a single path
  87605. * @param scene defines the hosting scene
  87606. * @param updatable defines if the mesh must be flagged as updatable
  87607. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87608. * @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)
  87609. * @returns a new Mesh
  87610. */
  87611. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87612. /**
  87613. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  87614. * @param name defines the name of the mesh to create
  87615. * @param radius sets the radius size (float) of the polygon (default 0.5)
  87616. * @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
  87617. * @param scene defines the hosting scene
  87618. * @param updatable defines if the mesh must be flagged as updatable
  87619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87620. * @returns a new Mesh
  87621. */
  87622. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87623. /**
  87624. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  87625. * @param name defines the name of the mesh to create
  87626. * @param size sets the size (float) of each box side (default 1)
  87627. * @param scene defines the hosting scene
  87628. * @param updatable defines if the mesh must be flagged as updatable
  87629. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87630. * @returns a new Mesh
  87631. */
  87632. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87633. /**
  87634. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  87635. * @param name defines the name of the mesh to create
  87636. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87637. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87638. * @param scene defines the hosting scene
  87639. * @param updatable defines if the mesh must be flagged as updatable
  87640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87641. * @returns a new Mesh
  87642. */
  87643. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87644. /**
  87645. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  87646. * @param name defines the name of the mesh to create
  87647. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87648. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87649. * @param scene defines the hosting scene
  87650. * @returns a new Mesh
  87651. */
  87652. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  87653. /**
  87654. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  87655. * @param name defines the name of the mesh to create
  87656. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  87657. * @param diameterTop set the top cap diameter (floats, default 1)
  87658. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  87659. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  87660. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  87661. * @param scene defines the hosting scene
  87662. * @param updatable defines if the mesh must be flagged as updatable
  87663. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87664. * @returns a new Mesh
  87665. */
  87666. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  87667. /**
  87668. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  87669. * @param name defines the name of the mesh to create
  87670. * @param diameter sets the diameter size (float) of the torus (default 1)
  87671. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  87672. * @param tessellation sets the number of torus sides (postive integer, default 16)
  87673. * @param scene defines the hosting scene
  87674. * @param updatable defines if the mesh must be flagged as updatable
  87675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87676. * @returns a new Mesh
  87677. */
  87678. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87679. /**
  87680. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  87681. * @param name defines the name of the mesh to create
  87682. * @param radius sets the global radius size (float) of the torus knot (default 2)
  87683. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  87684. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  87685. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  87686. * @param p the number of windings on X axis (positive integers, default 2)
  87687. * @param q the number of windings on Y axis (positive integers, default 3)
  87688. * @param scene defines the hosting scene
  87689. * @param updatable defines if the mesh must be flagged as updatable
  87690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87691. * @returns a new Mesh
  87692. */
  87693. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87694. /**
  87695. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  87696. * @param name defines the name of the mesh to create
  87697. * @param points is an array successive Vector3
  87698. * @param scene defines the hosting scene
  87699. * @param updatable defines if the mesh must be flagged as updatable
  87700. * @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).
  87701. * @returns a new Mesh
  87702. */
  87703. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  87704. /**
  87705. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  87706. * @param name defines the name of the mesh to create
  87707. * @param points is an array successive Vector3
  87708. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  87709. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  87710. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  87711. * @param scene defines the hosting scene
  87712. * @param updatable defines if the mesh must be flagged as updatable
  87713. * @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)
  87714. * @returns a new Mesh
  87715. */
  87716. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  87717. /**
  87718. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  87719. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  87720. * 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.
  87721. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87722. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87723. * Remember you can only change the shape positions, not their number when updating a polygon.
  87724. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  87725. * @param name defines the name of the mesh to create
  87726. * @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
  87727. * @param scene defines the hosting scene
  87728. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87729. * @param updatable defines if the mesh must be flagged as updatable
  87730. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87731. * @param earcutInjection can be used to inject your own earcut reference
  87732. * @returns a new Mesh
  87733. */
  87734. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  87735. /**
  87736. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  87737. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  87738. * @param name defines the name of the mesh to create
  87739. * @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
  87740. * @param depth defines the height of extrusion
  87741. * @param scene defines the hosting scene
  87742. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87743. * @param updatable defines if the mesh must be flagged as updatable
  87744. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87745. * @param earcutInjection can be used to inject your own earcut reference
  87746. * @returns a new Mesh
  87747. */
  87748. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  87749. /**
  87750. * Creates an extruded shape mesh.
  87751. * 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
  87752. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87753. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87754. * @param name defines the name of the mesh to create
  87755. * @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
  87756. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87757. * @param scale is the value to scale the shape
  87758. * @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
  87759. * @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
  87760. * @param scene defines the hosting scene
  87761. * @param updatable defines if the mesh must be flagged as updatable
  87762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87763. * @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)
  87764. * @returns a new Mesh
  87765. */
  87766. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87767. /**
  87768. * Creates an custom extruded shape mesh.
  87769. * The custom extrusion is a parametric shape.
  87770. * It has no predefined shape. Its final shape will depend on the input parameters.
  87771. * Please consider using the same method from the MeshBuilder class instead
  87772. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87773. * @param name defines the name of the mesh to create
  87774. * @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
  87775. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87776. * @param scaleFunction is a custom Javascript function called on each path point
  87777. * @param rotationFunction is a custom Javascript function called on each path point
  87778. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  87779. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  87780. * @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
  87781. * @param scene defines the hosting scene
  87782. * @param updatable defines if the mesh must be flagged as updatable
  87783. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87784. * @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)
  87785. * @returns a new Mesh
  87786. */
  87787. 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;
  87788. /**
  87789. * Creates lathe mesh.
  87790. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  87791. * Please consider using the same method from the MeshBuilder class instead
  87792. * @param name defines the name of the mesh to create
  87793. * @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
  87794. * @param radius is the radius value of the lathe
  87795. * @param tessellation is the side number of the lathe.
  87796. * @param scene defines the hosting scene
  87797. * @param updatable defines if the mesh must be flagged as updatable
  87798. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87799. * @returns a new Mesh
  87800. */
  87801. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87802. /**
  87803. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  87804. * @param name defines the name of the mesh to create
  87805. * @param size sets the size (float) of both sides of the plane at once (default 1)
  87806. * @param scene defines the hosting scene
  87807. * @param updatable defines if the mesh must be flagged as updatable
  87808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87809. * @returns a new Mesh
  87810. */
  87811. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87812. /**
  87813. * Creates a ground mesh.
  87814. * Please consider using the same method from the MeshBuilder class instead
  87815. * @param name defines the name of the mesh to create
  87816. * @param width set the width of the ground
  87817. * @param height set the height of the ground
  87818. * @param subdivisions sets the number of subdivisions per side
  87819. * @param scene defines the hosting scene
  87820. * @param updatable defines if the mesh must be flagged as updatable
  87821. * @returns a new Mesh
  87822. */
  87823. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  87824. /**
  87825. * Creates a tiled ground mesh.
  87826. * Please consider using the same method from the MeshBuilder class instead
  87827. * @param name defines the name of the mesh to create
  87828. * @param xmin set the ground minimum X coordinate
  87829. * @param zmin set the ground minimum Y coordinate
  87830. * @param xmax set the ground maximum X coordinate
  87831. * @param zmax set the ground maximum Z coordinate
  87832. * @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
  87833. * @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
  87834. * @param scene defines the hosting scene
  87835. * @param updatable defines if the mesh must be flagged as updatable
  87836. * @returns a new Mesh
  87837. */
  87838. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  87839. w: number;
  87840. h: number;
  87841. }, precision: {
  87842. w: number;
  87843. h: number;
  87844. }, scene: Scene, updatable?: boolean): Mesh;
  87845. /**
  87846. * Creates a ground mesh from a height map.
  87847. * Please consider using the same method from the MeshBuilder class instead
  87848. * @see http://doc.babylonjs.com/babylon101/height_map
  87849. * @param name defines the name of the mesh to create
  87850. * @param url sets the URL of the height map image resource
  87851. * @param width set the ground width size
  87852. * @param height set the ground height size
  87853. * @param subdivisions sets the number of subdivision per side
  87854. * @param minHeight is the minimum altitude on the ground
  87855. * @param maxHeight is the maximum altitude on the ground
  87856. * @param scene defines the hosting scene
  87857. * @param updatable defines if the mesh must be flagged as updatable
  87858. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  87859. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  87860. * @returns a new Mesh
  87861. */
  87862. 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;
  87863. /**
  87864. * Creates a tube mesh.
  87865. * The tube is a parametric shape.
  87866. * It has no predefined shape. Its final shape will depend on the input parameters.
  87867. * Please consider using the same method from the MeshBuilder class instead
  87868. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87869. * @param name defines the name of the mesh to create
  87870. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  87871. * @param radius sets the tube radius size
  87872. * @param tessellation is the number of sides on the tubular surface
  87873. * @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
  87874. * @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
  87875. * @param scene defines the hosting scene
  87876. * @param updatable defines if the mesh must be flagged as updatable
  87877. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87878. * @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)
  87879. * @returns a new Mesh
  87880. */
  87881. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  87882. (i: number, distance: number): number;
  87883. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87884. /**
  87885. * Creates a polyhedron mesh.
  87886. * Please consider using the same method from the MeshBuilder class instead.
  87887. * * 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
  87888. * * The parameter `size` (positive float, default 1) sets the polygon size
  87889. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  87890. * * 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`
  87891. * * 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
  87892. * * 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)`)
  87893. * * 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
  87894. * * 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
  87895. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87896. * * If you create a double-sided mesh, you can choose what parts of 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
  87897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87898. * @param name defines the name of the mesh to create
  87899. * @param options defines the options used to create the mesh
  87900. * @param scene defines the hosting scene
  87901. * @returns a new Mesh
  87902. */
  87903. static CreatePolyhedron(name: string, options: {
  87904. type?: number;
  87905. size?: number;
  87906. sizeX?: number;
  87907. sizeY?: number;
  87908. sizeZ?: number;
  87909. custom?: any;
  87910. faceUV?: Vector4[];
  87911. faceColors?: Color4[];
  87912. updatable?: boolean;
  87913. sideOrientation?: number;
  87914. }, scene: Scene): Mesh;
  87915. /**
  87916. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  87917. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  87918. * * 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`)
  87919. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  87920. * * 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
  87921. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87922. * * If you create a double-sided mesh, you can choose what parts of 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
  87923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87924. * @param name defines the name of the mesh
  87925. * @param options defines the options used to create the mesh
  87926. * @param scene defines the hosting scene
  87927. * @returns a new Mesh
  87928. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  87929. */
  87930. static CreateIcoSphere(name: string, options: {
  87931. radius?: number;
  87932. flat?: boolean;
  87933. subdivisions?: number;
  87934. sideOrientation?: number;
  87935. updatable?: boolean;
  87936. }, scene: Scene): Mesh;
  87937. /**
  87938. * Creates a decal mesh.
  87939. * Please consider using the same method from the MeshBuilder class instead.
  87940. * A decal is a mesh usually applied as a model onto the surface of another mesh
  87941. * @param name defines the name of the mesh
  87942. * @param sourceMesh defines the mesh receiving the decal
  87943. * @param position sets the position of the decal in world coordinates
  87944. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  87945. * @param size sets the decal scaling
  87946. * @param angle sets the angle to rotate the decal
  87947. * @returns a new Mesh
  87948. */
  87949. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  87950. /**
  87951. * Prepare internal position array for software CPU skinning
  87952. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  87953. */
  87954. setPositionsForCPUSkinning(): Float32Array;
  87955. /**
  87956. * Prepare internal normal array for software CPU skinning
  87957. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  87958. */
  87959. setNormalsForCPUSkinning(): Float32Array;
  87960. /**
  87961. * Updates the vertex buffer by applying transformation from the bones
  87962. * @param skeleton defines the skeleton to apply to current mesh
  87963. * @returns the current mesh
  87964. */
  87965. applySkeleton(skeleton: Skeleton): Mesh;
  87966. /**
  87967. * 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
  87968. * @param meshes defines the list of meshes to scan
  87969. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  87970. */
  87971. static MinMax(meshes: AbstractMesh[]): {
  87972. min: Vector3;
  87973. max: Vector3;
  87974. };
  87975. /**
  87976. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  87977. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  87978. * @returns a vector3
  87979. */
  87980. static Center(meshesOrMinMaxVector: {
  87981. min: Vector3;
  87982. max: Vector3;
  87983. } | AbstractMesh[]): Vector3;
  87984. /**
  87985. * Merge the array of meshes into a single mesh for performance reasons.
  87986. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  87987. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  87988. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  87989. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  87990. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  87991. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  87992. * @returns a new mesh
  87993. */
  87994. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  87995. /** @hidden */
  87996. addInstance(instance: InstancedMesh): void;
  87997. /** @hidden */
  87998. removeInstance(instance: InstancedMesh): void;
  87999. }
  88000. }
  88001. declare module BABYLON {
  88002. /**
  88003. * This is the base class of all the camera used in the application.
  88004. * @see http://doc.babylonjs.com/features/cameras
  88005. */
  88006. export class Camera extends Node {
  88007. /** @hidden */
  88008. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88009. /**
  88010. * This is the default projection mode used by the cameras.
  88011. * It helps recreating a feeling of perspective and better appreciate depth.
  88012. * This is the best way to simulate real life cameras.
  88013. */
  88014. static readonly PERSPECTIVE_CAMERA: number;
  88015. /**
  88016. * This helps creating camera with an orthographic mode.
  88017. * 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.
  88018. */
  88019. static readonly ORTHOGRAPHIC_CAMERA: number;
  88020. /**
  88021. * This is the default FOV mode for perspective cameras.
  88022. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88023. */
  88024. static readonly FOVMODE_VERTICAL_FIXED: number;
  88025. /**
  88026. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88027. */
  88028. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88029. /**
  88030. * This specifies ther is no need for a camera rig.
  88031. * Basically only one eye is rendered corresponding to the camera.
  88032. */
  88033. static readonly RIG_MODE_NONE: number;
  88034. /**
  88035. * Simulates a camera Rig with one blue eye and one red eye.
  88036. * This can be use with 3d blue and red glasses.
  88037. */
  88038. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88039. /**
  88040. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88041. */
  88042. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88043. /**
  88044. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88045. */
  88046. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88047. /**
  88048. * Defines that both eyes of the camera will be rendered over under each other.
  88049. */
  88050. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88051. /**
  88052. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88053. */
  88054. static readonly RIG_MODE_VR: number;
  88055. /**
  88056. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88057. */
  88058. static readonly RIG_MODE_WEBVR: number;
  88059. /**
  88060. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88061. */
  88062. static readonly RIG_MODE_CUSTOM: number;
  88063. /**
  88064. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88065. */
  88066. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88067. /**
  88068. * Define the input manager associated with the camera.
  88069. */
  88070. inputs: CameraInputsManager<Camera>;
  88071. /** @hidden */
  88072. _position: Vector3;
  88073. /**
  88074. * Define the current local position of the camera in the scene
  88075. */
  88076. position: Vector3;
  88077. /**
  88078. * The vector the camera should consider as up.
  88079. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88080. */
  88081. upVector: Vector3;
  88082. /**
  88083. * Define the current limit on the left side for an orthographic camera
  88084. * In scene unit
  88085. */
  88086. orthoLeft: Nullable<number>;
  88087. /**
  88088. * Define the current limit on the right side for an orthographic camera
  88089. * In scene unit
  88090. */
  88091. orthoRight: Nullable<number>;
  88092. /**
  88093. * Define the current limit on the bottom side for an orthographic camera
  88094. * In scene unit
  88095. */
  88096. orthoBottom: Nullable<number>;
  88097. /**
  88098. * Define the current limit on the top side for an orthographic camera
  88099. * In scene unit
  88100. */
  88101. orthoTop: Nullable<number>;
  88102. /**
  88103. * Field Of View is set in Radians. (default is 0.8)
  88104. */
  88105. fov: number;
  88106. /**
  88107. * Define the minimum distance the camera can see from.
  88108. * This is important to note that the depth buffer are not infinite and the closer it starts
  88109. * the more your scene might encounter depth fighting issue.
  88110. */
  88111. minZ: number;
  88112. /**
  88113. * Define the maximum distance the camera can see to.
  88114. * This is important to note that the depth buffer are not infinite and the further it end
  88115. * the more your scene might encounter depth fighting issue.
  88116. */
  88117. maxZ: number;
  88118. /**
  88119. * Define the default inertia of the camera.
  88120. * This helps giving a smooth feeling to the camera movement.
  88121. */
  88122. inertia: number;
  88123. /**
  88124. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  88125. */
  88126. mode: number;
  88127. /**
  88128. * Define wether the camera is intermediate.
  88129. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88130. */
  88131. isIntermediate: boolean;
  88132. /**
  88133. * Define the viewport of the camera.
  88134. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88135. */
  88136. viewport: Viewport;
  88137. /**
  88138. * Restricts the camera to viewing objects with the same layerMask.
  88139. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88140. */
  88141. layerMask: number;
  88142. /**
  88143. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88144. */
  88145. fovMode: number;
  88146. /**
  88147. * Rig mode of the camera.
  88148. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88149. * This is normally controlled byt the camera themselves as internal use.
  88150. */
  88151. cameraRigMode: number;
  88152. /**
  88153. * Defines the distance between both "eyes" in case of a RIG
  88154. */
  88155. interaxialDistance: number;
  88156. /**
  88157. * Defines if stereoscopic rendering is done side by side or over under.
  88158. */
  88159. isStereoscopicSideBySide: boolean;
  88160. /**
  88161. * 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
  88162. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88163. * else in the scene. (Eg. security camera)
  88164. *
  88165. * 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)
  88166. */
  88167. customRenderTargets: RenderTargetTexture[];
  88168. /**
  88169. * When set, the camera will render to this render target instead of the default canvas
  88170. *
  88171. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  88172. */
  88173. outputRenderTarget: Nullable<RenderTargetTexture>;
  88174. /**
  88175. * Observable triggered when the camera view matrix has changed.
  88176. */
  88177. onViewMatrixChangedObservable: Observable<Camera>;
  88178. /**
  88179. * Observable triggered when the camera Projection matrix has changed.
  88180. */
  88181. onProjectionMatrixChangedObservable: Observable<Camera>;
  88182. /**
  88183. * Observable triggered when the inputs have been processed.
  88184. */
  88185. onAfterCheckInputsObservable: Observable<Camera>;
  88186. /**
  88187. * Observable triggered when reset has been called and applied to the camera.
  88188. */
  88189. onRestoreStateObservable: Observable<Camera>;
  88190. /** @hidden */
  88191. _cameraRigParams: any;
  88192. /** @hidden */
  88193. _rigCameras: Camera[];
  88194. /** @hidden */
  88195. _rigPostProcess: Nullable<PostProcess>;
  88196. protected _webvrViewMatrix: Matrix;
  88197. /** @hidden */
  88198. _skipRendering: boolean;
  88199. /** @hidden */
  88200. _projectionMatrix: Matrix;
  88201. /** @hidden */
  88202. _postProcesses: Nullable<PostProcess>[];
  88203. /** @hidden */
  88204. _activeMeshes: SmartArray<AbstractMesh>;
  88205. protected _globalPosition: Vector3;
  88206. /** @hidden */
  88207. _computedViewMatrix: Matrix;
  88208. private _doNotComputeProjectionMatrix;
  88209. private _transformMatrix;
  88210. private _frustumPlanes;
  88211. private _refreshFrustumPlanes;
  88212. private _storedFov;
  88213. private _stateStored;
  88214. /**
  88215. * Instantiates a new camera object.
  88216. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88217. * @see http://doc.babylonjs.com/features/cameras
  88218. * @param name Defines the name of the camera in the scene
  88219. * @param position Defines the position of the camera
  88220. * @param scene Defines the scene the camera belongs too
  88221. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88222. */
  88223. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88224. /**
  88225. * Store current camera state (fov, position, etc..)
  88226. * @returns the camera
  88227. */
  88228. storeState(): Camera;
  88229. /**
  88230. * Restores the camera state values if it has been stored. You must call storeState() first
  88231. */
  88232. protected _restoreStateValues(): boolean;
  88233. /**
  88234. * Restored camera state. You must call storeState() first.
  88235. * @returns true if restored and false otherwise
  88236. */
  88237. restoreState(): boolean;
  88238. /**
  88239. * Gets the class name of the camera.
  88240. * @returns the class name
  88241. */
  88242. getClassName(): string;
  88243. /** @hidden */
  88244. readonly _isCamera: boolean;
  88245. /**
  88246. * Gets a string representation of the camera useful for debug purpose.
  88247. * @param fullDetails Defines that a more verboe level of logging is required
  88248. * @returns the string representation
  88249. */
  88250. toString(fullDetails?: boolean): string;
  88251. /**
  88252. * Gets the current world space position of the camera.
  88253. */
  88254. readonly globalPosition: Vector3;
  88255. /**
  88256. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88257. * @returns the active meshe list
  88258. */
  88259. getActiveMeshes(): SmartArray<AbstractMesh>;
  88260. /**
  88261. * Check wether a mesh is part of the current active mesh list of the camera
  88262. * @param mesh Defines the mesh to check
  88263. * @returns true if active, false otherwise
  88264. */
  88265. isActiveMesh(mesh: Mesh): boolean;
  88266. /**
  88267. * Is this camera ready to be used/rendered
  88268. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88269. * @return true if the camera is ready
  88270. */
  88271. isReady(completeCheck?: boolean): boolean;
  88272. /** @hidden */
  88273. _initCache(): void;
  88274. /** @hidden */
  88275. _updateCache(ignoreParentClass?: boolean): void;
  88276. /** @hidden */
  88277. _isSynchronized(): boolean;
  88278. /** @hidden */
  88279. _isSynchronizedViewMatrix(): boolean;
  88280. /** @hidden */
  88281. _isSynchronizedProjectionMatrix(): boolean;
  88282. /**
  88283. * Attach the input controls to a specific dom element to get the input from.
  88284. * @param element Defines the element the controls should be listened from
  88285. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88286. */
  88287. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88288. /**
  88289. * Detach the current controls from the specified dom element.
  88290. * @param element Defines the element to stop listening the inputs from
  88291. */
  88292. detachControl(element: HTMLElement): void;
  88293. /**
  88294. * Update the camera state according to the different inputs gathered during the frame.
  88295. */
  88296. update(): void;
  88297. /** @hidden */
  88298. _checkInputs(): void;
  88299. /** @hidden */
  88300. readonly rigCameras: Camera[];
  88301. /**
  88302. * Gets the post process used by the rig cameras
  88303. */
  88304. readonly rigPostProcess: Nullable<PostProcess>;
  88305. /**
  88306. * Internal, gets the first post proces.
  88307. * @returns the first post process to be run on this camera.
  88308. */
  88309. _getFirstPostProcess(): Nullable<PostProcess>;
  88310. private _cascadePostProcessesToRigCams;
  88311. /**
  88312. * Attach a post process to the camera.
  88313. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88314. * @param postProcess The post process to attach to the camera
  88315. * @param insertAt The position of the post process in case several of them are in use in the scene
  88316. * @returns the position the post process has been inserted at
  88317. */
  88318. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88319. /**
  88320. * Detach a post process to the camera.
  88321. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88322. * @param postProcess The post process to detach from the camera
  88323. */
  88324. detachPostProcess(postProcess: PostProcess): void;
  88325. /**
  88326. * Gets the current world matrix of the camera
  88327. */
  88328. getWorldMatrix(): Matrix;
  88329. /** @hidden */
  88330. _getViewMatrix(): Matrix;
  88331. /**
  88332. * Gets the current view matrix of the camera.
  88333. * @param force forces the camera to recompute the matrix without looking at the cached state
  88334. * @returns the view matrix
  88335. */
  88336. getViewMatrix(force?: boolean): Matrix;
  88337. /**
  88338. * Freeze the projection matrix.
  88339. * It will prevent the cache check of the camera projection compute and can speed up perf
  88340. * if no parameter of the camera are meant to change
  88341. * @param projection Defines manually a projection if necessary
  88342. */
  88343. freezeProjectionMatrix(projection?: Matrix): void;
  88344. /**
  88345. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88346. */
  88347. unfreezeProjectionMatrix(): void;
  88348. /**
  88349. * Gets the current projection matrix of the camera.
  88350. * @param force forces the camera to recompute the matrix without looking at the cached state
  88351. * @returns the projection matrix
  88352. */
  88353. getProjectionMatrix(force?: boolean): Matrix;
  88354. /**
  88355. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88356. * @returns a Matrix
  88357. */
  88358. getTransformationMatrix(): Matrix;
  88359. private _updateFrustumPlanes;
  88360. /**
  88361. * Checks if a cullable object (mesh...) is in the camera frustum
  88362. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88363. * @param target The object to check
  88364. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  88365. * @returns true if the object is in frustum otherwise false
  88366. */
  88367. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  88368. /**
  88369. * Checks if a cullable object (mesh...) is in the camera frustum
  88370. * Unlike isInFrustum this cheks the full bounding box
  88371. * @param target The object to check
  88372. * @returns true if the object is in frustum otherwise false
  88373. */
  88374. isCompletelyInFrustum(target: ICullable): boolean;
  88375. /**
  88376. * Gets a ray in the forward direction from the camera.
  88377. * @param length Defines the length of the ray to create
  88378. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88379. * @param origin Defines the start point of the ray which defaults to the camera position
  88380. * @returns the forward ray
  88381. */
  88382. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88383. /**
  88384. * Releases resources associated with this node.
  88385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88387. */
  88388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88389. /** @hidden */
  88390. _isLeftCamera: boolean;
  88391. /**
  88392. * Gets the left camera of a rig setup in case of Rigged Camera
  88393. */
  88394. readonly isLeftCamera: boolean;
  88395. /** @hidden */
  88396. _isRightCamera: boolean;
  88397. /**
  88398. * Gets the right camera of a rig setup in case of Rigged Camera
  88399. */
  88400. readonly isRightCamera: boolean;
  88401. /**
  88402. * Gets the left camera of a rig setup in case of Rigged Camera
  88403. */
  88404. readonly leftCamera: Nullable<FreeCamera>;
  88405. /**
  88406. * Gets the right camera of a rig setup in case of Rigged Camera
  88407. */
  88408. readonly rightCamera: Nullable<FreeCamera>;
  88409. /**
  88410. * Gets the left camera target of a rig setup in case of Rigged Camera
  88411. * @returns the target position
  88412. */
  88413. getLeftTarget(): Nullable<Vector3>;
  88414. /**
  88415. * Gets the right camera target of a rig setup in case of Rigged Camera
  88416. * @returns the target position
  88417. */
  88418. getRightTarget(): Nullable<Vector3>;
  88419. /**
  88420. * @hidden
  88421. */
  88422. setCameraRigMode(mode: number, rigParams: any): void;
  88423. /** @hidden */
  88424. static _setStereoscopicRigMode(camera: Camera): void;
  88425. /** @hidden */
  88426. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88427. /** @hidden */
  88428. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88429. /** @hidden */
  88430. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88431. /** @hidden */
  88432. _getVRProjectionMatrix(): Matrix;
  88433. protected _updateCameraRotationMatrix(): void;
  88434. protected _updateWebVRCameraRotationMatrix(): void;
  88435. /**
  88436. * This function MUST be overwritten by the different WebVR cameras available.
  88437. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88438. * @hidden
  88439. */
  88440. _getWebVRProjectionMatrix(): Matrix;
  88441. /**
  88442. * This function MUST be overwritten by the different WebVR cameras available.
  88443. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88444. * @hidden
  88445. */
  88446. _getWebVRViewMatrix(): Matrix;
  88447. /** @hidden */
  88448. setCameraRigParameter(name: string, value: any): void;
  88449. /**
  88450. * needs to be overridden by children so sub has required properties to be copied
  88451. * @hidden
  88452. */
  88453. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88454. /**
  88455. * May need to be overridden by children
  88456. * @hidden
  88457. */
  88458. _updateRigCameras(): void;
  88459. /** @hidden */
  88460. _setupInputs(): void;
  88461. /**
  88462. * Serialiaze the camera setup to a json represention
  88463. * @returns the JSON representation
  88464. */
  88465. serialize(): any;
  88466. /**
  88467. * Clones the current camera.
  88468. * @param name The cloned camera name
  88469. * @returns the cloned camera
  88470. */
  88471. clone(name: string): Camera;
  88472. /**
  88473. * Gets the direction of the camera relative to a given local axis.
  88474. * @param localAxis Defines the reference axis to provide a relative direction.
  88475. * @return the direction
  88476. */
  88477. getDirection(localAxis: Vector3): Vector3;
  88478. /**
  88479. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88480. * @param localAxis Defines the reference axis to provide a relative direction.
  88481. * @param result Defines the vector to store the result in
  88482. */
  88483. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88484. /**
  88485. * Gets a camera constructor for a given camera type
  88486. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88487. * @param name The name of the camera the result will be able to instantiate
  88488. * @param scene The scene the result will construct the camera in
  88489. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88490. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88491. * @returns a factory method to construc the camera
  88492. */
  88493. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88494. /**
  88495. * Compute the world matrix of the camera.
  88496. * @returns the camera workd matrix
  88497. */
  88498. computeWorldMatrix(): Matrix;
  88499. /**
  88500. * Parse a JSON and creates the camera from the parsed information
  88501. * @param parsedCamera The JSON to parse
  88502. * @param scene The scene to instantiate the camera in
  88503. * @returns the newly constructed camera
  88504. */
  88505. static Parse(parsedCamera: any, scene: Scene): Camera;
  88506. }
  88507. }
  88508. declare module BABYLON {
  88509. /**
  88510. * Class containing static functions to help procedurally build meshes
  88511. */
  88512. export class DiscBuilder {
  88513. /**
  88514. * Creates a plane polygonal mesh. By default, this is a disc
  88515. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88516. * * 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
  88517. * * 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
  88518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  88520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88521. * @param name defines the name of the mesh
  88522. * @param options defines the options used to create the mesh
  88523. * @param scene defines the hosting scene
  88524. * @returns the plane polygonal mesh
  88525. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88526. */
  88527. static CreateDisc(name: string, options: {
  88528. radius?: number;
  88529. tessellation?: number;
  88530. arc?: number;
  88531. updatable?: boolean;
  88532. sideOrientation?: number;
  88533. frontUVs?: Vector4;
  88534. backUVs?: Vector4;
  88535. }, scene?: Nullable<Scene>): Mesh;
  88536. }
  88537. }
  88538. declare module BABYLON {
  88539. /**
  88540. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  88541. *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.
  88542. * The SPS is also a particle system. It provides some methods to manage the particles.
  88543. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  88544. *
  88545. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  88546. */
  88547. export class SolidParticleSystem implements IDisposable {
  88548. /**
  88549. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  88550. * Example : var p = SPS.particles[i];
  88551. */
  88552. particles: SolidParticle[];
  88553. /**
  88554. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  88555. */
  88556. nbParticles: number;
  88557. /**
  88558. * If the particles must ever face the camera (default false). Useful for planar particles.
  88559. */
  88560. billboard: boolean;
  88561. /**
  88562. * Recompute normals when adding a shape
  88563. */
  88564. recomputeNormals: boolean;
  88565. /**
  88566. * This a counter ofr your own usage. It's not set by any SPS functions.
  88567. */
  88568. counter: number;
  88569. /**
  88570. * The SPS name. This name is also given to the underlying mesh.
  88571. */
  88572. name: string;
  88573. /**
  88574. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  88575. */
  88576. mesh: Mesh;
  88577. /**
  88578. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  88579. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  88580. */
  88581. vars: any;
  88582. /**
  88583. * This array is populated when the SPS is set as 'pickable'.
  88584. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  88585. * Each element of this array is an object `{idx: int, faceId: int}`.
  88586. * `idx` is the picked particle index in the `SPS.particles` array
  88587. * `faceId` is the picked face index counted within this particle.
  88588. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  88589. */
  88590. pickedParticles: {
  88591. idx: number;
  88592. faceId: number;
  88593. }[];
  88594. /**
  88595. * This array is populated when `enableDepthSort` is set to true.
  88596. * Each element of this array is an instance of the class DepthSortedParticle.
  88597. */
  88598. depthSortedParticles: DepthSortedParticle[];
  88599. /**
  88600. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  88601. * @hidden
  88602. */
  88603. _bSphereOnly: boolean;
  88604. /**
  88605. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  88606. * @hidden
  88607. */
  88608. _bSphereRadiusFactor: number;
  88609. private _scene;
  88610. private _positions;
  88611. private _indices;
  88612. private _normals;
  88613. private _colors;
  88614. private _uvs;
  88615. private _indices32;
  88616. private _positions32;
  88617. private _normals32;
  88618. private _fixedNormal32;
  88619. private _colors32;
  88620. private _uvs32;
  88621. private _index;
  88622. private _updatable;
  88623. private _pickable;
  88624. private _isVisibilityBoxLocked;
  88625. private _alwaysVisible;
  88626. private _depthSort;
  88627. private _shapeCounter;
  88628. private _copy;
  88629. private _color;
  88630. private _computeParticleColor;
  88631. private _computeParticleTexture;
  88632. private _computeParticleRotation;
  88633. private _computeParticleVertex;
  88634. private _computeBoundingBox;
  88635. private _depthSortParticles;
  88636. private _camera;
  88637. private _mustUnrotateFixedNormals;
  88638. private _particlesIntersect;
  88639. private _needs32Bits;
  88640. /**
  88641. * Creates a SPS (Solid Particle System) object.
  88642. * @param name (String) is the SPS name, this will be the underlying mesh name.
  88643. * @param scene (Scene) is the scene in which the SPS is added.
  88644. * @param options defines the options of the sps e.g.
  88645. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  88646. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  88647. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  88648. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  88649. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  88650. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  88651. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  88652. */
  88653. constructor(name: string, scene: Scene, options?: {
  88654. updatable?: boolean;
  88655. isPickable?: boolean;
  88656. enableDepthSort?: boolean;
  88657. particleIntersection?: boolean;
  88658. boundingSphereOnly?: boolean;
  88659. bSphereRadiusFactor?: number;
  88660. });
  88661. /**
  88662. * Builds the SPS underlying mesh. Returns a standard Mesh.
  88663. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  88664. * @returns the created mesh
  88665. */
  88666. buildMesh(): Mesh;
  88667. /**
  88668. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  88669. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  88670. * Thus the particles generated from `digest()` have their property `position` set yet.
  88671. * @param mesh ( Mesh ) is the mesh to be digested
  88672. * @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
  88673. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  88674. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  88675. * @returns the current SPS
  88676. */
  88677. digest(mesh: Mesh, options?: {
  88678. facetNb?: number;
  88679. number?: number;
  88680. delta?: number;
  88681. }): SolidParticleSystem;
  88682. private _unrotateFixedNormals;
  88683. private _resetCopy;
  88684. private _meshBuilder;
  88685. private _posToShape;
  88686. private _uvsToShapeUV;
  88687. private _addParticle;
  88688. /**
  88689. * Adds some particles to the SPS from the model shape. Returns the shape id.
  88690. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  88691. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  88692. * @param nb (positive integer) the number of particles to be created from this model
  88693. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  88694. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  88695. * @returns the number of shapes in the system
  88696. */
  88697. addShape(mesh: Mesh, nb: number, options?: {
  88698. positionFunction?: any;
  88699. vertexFunction?: any;
  88700. }): number;
  88701. private _rebuildParticle;
  88702. /**
  88703. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  88704. * @returns the SPS.
  88705. */
  88706. rebuildMesh(): SolidParticleSystem;
  88707. /**
  88708. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  88709. * This method calls `updateParticle()` for each particle of the SPS.
  88710. * For an animated SPS, it is usually called within the render loop.
  88711. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  88712. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  88713. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  88714. * @returns the SPS.
  88715. */
  88716. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  88717. /**
  88718. * Disposes the SPS.
  88719. */
  88720. dispose(): void;
  88721. /**
  88722. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  88723. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88724. * @returns the SPS.
  88725. */
  88726. refreshVisibleSize(): SolidParticleSystem;
  88727. /**
  88728. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  88729. * @param size the size (float) of the visibility box
  88730. * note : this doesn't lock the SPS mesh bounding box.
  88731. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88732. */
  88733. setVisibilityBox(size: number): void;
  88734. /**
  88735. * Gets whether the SPS as always visible or not
  88736. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88737. */
  88738. /**
  88739. * Sets the SPS as always visible or not
  88740. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88741. */
  88742. isAlwaysVisible: boolean;
  88743. /**
  88744. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  88745. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88746. */
  88747. /**
  88748. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  88749. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88750. */
  88751. isVisibilityBoxLocked: boolean;
  88752. /**
  88753. * Tells to `setParticles()` to compute the particle rotations or not.
  88754. * Default value : true. The SPS is faster when it's set to false.
  88755. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  88756. */
  88757. /**
  88758. * Gets if `setParticles()` computes the particle rotations or not.
  88759. * Default value : true. The SPS is faster when it's set to false.
  88760. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  88761. */
  88762. computeParticleRotation: boolean;
  88763. /**
  88764. * Tells to `setParticles()` to compute the particle colors or not.
  88765. * Default value : true. The SPS is faster when it's set to false.
  88766. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  88767. */
  88768. /**
  88769. * Gets if `setParticles()` computes the particle colors or not.
  88770. * Default value : true. The SPS is faster when it's set to false.
  88771. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  88772. */
  88773. computeParticleColor: boolean;
  88774. /**
  88775. * Gets if `setParticles()` computes the particle textures or not.
  88776. * Default value : true. The SPS is faster when it's set to false.
  88777. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  88778. */
  88779. computeParticleTexture: boolean;
  88780. /**
  88781. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  88782. * Default value : false. The SPS is faster when it's set to false.
  88783. * Note : the particle custom vertex positions aren't stored values.
  88784. */
  88785. /**
  88786. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  88787. * Default value : false. The SPS is faster when it's set to false.
  88788. * Note : the particle custom vertex positions aren't stored values.
  88789. */
  88790. computeParticleVertex: boolean;
  88791. /**
  88792. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  88793. */
  88794. /**
  88795. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  88796. */
  88797. computeBoundingBox: boolean;
  88798. /**
  88799. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  88800. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  88801. * Default : `true`
  88802. */
  88803. /**
  88804. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  88805. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  88806. * Default : `true`
  88807. */
  88808. depthSortParticles: boolean;
  88809. /**
  88810. * This function does nothing. It may be overwritten to set all the particle first values.
  88811. * The SPS doesn't call this function, you may have to call it by your own.
  88812. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  88813. */
  88814. initParticles(): void;
  88815. /**
  88816. * This function does nothing. It may be overwritten to recycle a particle.
  88817. * The SPS doesn't call this function, you may have to call it by your own.
  88818. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  88819. * @param particle The particle to recycle
  88820. * @returns the recycled particle
  88821. */
  88822. recycleParticle(particle: SolidParticle): SolidParticle;
  88823. /**
  88824. * Updates a particle : this function should be overwritten by the user.
  88825. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  88826. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  88827. * @example : just set a particle position or velocity and recycle conditions
  88828. * @param particle The particle to update
  88829. * @returns the updated particle
  88830. */
  88831. updateParticle(particle: SolidParticle): SolidParticle;
  88832. /**
  88833. * Updates a vertex of a particle : it can be overwritten by the user.
  88834. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  88835. * @param particle the current particle
  88836. * @param vertex the current index of the current particle
  88837. * @param pt the index of the current vertex in the particle shape
  88838. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  88839. * @example : just set a vertex particle position
  88840. * @returns the updated vertex
  88841. */
  88842. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  88843. /**
  88844. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  88845. * This does nothing and may be overwritten by the user.
  88846. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88847. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88848. * @param update the boolean update value actually passed to setParticles()
  88849. */
  88850. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  88851. /**
  88852. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  88853. * This will be passed three parameters.
  88854. * This does nothing and may be overwritten by the user.
  88855. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88856. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88857. * @param update the boolean update value actually passed to setParticles()
  88858. */
  88859. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  88860. }
  88861. }
  88862. declare module BABYLON {
  88863. /**
  88864. * Represents one particle of a solid particle system.
  88865. */
  88866. export class SolidParticle {
  88867. /**
  88868. * particle global index
  88869. */
  88870. idx: number;
  88871. /**
  88872. * The color of the particle
  88873. */
  88874. color: Nullable<Color4>;
  88875. /**
  88876. * The world space position of the particle.
  88877. */
  88878. position: Vector3;
  88879. /**
  88880. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  88881. */
  88882. rotation: Vector3;
  88883. /**
  88884. * The world space rotation quaternion of the particle.
  88885. */
  88886. rotationQuaternion: Nullable<Quaternion>;
  88887. /**
  88888. * The scaling of the particle.
  88889. */
  88890. scaling: Vector3;
  88891. /**
  88892. * The uvs of the particle.
  88893. */
  88894. uvs: Vector4;
  88895. /**
  88896. * The current speed of the particle.
  88897. */
  88898. velocity: Vector3;
  88899. /**
  88900. * The pivot point in the particle local space.
  88901. */
  88902. pivot: Vector3;
  88903. /**
  88904. * Must the particle be translated from its pivot point in its local space ?
  88905. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  88906. * Default : false
  88907. */
  88908. translateFromPivot: boolean;
  88909. /**
  88910. * Is the particle active or not ?
  88911. */
  88912. alive: boolean;
  88913. /**
  88914. * Is the particle visible or not ?
  88915. */
  88916. isVisible: boolean;
  88917. /**
  88918. * Index of this particle in the global "positions" array (Internal use)
  88919. * @hidden
  88920. */
  88921. _pos: number;
  88922. /**
  88923. * @hidden Index of this particle in the global "indices" array (Internal use)
  88924. */
  88925. _ind: number;
  88926. /**
  88927. * @hidden ModelShape of this particle (Internal use)
  88928. */
  88929. _model: ModelShape;
  88930. /**
  88931. * ModelShape id of this particle
  88932. */
  88933. shapeId: number;
  88934. /**
  88935. * Index of the particle in its shape id (Internal use)
  88936. */
  88937. idxInShape: number;
  88938. /**
  88939. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  88940. */
  88941. _modelBoundingInfo: BoundingInfo;
  88942. /**
  88943. * @hidden Particle BoundingInfo object (Internal use)
  88944. */
  88945. _boundingInfo: BoundingInfo;
  88946. /**
  88947. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  88948. */
  88949. _sps: SolidParticleSystem;
  88950. /**
  88951. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  88952. */
  88953. _stillInvisible: boolean;
  88954. /**
  88955. * @hidden Last computed particle rotation matrix
  88956. */
  88957. _rotationMatrix: number[];
  88958. /**
  88959. * Parent particle Id, if any.
  88960. * Default null.
  88961. */
  88962. parentId: Nullable<number>;
  88963. /**
  88964. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  88965. * The possible values are :
  88966. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  88967. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  88968. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  88969. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  88970. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  88971. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  88972. * */
  88973. cullingStrategy: number;
  88974. /**
  88975. * @hidden Internal global position in the SPS.
  88976. */
  88977. _globalPosition: Vector3;
  88978. /**
  88979. * Creates a Solid Particle object.
  88980. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  88981. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  88982. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  88983. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  88984. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  88985. * @param shapeId (integer) is the model shape identifier in the SPS.
  88986. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  88987. * @param sps defines the sps it is associated to
  88988. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  88989. */
  88990. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  88991. /**
  88992. * Legacy support, changed scale to scaling
  88993. */
  88994. /**
  88995. * Legacy support, changed scale to scaling
  88996. */
  88997. scale: Vector3;
  88998. /**
  88999. * Legacy support, changed quaternion to rotationQuaternion
  89000. */
  89001. /**
  89002. * Legacy support, changed quaternion to rotationQuaternion
  89003. */
  89004. quaternion: Nullable<Quaternion>;
  89005. /**
  89006. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89007. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89008. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89009. * @returns true if it intersects
  89010. */
  89011. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89012. /**
  89013. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89014. * A particle is in the frustum if its bounding box intersects the frustum
  89015. * @param frustumPlanes defines the frustum to test
  89016. * @returns true if the particle is in the frustum planes
  89017. */
  89018. isInFrustum(frustumPlanes: Plane[]): boolean;
  89019. /**
  89020. * get the rotation matrix of the particle
  89021. * @hidden
  89022. */
  89023. getRotationMatrix(m: Matrix): void;
  89024. }
  89025. /**
  89026. * Represents the shape of the model used by one particle of a solid particle system.
  89027. * SPS internal tool, don't use it manually.
  89028. */
  89029. export class ModelShape {
  89030. /**
  89031. * The shape id
  89032. * @hidden
  89033. */
  89034. shapeID: number;
  89035. /**
  89036. * flat array of model positions (internal use)
  89037. * @hidden
  89038. */
  89039. _shape: Vector3[];
  89040. /**
  89041. * flat array of model UVs (internal use)
  89042. * @hidden
  89043. */
  89044. _shapeUV: number[];
  89045. /**
  89046. * length of the shape in the model indices array (internal use)
  89047. * @hidden
  89048. */
  89049. _indicesLength: number;
  89050. /**
  89051. * Custom position function (internal use)
  89052. * @hidden
  89053. */
  89054. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89055. /**
  89056. * Custom vertex function (internal use)
  89057. * @hidden
  89058. */
  89059. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89060. /**
  89061. * 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.
  89062. * SPS internal tool, don't use it manually.
  89063. * @hidden
  89064. */
  89065. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  89066. }
  89067. /**
  89068. * Represents a Depth Sorted Particle in the solid particle system.
  89069. */
  89070. export class DepthSortedParticle {
  89071. /**
  89072. * Index of the particle in the "indices" array
  89073. */
  89074. ind: number;
  89075. /**
  89076. * Length of the particle shape in the "indices" array
  89077. */
  89078. indicesLength: number;
  89079. /**
  89080. * Squared distance from the particle to the camera
  89081. */
  89082. sqDistance: number;
  89083. }
  89084. }
  89085. declare module BABYLON {
  89086. /**
  89087. * @hidden
  89088. */
  89089. export class _MeshCollisionData {
  89090. _checkCollisions: boolean;
  89091. _collisionMask: number;
  89092. _collisionGroup: number;
  89093. _collider: Nullable<Collider>;
  89094. _oldPositionForCollisions: Vector3;
  89095. _diffPositionForCollisions: Vector3;
  89096. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  89097. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  89098. }
  89099. }
  89100. declare module BABYLON {
  89101. /** @hidden */
  89102. class _FacetDataStorage {
  89103. facetPositions: Vector3[];
  89104. facetNormals: Vector3[];
  89105. facetPartitioning: number[][];
  89106. facetNb: number;
  89107. partitioningSubdivisions: number;
  89108. partitioningBBoxRatio: number;
  89109. facetDataEnabled: boolean;
  89110. facetParameters: any;
  89111. bbSize: Vector3;
  89112. subDiv: {
  89113. max: number;
  89114. X: number;
  89115. Y: number;
  89116. Z: number;
  89117. };
  89118. facetDepthSort: boolean;
  89119. facetDepthSortEnabled: boolean;
  89120. depthSortedIndices: IndicesArray;
  89121. depthSortedFacets: {
  89122. ind: number;
  89123. sqDistance: number;
  89124. }[];
  89125. facetDepthSortFunction: (f1: {
  89126. ind: number;
  89127. sqDistance: number;
  89128. }, f2: {
  89129. ind: number;
  89130. sqDistance: number;
  89131. }) => number;
  89132. facetDepthSortFrom: Vector3;
  89133. facetDepthSortOrigin: Vector3;
  89134. invertedMatrix: Matrix;
  89135. }
  89136. /**
  89137. * @hidden
  89138. **/
  89139. class _InternalAbstractMeshDataInfo {
  89140. _hasVertexAlpha: boolean;
  89141. _useVertexColors: boolean;
  89142. _numBoneInfluencers: number;
  89143. _applyFog: boolean;
  89144. _receiveShadows: boolean;
  89145. _facetData: _FacetDataStorage;
  89146. _visibility: number;
  89147. _skeleton: Nullable<Skeleton>;
  89148. _layerMask: number;
  89149. _computeBonesUsingShaders: boolean;
  89150. _isActive: boolean;
  89151. _onlyForInstances: boolean;
  89152. _isActiveIntermediate: boolean;
  89153. _onlyForInstancesIntermediate: boolean;
  89154. }
  89155. /**
  89156. * Class used to store all common mesh properties
  89157. */
  89158. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  89159. /** No occlusion */
  89160. static OCCLUSION_TYPE_NONE: number;
  89161. /** Occlusion set to optimisitic */
  89162. static OCCLUSION_TYPE_OPTIMISTIC: number;
  89163. /** Occlusion set to strict */
  89164. static OCCLUSION_TYPE_STRICT: number;
  89165. /** Use an accurante occlusion algorithm */
  89166. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  89167. /** Use a conservative occlusion algorithm */
  89168. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  89169. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  89170. * Test order :
  89171. * Is the bounding sphere outside the frustum ?
  89172. * If not, are the bounding box vertices outside the frustum ?
  89173. * It not, then the cullable object is in the frustum.
  89174. */
  89175. static readonly CULLINGSTRATEGY_STANDARD: number;
  89176. /** Culling strategy : Bounding Sphere Only.
  89177. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  89178. * It's also less accurate than the standard because some not visible objects can still be selected.
  89179. * Test : is the bounding sphere outside the frustum ?
  89180. * If not, then the cullable object is in the frustum.
  89181. */
  89182. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  89183. /** Culling strategy : Optimistic Inclusion.
  89184. * This in an inclusion test first, then the standard exclusion test.
  89185. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  89186. * 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.
  89187. * Anyway, it's as accurate as the standard strategy.
  89188. * Test :
  89189. * Is the cullable object bounding sphere center in the frustum ?
  89190. * If not, apply the default culling strategy.
  89191. */
  89192. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  89193. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  89194. * This in an inclusion test first, then the bounding sphere only exclusion test.
  89195. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  89196. * 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.
  89197. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  89198. * Test :
  89199. * Is the cullable object bounding sphere center in the frustum ?
  89200. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  89201. */
  89202. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  89203. /**
  89204. * No billboard
  89205. */
  89206. static readonly BILLBOARDMODE_NONE: number;
  89207. /** Billboard on X axis */
  89208. static readonly BILLBOARDMODE_X: number;
  89209. /** Billboard on Y axis */
  89210. static readonly BILLBOARDMODE_Y: number;
  89211. /** Billboard on Z axis */
  89212. static readonly BILLBOARDMODE_Z: number;
  89213. /** Billboard on all axes */
  89214. static readonly BILLBOARDMODE_ALL: number;
  89215. /** @hidden */
  89216. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  89217. /**
  89218. * The culling strategy to use to check whether the mesh must be rendered or not.
  89219. * This value can be changed at any time and will be used on the next render mesh selection.
  89220. * The possible values are :
  89221. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89222. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89223. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89224. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89225. * Please read each static variable documentation to get details about the culling process.
  89226. * */
  89227. cullingStrategy: number;
  89228. /**
  89229. * Gets the number of facets in the mesh
  89230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89231. */
  89232. readonly facetNb: number;
  89233. /**
  89234. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  89235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89236. */
  89237. partitioningSubdivisions: number;
  89238. /**
  89239. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  89240. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  89241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89242. */
  89243. partitioningBBoxRatio: number;
  89244. /**
  89245. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  89246. * Works only for updatable meshes.
  89247. * Doesn't work with multi-materials
  89248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89249. */
  89250. mustDepthSortFacets: boolean;
  89251. /**
  89252. * The location (Vector3) where the facet depth sort must be computed from.
  89253. * By default, the active camera position.
  89254. * Used only when facet depth sort is enabled
  89255. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89256. */
  89257. facetDepthSortFrom: Vector3;
  89258. /**
  89259. * gets a boolean indicating if facetData is enabled
  89260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89261. */
  89262. readonly isFacetDataEnabled: boolean;
  89263. /** @hidden */
  89264. _updateNonUniformScalingState(value: boolean): boolean;
  89265. /**
  89266. * An event triggered when this mesh collides with another one
  89267. */
  89268. onCollideObservable: Observable<AbstractMesh>;
  89269. /** Set a function to call when this mesh collides with another one */
  89270. onCollide: () => void;
  89271. /**
  89272. * An event triggered when the collision's position changes
  89273. */
  89274. onCollisionPositionChangeObservable: Observable<Vector3>;
  89275. /** Set a function to call when the collision's position changes */
  89276. onCollisionPositionChange: () => void;
  89277. /**
  89278. * An event triggered when material is changed
  89279. */
  89280. onMaterialChangedObservable: Observable<AbstractMesh>;
  89281. /**
  89282. * Gets or sets the orientation for POV movement & rotation
  89283. */
  89284. definedFacingForward: boolean;
  89285. /** @hidden */
  89286. _occlusionQuery: Nullable<WebGLQuery>;
  89287. /** @hidden */
  89288. _renderingGroup: Nullable<RenderingGroup>;
  89289. /**
  89290. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89291. */
  89292. /**
  89293. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89294. */
  89295. visibility: number;
  89296. /** Gets or sets the alpha index used to sort transparent meshes
  89297. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  89298. */
  89299. alphaIndex: number;
  89300. /**
  89301. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  89302. */
  89303. isVisible: boolean;
  89304. /**
  89305. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89306. */
  89307. isPickable: boolean;
  89308. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  89309. showSubMeshesBoundingBox: boolean;
  89310. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  89311. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  89312. */
  89313. isBlocker: boolean;
  89314. /**
  89315. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  89316. */
  89317. enablePointerMoveEvents: boolean;
  89318. /**
  89319. * Specifies the rendering group id for this mesh (0 by default)
  89320. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89321. */
  89322. renderingGroupId: number;
  89323. private _material;
  89324. /** Gets or sets current material */
  89325. material: Nullable<Material>;
  89326. /**
  89327. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  89328. * @see http://doc.babylonjs.com/babylon101/shadows
  89329. */
  89330. receiveShadows: boolean;
  89331. /** Defines color to use when rendering outline */
  89332. outlineColor: Color3;
  89333. /** Define width to use when rendering outline */
  89334. outlineWidth: number;
  89335. /** Defines color to use when rendering overlay */
  89336. overlayColor: Color3;
  89337. /** Defines alpha to use when rendering overlay */
  89338. overlayAlpha: number;
  89339. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  89340. hasVertexAlpha: boolean;
  89341. /** 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) */
  89342. useVertexColors: boolean;
  89343. /**
  89344. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  89345. */
  89346. computeBonesUsingShaders: boolean;
  89347. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  89348. numBoneInfluencers: number;
  89349. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  89350. applyFog: boolean;
  89351. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  89352. useOctreeForRenderingSelection: boolean;
  89353. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  89354. useOctreeForPicking: boolean;
  89355. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  89356. useOctreeForCollisions: boolean;
  89357. /**
  89358. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  89359. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  89360. */
  89361. layerMask: number;
  89362. /**
  89363. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  89364. */
  89365. alwaysSelectAsActiveMesh: boolean;
  89366. /**
  89367. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  89368. */
  89369. doNotSyncBoundingInfo: boolean;
  89370. /**
  89371. * Gets or sets the current action manager
  89372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89373. */
  89374. actionManager: Nullable<AbstractActionManager>;
  89375. private _meshCollisionData;
  89376. /**
  89377. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  89378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89379. */
  89380. ellipsoid: Vector3;
  89381. /**
  89382. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  89383. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89384. */
  89385. ellipsoidOffset: Vector3;
  89386. /**
  89387. * Gets or sets a collision mask used to mask collisions (default is -1).
  89388. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89389. */
  89390. collisionMask: number;
  89391. /**
  89392. * Gets or sets the current collision group mask (-1 by default).
  89393. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89394. */
  89395. collisionGroup: number;
  89396. /**
  89397. * Defines edge width used when edgesRenderer is enabled
  89398. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89399. */
  89400. edgesWidth: number;
  89401. /**
  89402. * Defines edge color used when edgesRenderer is enabled
  89403. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89404. */
  89405. edgesColor: Color4;
  89406. /** @hidden */
  89407. _edgesRenderer: Nullable<IEdgesRenderer>;
  89408. /** @hidden */
  89409. _masterMesh: Nullable<AbstractMesh>;
  89410. /** @hidden */
  89411. _boundingInfo: Nullable<BoundingInfo>;
  89412. /** @hidden */
  89413. _renderId: number;
  89414. /**
  89415. * Gets or sets the list of subMeshes
  89416. * @see http://doc.babylonjs.com/how_to/multi_materials
  89417. */
  89418. subMeshes: SubMesh[];
  89419. /** @hidden */
  89420. _intersectionsInProgress: AbstractMesh[];
  89421. /** @hidden */
  89422. _unIndexed: boolean;
  89423. /** @hidden */
  89424. _lightSources: Light[];
  89425. /** Gets the list of lights affecting that mesh */
  89426. readonly lightSources: Light[];
  89427. /** @hidden */
  89428. readonly _positions: Nullable<Vector3[]>;
  89429. /** @hidden */
  89430. _waitingData: {
  89431. lods: Nullable<any>;
  89432. actions: Nullable<any>;
  89433. freezeWorldMatrix: Nullable<boolean>;
  89434. };
  89435. /** @hidden */
  89436. _bonesTransformMatrices: Nullable<Float32Array>;
  89437. /** @hidden */
  89438. _transformMatrixTexture: Nullable<RawTexture>;
  89439. /**
  89440. * Gets or sets a skeleton to apply skining transformations
  89441. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89442. */
  89443. skeleton: Nullable<Skeleton>;
  89444. /**
  89445. * An event triggered when the mesh is rebuilt.
  89446. */
  89447. onRebuildObservable: Observable<AbstractMesh>;
  89448. /**
  89449. * Creates a new AbstractMesh
  89450. * @param name defines the name of the mesh
  89451. * @param scene defines the hosting scene
  89452. */
  89453. constructor(name: string, scene?: Nullable<Scene>);
  89454. /**
  89455. * Returns the string "AbstractMesh"
  89456. * @returns "AbstractMesh"
  89457. */
  89458. getClassName(): string;
  89459. /**
  89460. * Gets a string representation of the current mesh
  89461. * @param fullDetails defines a boolean indicating if full details must be included
  89462. * @returns a string representation of the current mesh
  89463. */
  89464. toString(fullDetails?: boolean): string;
  89465. /**
  89466. * @hidden
  89467. */
  89468. protected _getEffectiveParent(): Nullable<Node>;
  89469. /** @hidden */
  89470. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  89471. /** @hidden */
  89472. _rebuild(): void;
  89473. /** @hidden */
  89474. _resyncLightSources(): void;
  89475. /** @hidden */
  89476. _resyncLighSource(light: Light): void;
  89477. /** @hidden */
  89478. _unBindEffect(): void;
  89479. /** @hidden */
  89480. _removeLightSource(light: Light): void;
  89481. private _markSubMeshesAsDirty;
  89482. /** @hidden */
  89483. _markSubMeshesAsLightDirty(): void;
  89484. /** @hidden */
  89485. _markSubMeshesAsAttributesDirty(): void;
  89486. /** @hidden */
  89487. _markSubMeshesAsMiscDirty(): void;
  89488. /**
  89489. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  89490. */
  89491. scaling: Vector3;
  89492. /**
  89493. * Returns true if the mesh is blocked. Implemented by child classes
  89494. */
  89495. readonly isBlocked: boolean;
  89496. /**
  89497. * Returns the mesh itself by default. Implemented by child classes
  89498. * @param camera defines the camera to use to pick the right LOD level
  89499. * @returns the currentAbstractMesh
  89500. */
  89501. getLOD(camera: Camera): Nullable<AbstractMesh>;
  89502. /**
  89503. * Returns 0 by default. Implemented by child classes
  89504. * @returns an integer
  89505. */
  89506. getTotalVertices(): number;
  89507. /**
  89508. * Returns a positive integer : the total number of indices in this mesh geometry.
  89509. * @returns the numner of indices or zero if the mesh has no geometry.
  89510. */
  89511. getTotalIndices(): number;
  89512. /**
  89513. * Returns null by default. Implemented by child classes
  89514. * @returns null
  89515. */
  89516. getIndices(): Nullable<IndicesArray>;
  89517. /**
  89518. * Returns the array of the requested vertex data kind. Implemented by child classes
  89519. * @param kind defines the vertex data kind to use
  89520. * @returns null
  89521. */
  89522. getVerticesData(kind: string): Nullable<FloatArray>;
  89523. /**
  89524. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89525. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89526. * Note that a new underlying VertexBuffer object is created each call.
  89527. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89528. * @param kind defines vertex data kind:
  89529. * * VertexBuffer.PositionKind
  89530. * * VertexBuffer.UVKind
  89531. * * VertexBuffer.UV2Kind
  89532. * * VertexBuffer.UV3Kind
  89533. * * VertexBuffer.UV4Kind
  89534. * * VertexBuffer.UV5Kind
  89535. * * VertexBuffer.UV6Kind
  89536. * * VertexBuffer.ColorKind
  89537. * * VertexBuffer.MatricesIndicesKind
  89538. * * VertexBuffer.MatricesIndicesExtraKind
  89539. * * VertexBuffer.MatricesWeightsKind
  89540. * * VertexBuffer.MatricesWeightsExtraKind
  89541. * @param data defines the data source
  89542. * @param updatable defines if the data must be flagged as updatable (or static)
  89543. * @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
  89544. * @returns the current mesh
  89545. */
  89546. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89547. /**
  89548. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89549. * If the mesh has no geometry, it is simply returned as it is.
  89550. * @param kind defines vertex data kind:
  89551. * * VertexBuffer.PositionKind
  89552. * * VertexBuffer.UVKind
  89553. * * VertexBuffer.UV2Kind
  89554. * * VertexBuffer.UV3Kind
  89555. * * VertexBuffer.UV4Kind
  89556. * * VertexBuffer.UV5Kind
  89557. * * VertexBuffer.UV6Kind
  89558. * * VertexBuffer.ColorKind
  89559. * * VertexBuffer.MatricesIndicesKind
  89560. * * VertexBuffer.MatricesIndicesExtraKind
  89561. * * VertexBuffer.MatricesWeightsKind
  89562. * * VertexBuffer.MatricesWeightsExtraKind
  89563. * @param data defines the data source
  89564. * @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
  89565. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  89566. * @returns the current mesh
  89567. */
  89568. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89569. /**
  89570. * Sets the mesh indices,
  89571. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89572. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  89573. * @param totalVertices Defines the total number of vertices
  89574. * @returns the current mesh
  89575. */
  89576. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  89577. /**
  89578. * Gets a boolean indicating if specific vertex data is present
  89579. * @param kind defines the vertex data kind to use
  89580. * @returns true is data kind is present
  89581. */
  89582. isVerticesDataPresent(kind: string): boolean;
  89583. /**
  89584. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  89585. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  89586. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  89587. * @returns a BoundingInfo
  89588. */
  89589. getBoundingInfo(): BoundingInfo;
  89590. /**
  89591. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89592. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89593. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89594. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89595. * @returns the current mesh
  89596. */
  89597. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  89598. /**
  89599. * Overwrite the current bounding info
  89600. * @param boundingInfo defines the new bounding info
  89601. * @returns the current mesh
  89602. */
  89603. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  89604. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  89605. readonly useBones: boolean;
  89606. /** @hidden */
  89607. _preActivate(): void;
  89608. /** @hidden */
  89609. _preActivateForIntermediateRendering(renderId: number): void;
  89610. /** @hidden */
  89611. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89612. /** @hidden */
  89613. _postActivate(): void;
  89614. /** @hidden */
  89615. _freeze(): void;
  89616. /** @hidden */
  89617. _unFreeze(): void;
  89618. /**
  89619. * Gets the current world matrix
  89620. * @returns a Matrix
  89621. */
  89622. getWorldMatrix(): Matrix;
  89623. /** @hidden */
  89624. _getWorldMatrixDeterminant(): number;
  89625. /**
  89626. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  89627. */
  89628. readonly isAnInstance: boolean;
  89629. /**
  89630. * Perform relative position change from the point of view of behind the front of the mesh.
  89631. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89632. * Supports definition of mesh facing forward or backward
  89633. * @param amountRight defines the distance on the right axis
  89634. * @param amountUp defines the distance on the up axis
  89635. * @param amountForward defines the distance on the forward axis
  89636. * @returns the current mesh
  89637. */
  89638. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  89639. /**
  89640. * Calculate relative position change from the point of view of behind the front of the mesh.
  89641. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89642. * Supports definition of mesh facing forward or backward
  89643. * @param amountRight defines the distance on the right axis
  89644. * @param amountUp defines the distance on the up axis
  89645. * @param amountForward defines the distance on the forward axis
  89646. * @returns the new displacement vector
  89647. */
  89648. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  89649. /**
  89650. * Perform relative rotation change from the point of view of behind the front of the mesh.
  89651. * Supports definition of mesh facing forward or backward
  89652. * @param flipBack defines the flip
  89653. * @param twirlClockwise defines the twirl
  89654. * @param tiltRight defines the tilt
  89655. * @returns the current mesh
  89656. */
  89657. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  89658. /**
  89659. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  89660. * Supports definition of mesh facing forward or backward.
  89661. * @param flipBack defines the flip
  89662. * @param twirlClockwise defines the twirl
  89663. * @param tiltRight defines the tilt
  89664. * @returns the new rotation vector
  89665. */
  89666. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  89667. /**
  89668. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89669. * This means the mesh underlying bounding box and sphere are recomputed.
  89670. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89671. * @returns the current mesh
  89672. */
  89673. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  89674. /** @hidden */
  89675. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  89676. /** @hidden */
  89677. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  89678. /** @hidden */
  89679. _updateBoundingInfo(): AbstractMesh;
  89680. /** @hidden */
  89681. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  89682. /** @hidden */
  89683. protected _afterComputeWorldMatrix(): void;
  89684. /** @hidden */
  89685. readonly _effectiveMesh: AbstractMesh;
  89686. /**
  89687. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89688. * A mesh is in the frustum if its bounding box intersects the frustum
  89689. * @param frustumPlanes defines the frustum to test
  89690. * @returns true if the mesh is in the frustum planes
  89691. */
  89692. isInFrustum(frustumPlanes: Plane[]): boolean;
  89693. /**
  89694. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  89695. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  89696. * @param frustumPlanes defines the frustum to test
  89697. * @returns true if the mesh is completely in the frustum planes
  89698. */
  89699. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89700. /**
  89701. * True if the mesh intersects another mesh or a SolidParticle object
  89702. * @param mesh defines a target mesh or SolidParticle to test
  89703. * @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)
  89704. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  89705. * @returns true if there is an intersection
  89706. */
  89707. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  89708. /**
  89709. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  89710. * @param point defines the point to test
  89711. * @returns true if there is an intersection
  89712. */
  89713. intersectsPoint(point: Vector3): boolean;
  89714. /**
  89715. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  89716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89717. */
  89718. checkCollisions: boolean;
  89719. /**
  89720. * Gets Collider object used to compute collisions (not physics)
  89721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89722. */
  89723. readonly collider: Nullable<Collider>;
  89724. /**
  89725. * Move the mesh using collision engine
  89726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89727. * @param displacement defines the requested displacement vector
  89728. * @returns the current mesh
  89729. */
  89730. moveWithCollisions(displacement: Vector3): AbstractMesh;
  89731. private _onCollisionPositionChange;
  89732. /** @hidden */
  89733. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  89734. /** @hidden */
  89735. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  89736. /** @hidden */
  89737. _checkCollision(collider: Collider): AbstractMesh;
  89738. /** @hidden */
  89739. _generatePointsArray(): boolean;
  89740. /**
  89741. * Checks if the passed Ray intersects with the mesh
  89742. * @param ray defines the ray to use
  89743. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  89744. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89745. * @returns the picking info
  89746. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89747. */
  89748. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  89749. /**
  89750. * Clones the current mesh
  89751. * @param name defines the mesh name
  89752. * @param newParent defines the new mesh parent
  89753. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  89754. * @returns the new mesh
  89755. */
  89756. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89757. /**
  89758. * Disposes all the submeshes of the current meshnp
  89759. * @returns the current mesh
  89760. */
  89761. releaseSubMeshes(): AbstractMesh;
  89762. /**
  89763. * Releases resources associated with this abstract mesh.
  89764. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89765. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89766. */
  89767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89768. /**
  89769. * Adds the passed mesh as a child to the current mesh
  89770. * @param mesh defines the child mesh
  89771. * @returns the current mesh
  89772. */
  89773. addChild(mesh: AbstractMesh): AbstractMesh;
  89774. /**
  89775. * Removes the passed mesh from the current mesh children list
  89776. * @param mesh defines the child mesh
  89777. * @returns the current mesh
  89778. */
  89779. removeChild(mesh: AbstractMesh): AbstractMesh;
  89780. /** @hidden */
  89781. private _initFacetData;
  89782. /**
  89783. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  89784. * This method can be called within the render loop.
  89785. * 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
  89786. * @returns the current mesh
  89787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89788. */
  89789. updateFacetData(): AbstractMesh;
  89790. /**
  89791. * Returns the facetLocalNormals array.
  89792. * The normals are expressed in the mesh local spac
  89793. * @returns an array of Vector3
  89794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89795. */
  89796. getFacetLocalNormals(): Vector3[];
  89797. /**
  89798. * Returns the facetLocalPositions array.
  89799. * The facet positions are expressed in the mesh local space
  89800. * @returns an array of Vector3
  89801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89802. */
  89803. getFacetLocalPositions(): Vector3[];
  89804. /**
  89805. * Returns the facetLocalPartioning array
  89806. * @returns an array of array of numbers
  89807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89808. */
  89809. getFacetLocalPartitioning(): number[][];
  89810. /**
  89811. * Returns the i-th facet position in the world system.
  89812. * This method allocates a new Vector3 per call
  89813. * @param i defines the facet index
  89814. * @returns a new Vector3
  89815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89816. */
  89817. getFacetPosition(i: number): Vector3;
  89818. /**
  89819. * Sets the reference Vector3 with the i-th facet position in the world system
  89820. * @param i defines the facet index
  89821. * @param ref defines the target vector
  89822. * @returns the current mesh
  89823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89824. */
  89825. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  89826. /**
  89827. * Returns the i-th facet normal in the world system.
  89828. * This method allocates a new Vector3 per call
  89829. * @param i defines the facet index
  89830. * @returns a new Vector3
  89831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89832. */
  89833. getFacetNormal(i: number): Vector3;
  89834. /**
  89835. * Sets the reference Vector3 with the i-th facet normal in the world system
  89836. * @param i defines the facet index
  89837. * @param ref defines the target vector
  89838. * @returns the current mesh
  89839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89840. */
  89841. getFacetNormalToRef(i: number, ref: Vector3): this;
  89842. /**
  89843. * 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)
  89844. * @param x defines x coordinate
  89845. * @param y defines y coordinate
  89846. * @param z defines z coordinate
  89847. * @returns the array of facet indexes
  89848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89849. */
  89850. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  89851. /**
  89852. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  89853. * @param projected sets as the (x,y,z) world projection on the facet
  89854. * @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
  89855. * @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
  89856. * @param x defines x coordinate
  89857. * @param y defines y coordinate
  89858. * @param z defines z coordinate
  89859. * @returns the face index if found (or null instead)
  89860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89861. */
  89862. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  89863. /**
  89864. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  89865. * @param projected sets as the (x,y,z) local projection on the facet
  89866. * @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
  89867. * @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
  89868. * @param x defines x coordinate
  89869. * @param y defines y coordinate
  89870. * @param z defines z coordinate
  89871. * @returns the face index if found (or null instead)
  89872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89873. */
  89874. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  89875. /**
  89876. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  89877. * @returns the parameters
  89878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89879. */
  89880. getFacetDataParameters(): any;
  89881. /**
  89882. * Disables the feature FacetData and frees the related memory
  89883. * @returns the current mesh
  89884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89885. */
  89886. disableFacetData(): AbstractMesh;
  89887. /**
  89888. * Updates the AbstractMesh indices array
  89889. * @param indices defines the data source
  89890. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89891. * @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)
  89892. * @returns the current mesh
  89893. */
  89894. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89895. /**
  89896. * Creates new normals data for the mesh
  89897. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  89898. * @returns the current mesh
  89899. */
  89900. createNormals(updatable: boolean): AbstractMesh;
  89901. /**
  89902. * Align the mesh with a normal
  89903. * @param normal defines the normal to use
  89904. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  89905. * @returns the current mesh
  89906. */
  89907. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  89908. /** @hidden */
  89909. _checkOcclusionQuery(): boolean;
  89910. /**
  89911. * Disables the mesh edge rendering mode
  89912. * @returns the currentAbstractMesh
  89913. */
  89914. disableEdgesRendering(): AbstractMesh;
  89915. /**
  89916. * Enables the edge rendering mode on the mesh.
  89917. * This mode makes the mesh edges visible
  89918. * @param epsilon defines the maximal distance between two angles to detect a face
  89919. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89920. * @returns the currentAbstractMesh
  89921. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89922. */
  89923. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89924. }
  89925. }
  89926. declare module BABYLON {
  89927. /**
  89928. * Interface used to define ActionEvent
  89929. */
  89930. export interface IActionEvent {
  89931. /** The mesh or sprite that triggered the action */
  89932. source: any;
  89933. /** The X mouse cursor position at the time of the event */
  89934. pointerX: number;
  89935. /** The Y mouse cursor position at the time of the event */
  89936. pointerY: number;
  89937. /** The mesh that is currently pointed at (can be null) */
  89938. meshUnderPointer: Nullable<AbstractMesh>;
  89939. /** the original (browser) event that triggered the ActionEvent */
  89940. sourceEvent?: any;
  89941. /** additional data for the event */
  89942. additionalData?: any;
  89943. }
  89944. /**
  89945. * ActionEvent is the event being sent when an action is triggered.
  89946. */
  89947. export class ActionEvent implements IActionEvent {
  89948. /** The mesh or sprite that triggered the action */
  89949. source: any;
  89950. /** The X mouse cursor position at the time of the event */
  89951. pointerX: number;
  89952. /** The Y mouse cursor position at the time of the event */
  89953. pointerY: number;
  89954. /** The mesh that is currently pointed at (can be null) */
  89955. meshUnderPointer: Nullable<AbstractMesh>;
  89956. /** the original (browser) event that triggered the ActionEvent */
  89957. sourceEvent?: any;
  89958. /** additional data for the event */
  89959. additionalData?: any;
  89960. /**
  89961. * Creates a new ActionEvent
  89962. * @param source The mesh or sprite that triggered the action
  89963. * @param pointerX The X mouse cursor position at the time of the event
  89964. * @param pointerY The Y mouse cursor position at the time of the event
  89965. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  89966. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  89967. * @param additionalData additional data for the event
  89968. */
  89969. constructor(
  89970. /** The mesh or sprite that triggered the action */
  89971. source: any,
  89972. /** The X mouse cursor position at the time of the event */
  89973. pointerX: number,
  89974. /** The Y mouse cursor position at the time of the event */
  89975. pointerY: number,
  89976. /** The mesh that is currently pointed at (can be null) */
  89977. meshUnderPointer: Nullable<AbstractMesh>,
  89978. /** the original (browser) event that triggered the ActionEvent */
  89979. sourceEvent?: any,
  89980. /** additional data for the event */
  89981. additionalData?: any);
  89982. /**
  89983. * Helper function to auto-create an ActionEvent from a source mesh.
  89984. * @param source The source mesh that triggered the event
  89985. * @param evt The original (browser) event
  89986. * @param additionalData additional data for the event
  89987. * @returns the new ActionEvent
  89988. */
  89989. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  89990. /**
  89991. * Helper function to auto-create an ActionEvent from a source sprite
  89992. * @param source The source sprite that triggered the event
  89993. * @param scene Scene associated with the sprite
  89994. * @param evt The original (browser) event
  89995. * @param additionalData additional data for the event
  89996. * @returns the new ActionEvent
  89997. */
  89998. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  89999. /**
  90000. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90001. * @param scene the scene where the event occurred
  90002. * @param evt The original (browser) event
  90003. * @returns the new ActionEvent
  90004. */
  90005. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90006. /**
  90007. * Helper function to auto-create an ActionEvent from a primitive
  90008. * @param prim defines the target primitive
  90009. * @param pointerPos defines the pointer position
  90010. * @param evt The original (browser) event
  90011. * @param additionalData additional data for the event
  90012. * @returns the new ActionEvent
  90013. */
  90014. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90015. }
  90016. }
  90017. declare module BABYLON {
  90018. /**
  90019. * Abstract class used to decouple action Manager from scene and meshes.
  90020. * Do not instantiate.
  90021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90022. */
  90023. export abstract class AbstractActionManager implements IDisposable {
  90024. /** Gets the list of active triggers */
  90025. static Triggers: {
  90026. [key: string]: number;
  90027. };
  90028. /** Gets the cursor to use when hovering items */
  90029. hoverCursor: string;
  90030. /** Gets the list of actions */
  90031. actions: IAction[];
  90032. /**
  90033. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90034. */
  90035. isRecursive: boolean;
  90036. /**
  90037. * Releases all associated resources
  90038. */
  90039. abstract dispose(): void;
  90040. /**
  90041. * Does this action manager has pointer triggers
  90042. */
  90043. abstract readonly hasPointerTriggers: boolean;
  90044. /**
  90045. * Does this action manager has pick triggers
  90046. */
  90047. abstract readonly hasPickTriggers: boolean;
  90048. /**
  90049. * Process a specific trigger
  90050. * @param trigger defines the trigger to process
  90051. * @param evt defines the event details to be processed
  90052. */
  90053. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90054. /**
  90055. * Does this action manager handles actions of any of the given triggers
  90056. * @param triggers defines the triggers to be tested
  90057. * @return a boolean indicating whether one (or more) of the triggers is handled
  90058. */
  90059. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90060. /**
  90061. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90062. * speed.
  90063. * @param triggerA defines the trigger to be tested
  90064. * @param triggerB defines the trigger to be tested
  90065. * @return a boolean indicating whether one (or more) of the triggers is handled
  90066. */
  90067. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90068. /**
  90069. * Does this action manager handles actions of a given trigger
  90070. * @param trigger defines the trigger to be tested
  90071. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90072. * @return whether the trigger is handled
  90073. */
  90074. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90075. /**
  90076. * Serialize this manager to a JSON object
  90077. * @param name defines the property name to store this manager
  90078. * @returns a JSON representation of this manager
  90079. */
  90080. abstract serialize(name: string): any;
  90081. /**
  90082. * Registers an action to this action manager
  90083. * @param action defines the action to be registered
  90084. * @return the action amended (prepared) after registration
  90085. */
  90086. abstract registerAction(action: IAction): Nullable<IAction>;
  90087. /**
  90088. * Unregisters an action to this action manager
  90089. * @param action defines the action to be unregistered
  90090. * @return a boolean indicating whether the action has been unregistered
  90091. */
  90092. abstract unregisterAction(action: IAction): Boolean;
  90093. /**
  90094. * Does exist one action manager with at least one trigger
  90095. **/
  90096. static readonly HasTriggers: boolean;
  90097. /**
  90098. * Does exist one action manager with at least one pick trigger
  90099. **/
  90100. static readonly HasPickTriggers: boolean;
  90101. /**
  90102. * Does exist one action manager that handles actions of a given trigger
  90103. * @param trigger defines the trigger to be tested
  90104. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  90105. **/
  90106. static HasSpecificTrigger(trigger: number): boolean;
  90107. }
  90108. }
  90109. declare module BABYLON {
  90110. /**
  90111. * Defines how a node can be built from a string name.
  90112. */
  90113. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  90114. /**
  90115. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  90116. */
  90117. export class Node implements IBehaviorAware<Node> {
  90118. /** @hidden */
  90119. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  90120. private static _NodeConstructors;
  90121. /**
  90122. * Add a new node constructor
  90123. * @param type defines the type name of the node to construct
  90124. * @param constructorFunc defines the constructor function
  90125. */
  90126. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  90127. /**
  90128. * Returns a node constructor based on type name
  90129. * @param type defines the type name
  90130. * @param name defines the new node name
  90131. * @param scene defines the hosting scene
  90132. * @param options defines optional options to transmit to constructors
  90133. * @returns the new constructor or null
  90134. */
  90135. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  90136. /**
  90137. * Gets or sets the name of the node
  90138. */
  90139. name: string;
  90140. /**
  90141. * Gets or sets the id of the node
  90142. */
  90143. id: string;
  90144. /**
  90145. * Gets or sets the unique id of the node
  90146. */
  90147. uniqueId: number;
  90148. /**
  90149. * Gets or sets a string used to store user defined state for the node
  90150. */
  90151. state: string;
  90152. /**
  90153. * Gets or sets an object used to store user defined information for the node
  90154. */
  90155. metadata: any;
  90156. /**
  90157. * For internal use only. Please do not use.
  90158. */
  90159. reservedDataStore: any;
  90160. /**
  90161. * List of inspectable custom properties (used by the Inspector)
  90162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90163. */
  90164. inspectableCustomProperties: IInspectable[];
  90165. /**
  90166. * Gets or sets a boolean used to define if the node must be serialized
  90167. */
  90168. doNotSerialize: boolean;
  90169. /** @hidden */
  90170. _isDisposed: boolean;
  90171. /**
  90172. * Gets a list of Animations associated with the node
  90173. */
  90174. animations: Animation[];
  90175. protected _ranges: {
  90176. [name: string]: Nullable<AnimationRange>;
  90177. };
  90178. /**
  90179. * Callback raised when the node is ready to be used
  90180. */
  90181. onReady: Nullable<(node: Node) => void>;
  90182. private _isEnabled;
  90183. private _isParentEnabled;
  90184. private _isReady;
  90185. /** @hidden */
  90186. _currentRenderId: number;
  90187. private _parentUpdateId;
  90188. /** @hidden */
  90189. _childUpdateId: number;
  90190. /** @hidden */
  90191. _waitingParentId: Nullable<string>;
  90192. /** @hidden */
  90193. _scene: Scene;
  90194. /** @hidden */
  90195. _cache: any;
  90196. private _parentNode;
  90197. private _children;
  90198. /** @hidden */
  90199. _worldMatrix: Matrix;
  90200. /** @hidden */
  90201. _worldMatrixDeterminant: number;
  90202. /** @hidden */
  90203. _worldMatrixDeterminantIsDirty: boolean;
  90204. /** @hidden */
  90205. private _sceneRootNodesIndex;
  90206. /**
  90207. * Gets a boolean indicating if the node has been disposed
  90208. * @returns true if the node was disposed
  90209. */
  90210. isDisposed(): boolean;
  90211. /**
  90212. * Gets or sets the parent of the node (without keeping the current position in the scene)
  90213. * @see https://doc.babylonjs.com/how_to/parenting
  90214. */
  90215. parent: Nullable<Node>;
  90216. private addToSceneRootNodes;
  90217. private removeFromSceneRootNodes;
  90218. private _animationPropertiesOverride;
  90219. /**
  90220. * Gets or sets the animation properties override
  90221. */
  90222. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90223. /**
  90224. * Gets a string idenfifying the name of the class
  90225. * @returns "Node" string
  90226. */
  90227. getClassName(): string;
  90228. /** @hidden */
  90229. readonly _isNode: boolean;
  90230. /**
  90231. * An event triggered when the mesh is disposed
  90232. */
  90233. onDisposeObservable: Observable<Node>;
  90234. private _onDisposeObserver;
  90235. /**
  90236. * Sets a callback that will be raised when the node will be disposed
  90237. */
  90238. onDispose: () => void;
  90239. /**
  90240. * Creates a new Node
  90241. * @param name the name and id to be given to this node
  90242. * @param scene the scene this node will be added to
  90243. * @param addToRootNodes the node will be added to scene.rootNodes
  90244. */
  90245. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  90246. /**
  90247. * Gets the scene of the node
  90248. * @returns a scene
  90249. */
  90250. getScene(): Scene;
  90251. /**
  90252. * Gets the engine of the node
  90253. * @returns a Engine
  90254. */
  90255. getEngine(): Engine;
  90256. private _behaviors;
  90257. /**
  90258. * Attach a behavior to the node
  90259. * @see http://doc.babylonjs.com/features/behaviour
  90260. * @param behavior defines the behavior to attach
  90261. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  90262. * @returns the current Node
  90263. */
  90264. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  90265. /**
  90266. * Remove an attached behavior
  90267. * @see http://doc.babylonjs.com/features/behaviour
  90268. * @param behavior defines the behavior to attach
  90269. * @returns the current Node
  90270. */
  90271. removeBehavior(behavior: Behavior<Node>): Node;
  90272. /**
  90273. * Gets the list of attached behaviors
  90274. * @see http://doc.babylonjs.com/features/behaviour
  90275. */
  90276. readonly behaviors: Behavior<Node>[];
  90277. /**
  90278. * Gets an attached behavior by name
  90279. * @param name defines the name of the behavior to look for
  90280. * @see http://doc.babylonjs.com/features/behaviour
  90281. * @returns null if behavior was not found else the requested behavior
  90282. */
  90283. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  90284. /**
  90285. * Returns the latest update of the World matrix
  90286. * @returns a Matrix
  90287. */
  90288. getWorldMatrix(): Matrix;
  90289. /** @hidden */
  90290. _getWorldMatrixDeterminant(): number;
  90291. /**
  90292. * Returns directly the latest state of the mesh World matrix.
  90293. * A Matrix is returned.
  90294. */
  90295. readonly worldMatrixFromCache: Matrix;
  90296. /** @hidden */
  90297. _initCache(): void;
  90298. /** @hidden */
  90299. updateCache(force?: boolean): void;
  90300. /** @hidden */
  90301. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90302. /** @hidden */
  90303. _updateCache(ignoreParentClass?: boolean): void;
  90304. /** @hidden */
  90305. _isSynchronized(): boolean;
  90306. /** @hidden */
  90307. _markSyncedWithParent(): void;
  90308. /** @hidden */
  90309. isSynchronizedWithParent(): boolean;
  90310. /** @hidden */
  90311. isSynchronized(): boolean;
  90312. /**
  90313. * Is this node ready to be used/rendered
  90314. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90315. * @return true if the node is ready
  90316. */
  90317. isReady(completeCheck?: boolean): boolean;
  90318. /**
  90319. * Is this node enabled?
  90320. * 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
  90321. * @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
  90322. * @return whether this node (and its parent) is enabled
  90323. */
  90324. isEnabled(checkAncestors?: boolean): boolean;
  90325. /** @hidden */
  90326. protected _syncParentEnabledState(): void;
  90327. /**
  90328. * Set the enabled state of this node
  90329. * @param value defines the new enabled state
  90330. */
  90331. setEnabled(value: boolean): void;
  90332. /**
  90333. * Is this node a descendant of the given node?
  90334. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  90335. * @param ancestor defines the parent node to inspect
  90336. * @returns a boolean indicating if this node is a descendant of the given node
  90337. */
  90338. isDescendantOf(ancestor: Node): boolean;
  90339. /** @hidden */
  90340. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  90341. /**
  90342. * Will return all nodes that have this node as ascendant
  90343. * @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
  90344. * @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
  90345. * @return all children nodes of all types
  90346. */
  90347. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  90348. /**
  90349. * Get all child-meshes of this node
  90350. * @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)
  90351. * @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
  90352. * @returns an array of AbstractMesh
  90353. */
  90354. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  90355. /**
  90356. * Get all direct children of this node
  90357. * @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
  90358. * @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)
  90359. * @returns an array of Node
  90360. */
  90361. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  90362. /** @hidden */
  90363. _setReady(state: boolean): void;
  90364. /**
  90365. * Get an animation by name
  90366. * @param name defines the name of the animation to look for
  90367. * @returns null if not found else the requested animation
  90368. */
  90369. getAnimationByName(name: string): Nullable<Animation>;
  90370. /**
  90371. * Creates an animation range for this node
  90372. * @param name defines the name of the range
  90373. * @param from defines the starting key
  90374. * @param to defines the end key
  90375. */
  90376. createAnimationRange(name: string, from: number, to: number): void;
  90377. /**
  90378. * Delete a specific animation range
  90379. * @param name defines the name of the range to delete
  90380. * @param deleteFrames defines if animation frames from the range must be deleted as well
  90381. */
  90382. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90383. /**
  90384. * Get an animation range by name
  90385. * @param name defines the name of the animation range to look for
  90386. * @returns null if not found else the requested animation range
  90387. */
  90388. getAnimationRange(name: string): Nullable<AnimationRange>;
  90389. /**
  90390. * Gets the list of all animation ranges defined on this node
  90391. * @returns an array
  90392. */
  90393. getAnimationRanges(): Nullable<AnimationRange>[];
  90394. /**
  90395. * Will start the animation sequence
  90396. * @param name defines the range frames for animation sequence
  90397. * @param loop defines if the animation should loop (false by default)
  90398. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  90399. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  90400. * @returns the object created for this animation. If range does not exist, it will return null
  90401. */
  90402. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90403. /**
  90404. * Serialize animation ranges into a JSON compatible object
  90405. * @returns serialization object
  90406. */
  90407. serializeAnimationRanges(): any;
  90408. /**
  90409. * Computes the world matrix of the node
  90410. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90411. * @returns the world matrix
  90412. */
  90413. computeWorldMatrix(force?: boolean): Matrix;
  90414. /**
  90415. * Releases resources associated with this node.
  90416. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90417. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90418. */
  90419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90420. /**
  90421. * Parse animation range data from a serialization object and store them into a given node
  90422. * @param node defines where to store the animation ranges
  90423. * @param parsedNode defines the serialization object to read data from
  90424. * @param scene defines the hosting scene
  90425. */
  90426. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  90427. /**
  90428. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  90429. * @param includeDescendants Include bounding info from descendants as well (true by default)
  90430. * @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
  90431. * @returns the new bounding vectors
  90432. */
  90433. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  90434. min: Vector3;
  90435. max: Vector3;
  90436. };
  90437. }
  90438. }
  90439. declare module BABYLON {
  90440. /**
  90441. * @hidden
  90442. */
  90443. export class _IAnimationState {
  90444. key: number;
  90445. repeatCount: number;
  90446. workValue?: any;
  90447. loopMode?: number;
  90448. offsetValue?: any;
  90449. highLimitValue?: any;
  90450. }
  90451. /**
  90452. * Class used to store any kind of animation
  90453. */
  90454. export class Animation {
  90455. /**Name of the animation */
  90456. name: string;
  90457. /**Property to animate */
  90458. targetProperty: string;
  90459. /**The frames per second of the animation */
  90460. framePerSecond: number;
  90461. /**The data type of the animation */
  90462. dataType: number;
  90463. /**The loop mode of the animation */
  90464. loopMode?: number | undefined;
  90465. /**Specifies if blending should be enabled */
  90466. enableBlending?: boolean | undefined;
  90467. /**
  90468. * Use matrix interpolation instead of using direct key value when animating matrices
  90469. */
  90470. static AllowMatricesInterpolation: boolean;
  90471. /**
  90472. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  90473. */
  90474. static AllowMatrixDecomposeForInterpolation: boolean;
  90475. /**
  90476. * Stores the key frames of the animation
  90477. */
  90478. private _keys;
  90479. /**
  90480. * Stores the easing function of the animation
  90481. */
  90482. private _easingFunction;
  90483. /**
  90484. * @hidden Internal use only
  90485. */
  90486. _runtimeAnimations: RuntimeAnimation[];
  90487. /**
  90488. * The set of event that will be linked to this animation
  90489. */
  90490. private _events;
  90491. /**
  90492. * Stores an array of target property paths
  90493. */
  90494. targetPropertyPath: string[];
  90495. /**
  90496. * Stores the blending speed of the animation
  90497. */
  90498. blendingSpeed: number;
  90499. /**
  90500. * Stores the animation ranges for the animation
  90501. */
  90502. private _ranges;
  90503. /**
  90504. * @hidden Internal use
  90505. */
  90506. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  90507. /**
  90508. * Sets up an animation
  90509. * @param property The property to animate
  90510. * @param animationType The animation type to apply
  90511. * @param framePerSecond The frames per second of the animation
  90512. * @param easingFunction The easing function used in the animation
  90513. * @returns The created animation
  90514. */
  90515. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  90516. /**
  90517. * Create and start an animation on a node
  90518. * @param name defines the name of the global animation that will be run on all nodes
  90519. * @param node defines the root node where the animation will take place
  90520. * @param targetProperty defines property to animate
  90521. * @param framePerSecond defines the number of frame per second yo use
  90522. * @param totalFrame defines the number of frames in total
  90523. * @param from defines the initial value
  90524. * @param to defines the final value
  90525. * @param loopMode defines which loop mode you want to use (off by default)
  90526. * @param easingFunction defines the easing function to use (linear by default)
  90527. * @param onAnimationEnd defines the callback to call when animation end
  90528. * @returns the animatable created for this animation
  90529. */
  90530. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90531. /**
  90532. * Create and start an animation on a node and its descendants
  90533. * @param name defines the name of the global animation that will be run on all nodes
  90534. * @param node defines the root node where the animation will take place
  90535. * @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
  90536. * @param targetProperty defines property to animate
  90537. * @param framePerSecond defines the number of frame per second to use
  90538. * @param totalFrame defines the number of frames in total
  90539. * @param from defines the initial value
  90540. * @param to defines the final value
  90541. * @param loopMode defines which loop mode you want to use (off by default)
  90542. * @param easingFunction defines the easing function to use (linear by default)
  90543. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90544. * @returns the list of animatables created for all nodes
  90545. * @example https://www.babylonjs-playground.com/#MH0VLI
  90546. */
  90547. 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[]>;
  90548. /**
  90549. * Creates a new animation, merges it with the existing animations and starts it
  90550. * @param name Name of the animation
  90551. * @param node Node which contains the scene that begins the animations
  90552. * @param targetProperty Specifies which property to animate
  90553. * @param framePerSecond The frames per second of the animation
  90554. * @param totalFrame The total number of frames
  90555. * @param from The frame at the beginning of the animation
  90556. * @param to The frame at the end of the animation
  90557. * @param loopMode Specifies the loop mode of the animation
  90558. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  90559. * @param onAnimationEnd Callback to run once the animation is complete
  90560. * @returns Nullable animation
  90561. */
  90562. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90563. /**
  90564. * Transition property of an host to the target Value
  90565. * @param property The property to transition
  90566. * @param targetValue The target Value of the property
  90567. * @param host The object where the property to animate belongs
  90568. * @param scene Scene used to run the animation
  90569. * @param frameRate Framerate (in frame/s) to use
  90570. * @param transition The transition type we want to use
  90571. * @param duration The duration of the animation, in milliseconds
  90572. * @param onAnimationEnd Callback trigger at the end of the animation
  90573. * @returns Nullable animation
  90574. */
  90575. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  90576. /**
  90577. * Return the array of runtime animations currently using this animation
  90578. */
  90579. readonly runtimeAnimations: RuntimeAnimation[];
  90580. /**
  90581. * Specifies if any of the runtime animations are currently running
  90582. */
  90583. readonly hasRunningRuntimeAnimations: boolean;
  90584. /**
  90585. * Initializes the animation
  90586. * @param name Name of the animation
  90587. * @param targetProperty Property to animate
  90588. * @param framePerSecond The frames per second of the animation
  90589. * @param dataType The data type of the animation
  90590. * @param loopMode The loop mode of the animation
  90591. * @param enableBlending Specifies if blending should be enabled
  90592. */
  90593. constructor(
  90594. /**Name of the animation */
  90595. name: string,
  90596. /**Property to animate */
  90597. targetProperty: string,
  90598. /**The frames per second of the animation */
  90599. framePerSecond: number,
  90600. /**The data type of the animation */
  90601. dataType: number,
  90602. /**The loop mode of the animation */
  90603. loopMode?: number | undefined,
  90604. /**Specifies if blending should be enabled */
  90605. enableBlending?: boolean | undefined);
  90606. /**
  90607. * Converts the animation to a string
  90608. * @param fullDetails support for multiple levels of logging within scene loading
  90609. * @returns String form of the animation
  90610. */
  90611. toString(fullDetails?: boolean): string;
  90612. /**
  90613. * Add an event to this animation
  90614. * @param event Event to add
  90615. */
  90616. addEvent(event: AnimationEvent): void;
  90617. /**
  90618. * Remove all events found at the given frame
  90619. * @param frame The frame to remove events from
  90620. */
  90621. removeEvents(frame: number): void;
  90622. /**
  90623. * Retrieves all the events from the animation
  90624. * @returns Events from the animation
  90625. */
  90626. getEvents(): AnimationEvent[];
  90627. /**
  90628. * Creates an animation range
  90629. * @param name Name of the animation range
  90630. * @param from Starting frame of the animation range
  90631. * @param to Ending frame of the animation
  90632. */
  90633. createRange(name: string, from: number, to: number): void;
  90634. /**
  90635. * Deletes an animation range by name
  90636. * @param name Name of the animation range to delete
  90637. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  90638. */
  90639. deleteRange(name: string, deleteFrames?: boolean): void;
  90640. /**
  90641. * Gets the animation range by name, or null if not defined
  90642. * @param name Name of the animation range
  90643. * @returns Nullable animation range
  90644. */
  90645. getRange(name: string): Nullable<AnimationRange>;
  90646. /**
  90647. * Gets the key frames from the animation
  90648. * @returns The key frames of the animation
  90649. */
  90650. getKeys(): Array<IAnimationKey>;
  90651. /**
  90652. * Gets the highest frame rate of the animation
  90653. * @returns Highest frame rate of the animation
  90654. */
  90655. getHighestFrame(): number;
  90656. /**
  90657. * Gets the easing function of the animation
  90658. * @returns Easing function of the animation
  90659. */
  90660. getEasingFunction(): IEasingFunction;
  90661. /**
  90662. * Sets the easing function of the animation
  90663. * @param easingFunction A custom mathematical formula for animation
  90664. */
  90665. setEasingFunction(easingFunction: EasingFunction): void;
  90666. /**
  90667. * Interpolates a scalar linearly
  90668. * @param startValue Start value of the animation curve
  90669. * @param endValue End value of the animation curve
  90670. * @param gradient Scalar amount to interpolate
  90671. * @returns Interpolated scalar value
  90672. */
  90673. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  90674. /**
  90675. * Interpolates a scalar cubically
  90676. * @param startValue Start value of the animation curve
  90677. * @param outTangent End tangent of the animation
  90678. * @param endValue End value of the animation curve
  90679. * @param inTangent Start tangent of the animation curve
  90680. * @param gradient Scalar amount to interpolate
  90681. * @returns Interpolated scalar value
  90682. */
  90683. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  90684. /**
  90685. * Interpolates a quaternion using a spherical linear interpolation
  90686. * @param startValue Start value of the animation curve
  90687. * @param endValue End value of the animation curve
  90688. * @param gradient Scalar amount to interpolate
  90689. * @returns Interpolated quaternion value
  90690. */
  90691. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  90692. /**
  90693. * Interpolates a quaternion cubically
  90694. * @param startValue Start value of the animation curve
  90695. * @param outTangent End tangent of the animation curve
  90696. * @param endValue End value of the animation curve
  90697. * @param inTangent Start tangent of the animation curve
  90698. * @param gradient Scalar amount to interpolate
  90699. * @returns Interpolated quaternion value
  90700. */
  90701. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  90702. /**
  90703. * Interpolates a Vector3 linearl
  90704. * @param startValue Start value of the animation curve
  90705. * @param endValue End value of the animation curve
  90706. * @param gradient Scalar amount to interpolate
  90707. * @returns Interpolated scalar value
  90708. */
  90709. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  90710. /**
  90711. * Interpolates a Vector3 cubically
  90712. * @param startValue Start value of the animation curve
  90713. * @param outTangent End tangent of the animation
  90714. * @param endValue End value of the animation curve
  90715. * @param inTangent Start tangent of the animation curve
  90716. * @param gradient Scalar amount to interpolate
  90717. * @returns InterpolatedVector3 value
  90718. */
  90719. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  90720. /**
  90721. * Interpolates a Vector2 linearly
  90722. * @param startValue Start value of the animation curve
  90723. * @param endValue End value of the animation curve
  90724. * @param gradient Scalar amount to interpolate
  90725. * @returns Interpolated Vector2 value
  90726. */
  90727. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  90728. /**
  90729. * Interpolates a Vector2 cubically
  90730. * @param startValue Start value of the animation curve
  90731. * @param outTangent End tangent of the animation
  90732. * @param endValue End value of the animation curve
  90733. * @param inTangent Start tangent of the animation curve
  90734. * @param gradient Scalar amount to interpolate
  90735. * @returns Interpolated Vector2 value
  90736. */
  90737. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  90738. /**
  90739. * Interpolates a size linearly
  90740. * @param startValue Start value of the animation curve
  90741. * @param endValue End value of the animation curve
  90742. * @param gradient Scalar amount to interpolate
  90743. * @returns Interpolated Size value
  90744. */
  90745. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  90746. /**
  90747. * Interpolates a Color3 linearly
  90748. * @param startValue Start value of the animation curve
  90749. * @param endValue End value of the animation curve
  90750. * @param gradient Scalar amount to interpolate
  90751. * @returns Interpolated Color3 value
  90752. */
  90753. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  90754. /**
  90755. * @hidden Internal use only
  90756. */
  90757. _getKeyValue(value: any): any;
  90758. /**
  90759. * @hidden Internal use only
  90760. */
  90761. _interpolate(currentFrame: number, state: _IAnimationState): any;
  90762. /**
  90763. * Defines the function to use to interpolate matrices
  90764. * @param startValue defines the start matrix
  90765. * @param endValue defines the end matrix
  90766. * @param gradient defines the gradient between both matrices
  90767. * @param result defines an optional target matrix where to store the interpolation
  90768. * @returns the interpolated matrix
  90769. */
  90770. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  90771. /**
  90772. * Makes a copy of the animation
  90773. * @returns Cloned animation
  90774. */
  90775. clone(): Animation;
  90776. /**
  90777. * Sets the key frames of the animation
  90778. * @param values The animation key frames to set
  90779. */
  90780. setKeys(values: Array<IAnimationKey>): void;
  90781. /**
  90782. * Serializes the animation to an object
  90783. * @returns Serialized object
  90784. */
  90785. serialize(): any;
  90786. /**
  90787. * Float animation type
  90788. */
  90789. private static _ANIMATIONTYPE_FLOAT;
  90790. /**
  90791. * Vector3 animation type
  90792. */
  90793. private static _ANIMATIONTYPE_VECTOR3;
  90794. /**
  90795. * Quaternion animation type
  90796. */
  90797. private static _ANIMATIONTYPE_QUATERNION;
  90798. /**
  90799. * Matrix animation type
  90800. */
  90801. private static _ANIMATIONTYPE_MATRIX;
  90802. /**
  90803. * Color3 animation type
  90804. */
  90805. private static _ANIMATIONTYPE_COLOR3;
  90806. /**
  90807. * Vector2 animation type
  90808. */
  90809. private static _ANIMATIONTYPE_VECTOR2;
  90810. /**
  90811. * Size animation type
  90812. */
  90813. private static _ANIMATIONTYPE_SIZE;
  90814. /**
  90815. * Relative Loop Mode
  90816. */
  90817. private static _ANIMATIONLOOPMODE_RELATIVE;
  90818. /**
  90819. * Cycle Loop Mode
  90820. */
  90821. private static _ANIMATIONLOOPMODE_CYCLE;
  90822. /**
  90823. * Constant Loop Mode
  90824. */
  90825. private static _ANIMATIONLOOPMODE_CONSTANT;
  90826. /**
  90827. * Get the float animation type
  90828. */
  90829. static readonly ANIMATIONTYPE_FLOAT: number;
  90830. /**
  90831. * Get the Vector3 animation type
  90832. */
  90833. static readonly ANIMATIONTYPE_VECTOR3: number;
  90834. /**
  90835. * Get the Vector2 animation type
  90836. */
  90837. static readonly ANIMATIONTYPE_VECTOR2: number;
  90838. /**
  90839. * Get the Size animation type
  90840. */
  90841. static readonly ANIMATIONTYPE_SIZE: number;
  90842. /**
  90843. * Get the Quaternion animation type
  90844. */
  90845. static readonly ANIMATIONTYPE_QUATERNION: number;
  90846. /**
  90847. * Get the Matrix animation type
  90848. */
  90849. static readonly ANIMATIONTYPE_MATRIX: number;
  90850. /**
  90851. * Get the Color3 animation type
  90852. */
  90853. static readonly ANIMATIONTYPE_COLOR3: number;
  90854. /**
  90855. * Get the Relative Loop Mode
  90856. */
  90857. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  90858. /**
  90859. * Get the Cycle Loop Mode
  90860. */
  90861. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  90862. /**
  90863. * Get the Constant Loop Mode
  90864. */
  90865. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  90866. /** @hidden */
  90867. static _UniversalLerp(left: any, right: any, amount: number): any;
  90868. /**
  90869. * Parses an animation object and creates an animation
  90870. * @param parsedAnimation Parsed animation object
  90871. * @returns Animation object
  90872. */
  90873. static Parse(parsedAnimation: any): Animation;
  90874. /**
  90875. * Appends the serialized animations from the source animations
  90876. * @param source Source containing the animations
  90877. * @param destination Target to store the animations
  90878. */
  90879. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90880. }
  90881. }
  90882. declare module BABYLON {
  90883. /**
  90884. * Interface containing an array of animations
  90885. */
  90886. export interface IAnimatable {
  90887. /**
  90888. * Array of animations
  90889. */
  90890. animations: Nullable<Array<Animation>>;
  90891. }
  90892. }
  90893. declare module BABYLON {
  90894. /**
  90895. * This represents all the required information to add a fresnel effect on a material:
  90896. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  90897. */
  90898. export class FresnelParameters {
  90899. private _isEnabled;
  90900. /**
  90901. * Define if the fresnel effect is enable or not.
  90902. */
  90903. isEnabled: boolean;
  90904. /**
  90905. * Define the color used on edges (grazing angle)
  90906. */
  90907. leftColor: Color3;
  90908. /**
  90909. * Define the color used on center
  90910. */
  90911. rightColor: Color3;
  90912. /**
  90913. * Define bias applied to computed fresnel term
  90914. */
  90915. bias: number;
  90916. /**
  90917. * Defined the power exponent applied to fresnel term
  90918. */
  90919. power: number;
  90920. /**
  90921. * Clones the current fresnel and its valuues
  90922. * @returns a clone fresnel configuration
  90923. */
  90924. clone(): FresnelParameters;
  90925. /**
  90926. * Serializes the current fresnel parameters to a JSON representation.
  90927. * @return the JSON serialization
  90928. */
  90929. serialize(): any;
  90930. /**
  90931. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90932. * @param parsedFresnelParameters Define the JSON representation
  90933. * @returns the parsed parameters
  90934. */
  90935. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90936. }
  90937. }
  90938. declare module BABYLON {
  90939. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90940. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90941. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90942. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90943. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90944. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90945. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90946. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90947. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90948. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90949. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90950. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90951. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90952. /**
  90953. * Decorator used to define property that can be serialized as reference to a camera
  90954. * @param sourceName defines the name of the property to decorate
  90955. */
  90956. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90957. /**
  90958. * Class used to help serialization objects
  90959. */
  90960. export class SerializationHelper {
  90961. /** @hidden */
  90962. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90963. /** @hidden */
  90964. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90965. /** @hidden */
  90966. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90967. /** @hidden */
  90968. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90969. /**
  90970. * Appends the serialized animations from the source animations
  90971. * @param source Source containing the animations
  90972. * @param destination Target to store the animations
  90973. */
  90974. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90975. /**
  90976. * Static function used to serialized a specific entity
  90977. * @param entity defines the entity to serialize
  90978. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90979. * @returns a JSON compatible object representing the serialization of the entity
  90980. */
  90981. static Serialize<T>(entity: T, serializationObject?: any): any;
  90982. /**
  90983. * Creates a new entity from a serialization data object
  90984. * @param creationFunction defines a function used to instanciated the new entity
  90985. * @param source defines the source serialization data
  90986. * @param scene defines the hosting scene
  90987. * @param rootUrl defines the root url for resources
  90988. * @returns a new entity
  90989. */
  90990. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90991. /**
  90992. * Clones an object
  90993. * @param creationFunction defines the function used to instanciate the new object
  90994. * @param source defines the source object
  90995. * @returns the cloned object
  90996. */
  90997. static Clone<T>(creationFunction: () => T, source: T): T;
  90998. /**
  90999. * Instanciates a new object based on a source one (some data will be shared between both object)
  91000. * @param creationFunction defines the function used to instanciate the new object
  91001. * @param source defines the source object
  91002. * @returns the new object
  91003. */
  91004. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91005. }
  91006. }
  91007. declare module BABYLON {
  91008. /**
  91009. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91010. */
  91011. export interface CubeMapInfo {
  91012. /**
  91013. * The pixel array for the front face.
  91014. * This is stored in format, left to right, up to down format.
  91015. */
  91016. front: Nullable<ArrayBufferView>;
  91017. /**
  91018. * The pixel array for the back face.
  91019. * This is stored in format, left to right, up to down format.
  91020. */
  91021. back: Nullable<ArrayBufferView>;
  91022. /**
  91023. * The pixel array for the left face.
  91024. * This is stored in format, left to right, up to down format.
  91025. */
  91026. left: Nullable<ArrayBufferView>;
  91027. /**
  91028. * The pixel array for the right face.
  91029. * This is stored in format, left to right, up to down format.
  91030. */
  91031. right: Nullable<ArrayBufferView>;
  91032. /**
  91033. * The pixel array for the up face.
  91034. * This is stored in format, left to right, up to down format.
  91035. */
  91036. up: Nullable<ArrayBufferView>;
  91037. /**
  91038. * The pixel array for the down face.
  91039. * This is stored in format, left to right, up to down format.
  91040. */
  91041. down: Nullable<ArrayBufferView>;
  91042. /**
  91043. * The size of the cubemap stored.
  91044. *
  91045. * Each faces will be size * size pixels.
  91046. */
  91047. size: number;
  91048. /**
  91049. * The format of the texture.
  91050. *
  91051. * RGBA, RGB.
  91052. */
  91053. format: number;
  91054. /**
  91055. * The type of the texture data.
  91056. *
  91057. * UNSIGNED_INT, FLOAT.
  91058. */
  91059. type: number;
  91060. /**
  91061. * Specifies whether the texture is in gamma space.
  91062. */
  91063. gammaSpace: boolean;
  91064. }
  91065. /**
  91066. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91067. */
  91068. export class PanoramaToCubeMapTools {
  91069. private static FACE_FRONT;
  91070. private static FACE_BACK;
  91071. private static FACE_RIGHT;
  91072. private static FACE_LEFT;
  91073. private static FACE_DOWN;
  91074. private static FACE_UP;
  91075. /**
  91076. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91077. *
  91078. * @param float32Array The source data.
  91079. * @param inputWidth The width of the input panorama.
  91080. * @param inputHeight The height of the input panorama.
  91081. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91082. * @return The cubemap data
  91083. */
  91084. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  91085. private static CreateCubemapTexture;
  91086. private static CalcProjectionSpherical;
  91087. }
  91088. }
  91089. declare module BABYLON {
  91090. /**
  91091. * Helper class dealing with the extraction of spherical polynomial dataArray
  91092. * from a cube map.
  91093. */
  91094. export class CubeMapToSphericalPolynomialTools {
  91095. private static FileFaces;
  91096. /**
  91097. * Converts a texture to the according Spherical Polynomial data.
  91098. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91099. *
  91100. * @param texture The texture to extract the information from.
  91101. * @return The Spherical Polynomial data.
  91102. */
  91103. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  91104. /**
  91105. * Converts a cubemap to the according Spherical Polynomial data.
  91106. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91107. *
  91108. * @param cubeInfo The Cube map to extract the information from.
  91109. * @return The Spherical Polynomial data.
  91110. */
  91111. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  91112. }
  91113. }
  91114. declare module BABYLON {
  91115. /**
  91116. * Class used to manipulate GUIDs
  91117. */
  91118. export class GUID {
  91119. /**
  91120. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91121. * Be aware Math.random() could cause collisions, but:
  91122. * "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"
  91123. * @returns a pseudo random id
  91124. */
  91125. static RandomId(): string;
  91126. }
  91127. }
  91128. declare module BABYLON {
  91129. /**
  91130. * Base class of all the textures in babylon.
  91131. * It groups all the common properties the materials, post process, lights... might need
  91132. * in order to make a correct use of the texture.
  91133. */
  91134. export class BaseTexture implements IAnimatable {
  91135. /**
  91136. * Default anisotropic filtering level for the application.
  91137. * It is set to 4 as a good tradeoff between perf and quality.
  91138. */
  91139. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  91140. /**
  91141. * Gets or sets the unique id of the texture
  91142. */
  91143. uniqueId: number;
  91144. /**
  91145. * Define the name of the texture.
  91146. */
  91147. name: string;
  91148. /**
  91149. * Gets or sets an object used to store user defined information.
  91150. */
  91151. metadata: any;
  91152. /**
  91153. * For internal use only. Please do not use.
  91154. */
  91155. reservedDataStore: any;
  91156. private _hasAlpha;
  91157. /**
  91158. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  91159. */
  91160. hasAlpha: boolean;
  91161. /**
  91162. * Defines if the alpha value should be determined via the rgb values.
  91163. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  91164. */
  91165. getAlphaFromRGB: boolean;
  91166. /**
  91167. * Intensity or strength of the texture.
  91168. * It is commonly used by materials to fine tune the intensity of the texture
  91169. */
  91170. level: number;
  91171. /**
  91172. * Define the UV chanel to use starting from 0 and defaulting to 0.
  91173. * This is part of the texture as textures usually maps to one uv set.
  91174. */
  91175. coordinatesIndex: number;
  91176. private _coordinatesMode;
  91177. /**
  91178. * How a texture is mapped.
  91179. *
  91180. * | Value | Type | Description |
  91181. * | ----- | ----------------------------------- | ----------- |
  91182. * | 0 | EXPLICIT_MODE | |
  91183. * | 1 | SPHERICAL_MODE | |
  91184. * | 2 | PLANAR_MODE | |
  91185. * | 3 | CUBIC_MODE | |
  91186. * | 4 | PROJECTION_MODE | |
  91187. * | 5 | SKYBOX_MODE | |
  91188. * | 6 | INVCUBIC_MODE | |
  91189. * | 7 | EQUIRECTANGULAR_MODE | |
  91190. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  91191. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  91192. */
  91193. coordinatesMode: number;
  91194. /**
  91195. * | Value | Type | Description |
  91196. * | ----- | ------------------ | ----------- |
  91197. * | 0 | CLAMP_ADDRESSMODE | |
  91198. * | 1 | WRAP_ADDRESSMODE | |
  91199. * | 2 | MIRROR_ADDRESSMODE | |
  91200. */
  91201. wrapU: number;
  91202. /**
  91203. * | Value | Type | Description |
  91204. * | ----- | ------------------ | ----------- |
  91205. * | 0 | CLAMP_ADDRESSMODE | |
  91206. * | 1 | WRAP_ADDRESSMODE | |
  91207. * | 2 | MIRROR_ADDRESSMODE | |
  91208. */
  91209. wrapV: number;
  91210. /**
  91211. * | Value | Type | Description |
  91212. * | ----- | ------------------ | ----------- |
  91213. * | 0 | CLAMP_ADDRESSMODE | |
  91214. * | 1 | WRAP_ADDRESSMODE | |
  91215. * | 2 | MIRROR_ADDRESSMODE | |
  91216. */
  91217. wrapR: number;
  91218. /**
  91219. * With compliant hardware and browser (supporting anisotropic filtering)
  91220. * this defines the level of anisotropic filtering in the texture.
  91221. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  91222. */
  91223. anisotropicFilteringLevel: number;
  91224. /**
  91225. * Define if the texture is a cube texture or if false a 2d texture.
  91226. */
  91227. isCube: boolean;
  91228. /**
  91229. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  91230. */
  91231. is3D: boolean;
  91232. /**
  91233. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  91234. * HDR texture are usually stored in linear space.
  91235. * This only impacts the PBR and Background materials
  91236. */
  91237. gammaSpace: boolean;
  91238. /**
  91239. * Gets whether or not the texture contains RGBD data.
  91240. */
  91241. readonly isRGBD: boolean;
  91242. /**
  91243. * Is Z inverted in the texture (useful in a cube texture).
  91244. */
  91245. invertZ: boolean;
  91246. /**
  91247. * Are mip maps generated for this texture or not.
  91248. */
  91249. readonly noMipmap: boolean;
  91250. /**
  91251. * @hidden
  91252. */
  91253. lodLevelInAlpha: boolean;
  91254. /**
  91255. * With prefiltered texture, defined the offset used during the prefiltering steps.
  91256. */
  91257. lodGenerationOffset: number;
  91258. /**
  91259. * With prefiltered texture, defined the scale used during the prefiltering steps.
  91260. */
  91261. lodGenerationScale: number;
  91262. /**
  91263. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  91264. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  91265. * average roughness values.
  91266. */
  91267. linearSpecularLOD: boolean;
  91268. /**
  91269. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  91270. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  91271. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  91272. */
  91273. irradianceTexture: Nullable<BaseTexture>;
  91274. /**
  91275. * Define if the texture is a render target.
  91276. */
  91277. isRenderTarget: boolean;
  91278. /**
  91279. * Define the unique id of the texture in the scene.
  91280. */
  91281. readonly uid: string;
  91282. /**
  91283. * Return a string representation of the texture.
  91284. * @returns the texture as a string
  91285. */
  91286. toString(): string;
  91287. /**
  91288. * Get the class name of the texture.
  91289. * @returns "BaseTexture"
  91290. */
  91291. getClassName(): string;
  91292. /**
  91293. * Define the list of animation attached to the texture.
  91294. */
  91295. animations: Animation[];
  91296. /**
  91297. * An event triggered when the texture is disposed.
  91298. */
  91299. onDisposeObservable: Observable<BaseTexture>;
  91300. private _onDisposeObserver;
  91301. /**
  91302. * Callback triggered when the texture has been disposed.
  91303. * Kept for back compatibility, you can use the onDisposeObservable instead.
  91304. */
  91305. onDispose: () => void;
  91306. /**
  91307. * Define the current state of the loading sequence when in delayed load mode.
  91308. */
  91309. delayLoadState: number;
  91310. private _scene;
  91311. /** @hidden */
  91312. _texture: Nullable<InternalTexture>;
  91313. private _uid;
  91314. /**
  91315. * Define if the texture is preventinga material to render or not.
  91316. * If not and the texture is not ready, the engine will use a default black texture instead.
  91317. */
  91318. readonly isBlocking: boolean;
  91319. /**
  91320. * Instantiates a new BaseTexture.
  91321. * Base class of all the textures in babylon.
  91322. * It groups all the common properties the materials, post process, lights... might need
  91323. * in order to make a correct use of the texture.
  91324. * @param scene Define the scene the texture blongs to
  91325. */
  91326. constructor(scene: Nullable<Scene>);
  91327. /**
  91328. * Get the scene the texture belongs to.
  91329. * @returns the scene or null if undefined
  91330. */
  91331. getScene(): Nullable<Scene>;
  91332. /**
  91333. * Get the texture transform matrix used to offset tile the texture for istance.
  91334. * @returns the transformation matrix
  91335. */
  91336. getTextureMatrix(): Matrix;
  91337. /**
  91338. * Get the texture reflection matrix used to rotate/transform the reflection.
  91339. * @returns the reflection matrix
  91340. */
  91341. getReflectionTextureMatrix(): Matrix;
  91342. /**
  91343. * Get the underlying lower level texture from Babylon.
  91344. * @returns the insternal texture
  91345. */
  91346. getInternalTexture(): Nullable<InternalTexture>;
  91347. /**
  91348. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  91349. * @returns true if ready or not blocking
  91350. */
  91351. isReadyOrNotBlocking(): boolean;
  91352. /**
  91353. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  91354. * @returns true if fully ready
  91355. */
  91356. isReady(): boolean;
  91357. private _cachedSize;
  91358. /**
  91359. * Get the size of the texture.
  91360. * @returns the texture size.
  91361. */
  91362. getSize(): ISize;
  91363. /**
  91364. * Get the base size of the texture.
  91365. * It can be different from the size if the texture has been resized for POT for instance
  91366. * @returns the base size
  91367. */
  91368. getBaseSize(): ISize;
  91369. /**
  91370. * Update the sampling mode of the texture.
  91371. * Default is Trilinear mode.
  91372. *
  91373. * | Value | Type | Description |
  91374. * | ----- | ------------------ | ----------- |
  91375. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  91376. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  91377. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  91378. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  91379. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  91380. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  91381. * | 7 | NEAREST_LINEAR | |
  91382. * | 8 | NEAREST_NEAREST | |
  91383. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  91384. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  91385. * | 11 | LINEAR_LINEAR | |
  91386. * | 12 | LINEAR_NEAREST | |
  91387. *
  91388. * > _mag_: magnification filter (close to the viewer)
  91389. * > _min_: minification filter (far from the viewer)
  91390. * > _mip_: filter used between mip map levels
  91391. *@param samplingMode Define the new sampling mode of the texture
  91392. */
  91393. updateSamplingMode(samplingMode: number): void;
  91394. /**
  91395. * Scales the texture if is `canRescale()`
  91396. * @param ratio the resize factor we want to use to rescale
  91397. */
  91398. scale(ratio: number): void;
  91399. /**
  91400. * Get if the texture can rescale.
  91401. */
  91402. readonly canRescale: boolean;
  91403. /** @hidden */
  91404. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  91405. /** @hidden */
  91406. _rebuild(): void;
  91407. /**
  91408. * Triggers the load sequence in delayed load mode.
  91409. */
  91410. delayLoad(): void;
  91411. /**
  91412. * Clones the texture.
  91413. * @returns the cloned texture
  91414. */
  91415. clone(): Nullable<BaseTexture>;
  91416. /**
  91417. * Get the texture underlying type (INT, FLOAT...)
  91418. */
  91419. readonly textureType: number;
  91420. /**
  91421. * Get the texture underlying format (RGB, RGBA...)
  91422. */
  91423. readonly textureFormat: number;
  91424. /**
  91425. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  91426. * This will returns an RGBA array buffer containing either in values (0-255) or
  91427. * float values (0-1) depending of the underlying buffer type.
  91428. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  91429. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  91430. * @param buffer defines a user defined buffer to fill with data (can be null)
  91431. * @returns The Array buffer containing the pixels data.
  91432. */
  91433. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  91434. /**
  91435. * Release and destroy the underlying lower level texture aka internalTexture.
  91436. */
  91437. releaseInternalTexture(): void;
  91438. /**
  91439. * Get the polynomial representation of the texture data.
  91440. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  91441. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  91442. */
  91443. sphericalPolynomial: Nullable<SphericalPolynomial>;
  91444. /** @hidden */
  91445. readonly _lodTextureHigh: Nullable<BaseTexture>;
  91446. /** @hidden */
  91447. readonly _lodTextureMid: Nullable<BaseTexture>;
  91448. /** @hidden */
  91449. readonly _lodTextureLow: Nullable<BaseTexture>;
  91450. /**
  91451. * Dispose the texture and release its associated resources.
  91452. */
  91453. dispose(): void;
  91454. /**
  91455. * Serialize the texture into a JSON representation that can be parsed later on.
  91456. * @returns the JSON representation of the texture
  91457. */
  91458. serialize(): any;
  91459. /**
  91460. * Helper function to be called back once a list of texture contains only ready textures.
  91461. * @param textures Define the list of textures to wait for
  91462. * @param callback Define the callback triggered once the entire list will be ready
  91463. */
  91464. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  91465. }
  91466. }
  91467. declare module BABYLON {
  91468. /**
  91469. * Class used to store data associated with WebGL texture data for the engine
  91470. * This class should not be used directly
  91471. */
  91472. export class InternalTexture {
  91473. /** @hidden */
  91474. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  91475. /**
  91476. * The source of the texture data is unknown
  91477. */
  91478. static DATASOURCE_UNKNOWN: number;
  91479. /**
  91480. * Texture data comes from an URL
  91481. */
  91482. static DATASOURCE_URL: number;
  91483. /**
  91484. * Texture data is only used for temporary storage
  91485. */
  91486. static DATASOURCE_TEMP: number;
  91487. /**
  91488. * Texture data comes from raw data (ArrayBuffer)
  91489. */
  91490. static DATASOURCE_RAW: number;
  91491. /**
  91492. * Texture content is dynamic (video or dynamic texture)
  91493. */
  91494. static DATASOURCE_DYNAMIC: number;
  91495. /**
  91496. * Texture content is generated by rendering to it
  91497. */
  91498. static DATASOURCE_RENDERTARGET: number;
  91499. /**
  91500. * Texture content is part of a multi render target process
  91501. */
  91502. static DATASOURCE_MULTIRENDERTARGET: number;
  91503. /**
  91504. * Texture data comes from a cube data file
  91505. */
  91506. static DATASOURCE_CUBE: number;
  91507. /**
  91508. * Texture data comes from a raw cube data
  91509. */
  91510. static DATASOURCE_CUBERAW: number;
  91511. /**
  91512. * Texture data come from a prefiltered cube data file
  91513. */
  91514. static DATASOURCE_CUBEPREFILTERED: number;
  91515. /**
  91516. * Texture content is raw 3D data
  91517. */
  91518. static DATASOURCE_RAW3D: number;
  91519. /**
  91520. * Texture content is a depth texture
  91521. */
  91522. static DATASOURCE_DEPTHTEXTURE: number;
  91523. /**
  91524. * Texture data comes from a raw cube data encoded with RGBD
  91525. */
  91526. static DATASOURCE_CUBERAW_RGBD: number;
  91527. /**
  91528. * Defines if the texture is ready
  91529. */
  91530. isReady: boolean;
  91531. /**
  91532. * Defines if the texture is a cube texture
  91533. */
  91534. isCube: boolean;
  91535. /**
  91536. * Defines if the texture contains 3D data
  91537. */
  91538. is3D: boolean;
  91539. /**
  91540. * Defines if the texture contains multiview data
  91541. */
  91542. isMultiview: boolean;
  91543. /**
  91544. * Gets the URL used to load this texture
  91545. */
  91546. url: string;
  91547. /**
  91548. * Gets the sampling mode of the texture
  91549. */
  91550. samplingMode: number;
  91551. /**
  91552. * Gets a boolean indicating if the texture needs mipmaps generation
  91553. */
  91554. generateMipMaps: boolean;
  91555. /**
  91556. * Gets the number of samples used by the texture (WebGL2+ only)
  91557. */
  91558. samples: number;
  91559. /**
  91560. * Gets the type of the texture (int, float...)
  91561. */
  91562. type: number;
  91563. /**
  91564. * Gets the format of the texture (RGB, RGBA...)
  91565. */
  91566. format: number;
  91567. /**
  91568. * Observable called when the texture is loaded
  91569. */
  91570. onLoadedObservable: Observable<InternalTexture>;
  91571. /**
  91572. * Gets the width of the texture
  91573. */
  91574. width: number;
  91575. /**
  91576. * Gets the height of the texture
  91577. */
  91578. height: number;
  91579. /**
  91580. * Gets the depth of the texture
  91581. */
  91582. depth: number;
  91583. /**
  91584. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  91585. */
  91586. baseWidth: number;
  91587. /**
  91588. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  91589. */
  91590. baseHeight: number;
  91591. /**
  91592. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  91593. */
  91594. baseDepth: number;
  91595. /**
  91596. * Gets a boolean indicating if the texture is inverted on Y axis
  91597. */
  91598. invertY: boolean;
  91599. /** @hidden */
  91600. _invertVScale: boolean;
  91601. /** @hidden */
  91602. _associatedChannel: number;
  91603. /** @hidden */
  91604. _dataSource: number;
  91605. /** @hidden */
  91606. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  91607. /** @hidden */
  91608. _bufferView: Nullable<ArrayBufferView>;
  91609. /** @hidden */
  91610. _bufferViewArray: Nullable<ArrayBufferView[]>;
  91611. /** @hidden */
  91612. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  91613. /** @hidden */
  91614. _size: number;
  91615. /** @hidden */
  91616. _extension: string;
  91617. /** @hidden */
  91618. _files: Nullable<string[]>;
  91619. /** @hidden */
  91620. _workingCanvas: Nullable<HTMLCanvasElement>;
  91621. /** @hidden */
  91622. _workingContext: Nullable<CanvasRenderingContext2D>;
  91623. /** @hidden */
  91624. _framebuffer: Nullable<WebGLFramebuffer>;
  91625. /** @hidden */
  91626. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  91627. /** @hidden */
  91628. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  91629. /** @hidden */
  91630. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  91631. /** @hidden */
  91632. _attachments: Nullable<number[]>;
  91633. /** @hidden */
  91634. _cachedCoordinatesMode: Nullable<number>;
  91635. /** @hidden */
  91636. _cachedWrapU: Nullable<number>;
  91637. /** @hidden */
  91638. _cachedWrapV: Nullable<number>;
  91639. /** @hidden */
  91640. _cachedWrapR: Nullable<number>;
  91641. /** @hidden */
  91642. _cachedAnisotropicFilteringLevel: Nullable<number>;
  91643. /** @hidden */
  91644. _isDisabled: boolean;
  91645. /** @hidden */
  91646. _compression: Nullable<string>;
  91647. /** @hidden */
  91648. _generateStencilBuffer: boolean;
  91649. /** @hidden */
  91650. _generateDepthBuffer: boolean;
  91651. /** @hidden */
  91652. _comparisonFunction: number;
  91653. /** @hidden */
  91654. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  91655. /** @hidden */
  91656. _lodGenerationScale: number;
  91657. /** @hidden */
  91658. _lodGenerationOffset: number;
  91659. /** @hidden */
  91660. _colorTextureArray: Nullable<WebGLTexture>;
  91661. /** @hidden */
  91662. _depthStencilTextureArray: Nullable<WebGLTexture>;
  91663. /** @hidden */
  91664. _lodTextureHigh: Nullable<BaseTexture>;
  91665. /** @hidden */
  91666. _lodTextureMid: Nullable<BaseTexture>;
  91667. /** @hidden */
  91668. _lodTextureLow: Nullable<BaseTexture>;
  91669. /** @hidden */
  91670. _isRGBD: boolean;
  91671. /** @hidden */
  91672. _linearSpecularLOD: boolean;
  91673. /** @hidden */
  91674. _irradianceTexture: Nullable<BaseTexture>;
  91675. /** @hidden */
  91676. _webGLTexture: Nullable<WebGLTexture>;
  91677. /** @hidden */
  91678. _references: number;
  91679. private _engine;
  91680. /**
  91681. * Gets the Engine the texture belongs to.
  91682. * @returns The babylon engine
  91683. */
  91684. getEngine(): Engine;
  91685. /**
  91686. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  91687. */
  91688. readonly dataSource: number;
  91689. /**
  91690. * Creates a new InternalTexture
  91691. * @param engine defines the engine to use
  91692. * @param dataSource defines the type of data that will be used
  91693. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91694. */
  91695. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  91696. /**
  91697. * Increments the number of references (ie. the number of Texture that point to it)
  91698. */
  91699. incrementReferences(): void;
  91700. /**
  91701. * Change the size of the texture (not the size of the content)
  91702. * @param width defines the new width
  91703. * @param height defines the new height
  91704. * @param depth defines the new depth (1 by default)
  91705. */
  91706. updateSize(width: int, height: int, depth?: int): void;
  91707. /** @hidden */
  91708. _rebuild(): void;
  91709. /** @hidden */
  91710. _swapAndDie(target: InternalTexture): void;
  91711. /**
  91712. * Dispose the current allocated resources
  91713. */
  91714. dispose(): void;
  91715. }
  91716. }
  91717. declare module BABYLON {
  91718. /**
  91719. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91720. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91721. */
  91722. export class EffectFallbacks {
  91723. private _defines;
  91724. private _currentRank;
  91725. private _maxRank;
  91726. private _mesh;
  91727. /**
  91728. * Removes the fallback from the bound mesh.
  91729. */
  91730. unBindMesh(): void;
  91731. /**
  91732. * Adds a fallback on the specified property.
  91733. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91734. * @param define The name of the define in the shader
  91735. */
  91736. addFallback(rank: number, define: string): void;
  91737. /**
  91738. * Sets the mesh to use CPU skinning when needing to fallback.
  91739. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91740. * @param mesh The mesh to use the fallbacks.
  91741. */
  91742. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91743. /**
  91744. * Checks to see if more fallbacks are still availible.
  91745. */
  91746. readonly isMoreFallbacks: boolean;
  91747. /**
  91748. * Removes the defines that should be removed when falling back.
  91749. * @param currentDefines defines the current define statements for the shader.
  91750. * @param effect defines the current effect we try to compile
  91751. * @returns The resulting defines with defines of the current rank removed.
  91752. */
  91753. reduce(currentDefines: string, effect: Effect): string;
  91754. }
  91755. /**
  91756. * Options to be used when creating an effect.
  91757. */
  91758. export class EffectCreationOptions {
  91759. /**
  91760. * Atrributes that will be used in the shader.
  91761. */
  91762. attributes: string[];
  91763. /**
  91764. * Uniform varible names that will be set in the shader.
  91765. */
  91766. uniformsNames: string[];
  91767. /**
  91768. * Uniform buffer varible names that will be set in the shader.
  91769. */
  91770. uniformBuffersNames: string[];
  91771. /**
  91772. * Sampler texture variable names that will be set in the shader.
  91773. */
  91774. samplers: string[];
  91775. /**
  91776. * Define statements that will be set in the shader.
  91777. */
  91778. defines: any;
  91779. /**
  91780. * Possible fallbacks for this effect to improve performance when needed.
  91781. */
  91782. fallbacks: Nullable<EffectFallbacks>;
  91783. /**
  91784. * Callback that will be called when the shader is compiled.
  91785. */
  91786. onCompiled: Nullable<(effect: Effect) => void>;
  91787. /**
  91788. * Callback that will be called if an error occurs during shader compilation.
  91789. */
  91790. onError: Nullable<(effect: Effect, errors: string) => void>;
  91791. /**
  91792. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91793. */
  91794. indexParameters: any;
  91795. /**
  91796. * Max number of lights that can be used in the shader.
  91797. */
  91798. maxSimultaneousLights: number;
  91799. /**
  91800. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91801. */
  91802. transformFeedbackVaryings: Nullable<string[]>;
  91803. }
  91804. /**
  91805. * Effect containing vertex and fragment shader that can be executed on an object.
  91806. */
  91807. export class Effect implements IDisposable {
  91808. /**
  91809. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91810. */
  91811. static ShadersRepository: string;
  91812. /**
  91813. * Name of the effect.
  91814. */
  91815. name: any;
  91816. /**
  91817. * String container all the define statements that should be set on the shader.
  91818. */
  91819. defines: string;
  91820. /**
  91821. * Callback that will be called when the shader is compiled.
  91822. */
  91823. onCompiled: Nullable<(effect: Effect) => void>;
  91824. /**
  91825. * Callback that will be called if an error occurs during shader compilation.
  91826. */
  91827. onError: Nullable<(effect: Effect, errors: string) => void>;
  91828. /**
  91829. * Callback that will be called when effect is bound.
  91830. */
  91831. onBind: Nullable<(effect: Effect) => void>;
  91832. /**
  91833. * Unique ID of the effect.
  91834. */
  91835. uniqueId: number;
  91836. /**
  91837. * Observable that will be called when the shader is compiled.
  91838. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91839. */
  91840. onCompileObservable: Observable<Effect>;
  91841. /**
  91842. * Observable that will be called if an error occurs during shader compilation.
  91843. */
  91844. onErrorObservable: Observable<Effect>;
  91845. /** @hidden */
  91846. _onBindObservable: Nullable<Observable<Effect>>;
  91847. /**
  91848. * Observable that will be called when effect is bound.
  91849. */
  91850. readonly onBindObservable: Observable<Effect>;
  91851. /** @hidden */
  91852. _bonesComputationForcedToCPU: boolean;
  91853. private static _uniqueIdSeed;
  91854. private _engine;
  91855. private _uniformBuffersNames;
  91856. private _uniformsNames;
  91857. private _samplerList;
  91858. private _samplers;
  91859. private _isReady;
  91860. private _compilationError;
  91861. private _attributesNames;
  91862. private _attributes;
  91863. private _uniforms;
  91864. /**
  91865. * Key for the effect.
  91866. * @hidden
  91867. */
  91868. _key: string;
  91869. private _indexParameters;
  91870. private _fallbacks;
  91871. private _vertexSourceCode;
  91872. private _fragmentSourceCode;
  91873. private _vertexSourceCodeOverride;
  91874. private _fragmentSourceCodeOverride;
  91875. private _transformFeedbackVaryings;
  91876. /**
  91877. * Compiled shader to webGL program.
  91878. * @hidden
  91879. */
  91880. _pipelineContext: Nullable<IPipelineContext>;
  91881. private _valueCache;
  91882. private static _baseCache;
  91883. /**
  91884. * Instantiates an effect.
  91885. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91886. * @param baseName Name of the effect.
  91887. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91888. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91889. * @param samplers List of sampler variables that will be passed to the shader.
  91890. * @param engine Engine to be used to render the effect
  91891. * @param defines Define statements to be added to the shader.
  91892. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91893. * @param onCompiled Callback that will be called when the shader is compiled.
  91894. * @param onError Callback that will be called if an error occurs during shader compilation.
  91895. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91896. */
  91897. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  91898. private _useFinalCode;
  91899. /**
  91900. * Unique key for this effect
  91901. */
  91902. readonly key: string;
  91903. /**
  91904. * If the effect has been compiled and prepared.
  91905. * @returns if the effect is compiled and prepared.
  91906. */
  91907. isReady(): boolean;
  91908. /**
  91909. * The engine the effect was initialized with.
  91910. * @returns the engine.
  91911. */
  91912. getEngine(): Engine;
  91913. /**
  91914. * The pipeline context for this effect
  91915. * @returns the associated pipeline context
  91916. */
  91917. getPipelineContext(): Nullable<IPipelineContext>;
  91918. /**
  91919. * The set of names of attribute variables for the shader.
  91920. * @returns An array of attribute names.
  91921. */
  91922. getAttributesNames(): string[];
  91923. /**
  91924. * Returns the attribute at the given index.
  91925. * @param index The index of the attribute.
  91926. * @returns The location of the attribute.
  91927. */
  91928. getAttributeLocation(index: number): number;
  91929. /**
  91930. * Returns the attribute based on the name of the variable.
  91931. * @param name of the attribute to look up.
  91932. * @returns the attribute location.
  91933. */
  91934. getAttributeLocationByName(name: string): number;
  91935. /**
  91936. * The number of attributes.
  91937. * @returns the numnber of attributes.
  91938. */
  91939. getAttributesCount(): number;
  91940. /**
  91941. * Gets the index of a uniform variable.
  91942. * @param uniformName of the uniform to look up.
  91943. * @returns the index.
  91944. */
  91945. getUniformIndex(uniformName: string): number;
  91946. /**
  91947. * Returns the attribute based on the name of the variable.
  91948. * @param uniformName of the uniform to look up.
  91949. * @returns the location of the uniform.
  91950. */
  91951. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  91952. /**
  91953. * Returns an array of sampler variable names
  91954. * @returns The array of sampler variable neames.
  91955. */
  91956. getSamplers(): string[];
  91957. /**
  91958. * The error from the last compilation.
  91959. * @returns the error string.
  91960. */
  91961. getCompilationError(): string;
  91962. /**
  91963. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  91964. * @param func The callback to be used.
  91965. */
  91966. executeWhenCompiled(func: (effect: Effect) => void): void;
  91967. private _checkIsReady;
  91968. /** @hidden */
  91969. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  91970. /** @hidden */
  91971. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  91972. /** @hidden */
  91973. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  91974. /**
  91975. * Recompiles the webGL program
  91976. * @param vertexSourceCode The source code for the vertex shader.
  91977. * @param fragmentSourceCode The source code for the fragment shader.
  91978. * @param onCompiled Callback called when completed.
  91979. * @param onError Callback called on error.
  91980. * @hidden
  91981. */
  91982. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  91983. /**
  91984. * Prepares the effect
  91985. * @hidden
  91986. */
  91987. _prepareEffect(): void;
  91988. /**
  91989. * Checks if the effect is supported. (Must be called after compilation)
  91990. */
  91991. readonly isSupported: boolean;
  91992. /**
  91993. * Binds a texture to the engine to be used as output of the shader.
  91994. * @param channel Name of the output variable.
  91995. * @param texture Texture to bind.
  91996. * @hidden
  91997. */
  91998. _bindTexture(channel: string, texture: InternalTexture): void;
  91999. /**
  92000. * Sets a texture on the engine to be used in the shader.
  92001. * @param channel Name of the sampler variable.
  92002. * @param texture Texture to set.
  92003. */
  92004. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92005. /**
  92006. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92007. * @param channel Name of the sampler variable.
  92008. * @param texture Texture to set.
  92009. */
  92010. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92011. /**
  92012. * Sets an array of textures on the engine to be used in the shader.
  92013. * @param channel Name of the variable.
  92014. * @param textures Textures to set.
  92015. */
  92016. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92017. /**
  92018. * 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)
  92019. * @param channel Name of the sampler variable.
  92020. * @param postProcess Post process to get the input texture from.
  92021. */
  92022. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92023. /**
  92024. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92025. * 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)
  92026. * @param channel Name of the sampler variable.
  92027. * @param postProcess Post process to get the output texture from.
  92028. */
  92029. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92030. /** @hidden */
  92031. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92032. /** @hidden */
  92033. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92034. /** @hidden */
  92035. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92036. /** @hidden */
  92037. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92038. /**
  92039. * Binds a buffer to a uniform.
  92040. * @param buffer Buffer to bind.
  92041. * @param name Name of the uniform variable to bind to.
  92042. */
  92043. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92044. /**
  92045. * Binds block to a uniform.
  92046. * @param blockName Name of the block to bind.
  92047. * @param index Index to bind.
  92048. */
  92049. bindUniformBlock(blockName: string, index: number): void;
  92050. /**
  92051. * Sets an interger value on a uniform variable.
  92052. * @param uniformName Name of the variable.
  92053. * @param value Value to be set.
  92054. * @returns this effect.
  92055. */
  92056. setInt(uniformName: string, value: number): Effect;
  92057. /**
  92058. * Sets an int array on a uniform variable.
  92059. * @param uniformName Name of the variable.
  92060. * @param array array to be set.
  92061. * @returns this effect.
  92062. */
  92063. setIntArray(uniformName: string, array: Int32Array): Effect;
  92064. /**
  92065. * 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)
  92066. * @param uniformName Name of the variable.
  92067. * @param array array to be set.
  92068. * @returns this effect.
  92069. */
  92070. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92071. /**
  92072. * 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)
  92073. * @param uniformName Name of the variable.
  92074. * @param array array to be set.
  92075. * @returns this effect.
  92076. */
  92077. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92078. /**
  92079. * 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)
  92080. * @param uniformName Name of the variable.
  92081. * @param array array to be set.
  92082. * @returns this effect.
  92083. */
  92084. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92085. /**
  92086. * Sets an float array on a uniform variable.
  92087. * @param uniformName Name of the variable.
  92088. * @param array array to be set.
  92089. * @returns this effect.
  92090. */
  92091. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92092. /**
  92093. * 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)
  92094. * @param uniformName Name of the variable.
  92095. * @param array array to be set.
  92096. * @returns this effect.
  92097. */
  92098. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92099. /**
  92100. * 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)
  92101. * @param uniformName Name of the variable.
  92102. * @param array array to be set.
  92103. * @returns this effect.
  92104. */
  92105. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92106. /**
  92107. * 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)
  92108. * @param uniformName Name of the variable.
  92109. * @param array array to be set.
  92110. * @returns this effect.
  92111. */
  92112. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92113. /**
  92114. * Sets an array on a uniform variable.
  92115. * @param uniformName Name of the variable.
  92116. * @param array array to be set.
  92117. * @returns this effect.
  92118. */
  92119. setArray(uniformName: string, array: number[]): Effect;
  92120. /**
  92121. * 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)
  92122. * @param uniformName Name of the variable.
  92123. * @param array array to be set.
  92124. * @returns this effect.
  92125. */
  92126. setArray2(uniformName: string, array: number[]): Effect;
  92127. /**
  92128. * 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)
  92129. * @param uniformName Name of the variable.
  92130. * @param array array to be set.
  92131. * @returns this effect.
  92132. */
  92133. setArray3(uniformName: string, array: number[]): Effect;
  92134. /**
  92135. * 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)
  92136. * @param uniformName Name of the variable.
  92137. * @param array array to be set.
  92138. * @returns this effect.
  92139. */
  92140. setArray4(uniformName: string, array: number[]): Effect;
  92141. /**
  92142. * Sets matrices on a uniform variable.
  92143. * @param uniformName Name of the variable.
  92144. * @param matrices matrices to be set.
  92145. * @returns this effect.
  92146. */
  92147. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92148. /**
  92149. * Sets matrix on a uniform variable.
  92150. * @param uniformName Name of the variable.
  92151. * @param matrix matrix to be set.
  92152. * @returns this effect.
  92153. */
  92154. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  92155. /**
  92156. * 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)
  92157. * @param uniformName Name of the variable.
  92158. * @param matrix matrix to be set.
  92159. * @returns this effect.
  92160. */
  92161. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92162. /**
  92163. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92164. * @param uniformName Name of the variable.
  92165. * @param matrix matrix to be set.
  92166. * @returns this effect.
  92167. */
  92168. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92169. /**
  92170. * Sets a float on a uniform variable.
  92171. * @param uniformName Name of the variable.
  92172. * @param value value to be set.
  92173. * @returns this effect.
  92174. */
  92175. setFloat(uniformName: string, value: number): Effect;
  92176. /**
  92177. * Sets a boolean on a uniform variable.
  92178. * @param uniformName Name of the variable.
  92179. * @param bool value to be set.
  92180. * @returns this effect.
  92181. */
  92182. setBool(uniformName: string, bool: boolean): Effect;
  92183. /**
  92184. * Sets a Vector2 on a uniform variable.
  92185. * @param uniformName Name of the variable.
  92186. * @param vector2 vector2 to be set.
  92187. * @returns this effect.
  92188. */
  92189. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  92190. /**
  92191. * Sets a float2 on a uniform variable.
  92192. * @param uniformName Name of the variable.
  92193. * @param x First float in float2.
  92194. * @param y Second float in float2.
  92195. * @returns this effect.
  92196. */
  92197. setFloat2(uniformName: string, x: number, y: number): Effect;
  92198. /**
  92199. * Sets a Vector3 on a uniform variable.
  92200. * @param uniformName Name of the variable.
  92201. * @param vector3 Value to be set.
  92202. * @returns this effect.
  92203. */
  92204. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  92205. /**
  92206. * Sets a float3 on a uniform variable.
  92207. * @param uniformName Name of the variable.
  92208. * @param x First float in float3.
  92209. * @param y Second float in float3.
  92210. * @param z Third float in float3.
  92211. * @returns this effect.
  92212. */
  92213. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92214. /**
  92215. * Sets a Vector4 on a uniform variable.
  92216. * @param uniformName Name of the variable.
  92217. * @param vector4 Value to be set.
  92218. * @returns this effect.
  92219. */
  92220. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  92221. /**
  92222. * Sets a float4 on a uniform variable.
  92223. * @param uniformName Name of the variable.
  92224. * @param x First float in float4.
  92225. * @param y Second float in float4.
  92226. * @param z Third float in float4.
  92227. * @param w Fourth float in float4.
  92228. * @returns this effect.
  92229. */
  92230. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92231. /**
  92232. * Sets a Color3 on a uniform variable.
  92233. * @param uniformName Name of the variable.
  92234. * @param color3 Value to be set.
  92235. * @returns this effect.
  92236. */
  92237. setColor3(uniformName: string, color3: IColor3Like): Effect;
  92238. /**
  92239. * Sets a Color4 on a uniform variable.
  92240. * @param uniformName Name of the variable.
  92241. * @param color3 Value to be set.
  92242. * @param alpha Alpha value to be set.
  92243. * @returns this effect.
  92244. */
  92245. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  92246. /**
  92247. * Sets a Color4 on a uniform variable
  92248. * @param uniformName defines the name of the variable
  92249. * @param color4 defines the value to be set
  92250. * @returns this effect.
  92251. */
  92252. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  92253. /** Release all associated resources */
  92254. dispose(): void;
  92255. /**
  92256. * This function will add a new shader to the shader store
  92257. * @param name the name of the shader
  92258. * @param pixelShader optional pixel shader content
  92259. * @param vertexShader optional vertex shader content
  92260. */
  92261. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92262. /**
  92263. * Store of each shader (The can be looked up using effect.key)
  92264. */
  92265. static ShadersStore: {
  92266. [key: string]: string;
  92267. };
  92268. /**
  92269. * Store of each included file for a shader (The can be looked up using effect.key)
  92270. */
  92271. static IncludesShadersStore: {
  92272. [key: string]: string;
  92273. };
  92274. /**
  92275. * Resets the cache of effects.
  92276. */
  92277. static ResetCache(): void;
  92278. }
  92279. }
  92280. declare module BABYLON {
  92281. /**
  92282. * Uniform buffer objects.
  92283. *
  92284. * Handles blocks of uniform on the GPU.
  92285. *
  92286. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92287. *
  92288. * For more information, please refer to :
  92289. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92290. */
  92291. export class UniformBuffer {
  92292. private _engine;
  92293. private _buffer;
  92294. private _data;
  92295. private _bufferData;
  92296. private _dynamic?;
  92297. private _uniformLocations;
  92298. private _uniformSizes;
  92299. private _uniformLocationPointer;
  92300. private _needSync;
  92301. private _noUBO;
  92302. private _currentEffect;
  92303. private static _MAX_UNIFORM_SIZE;
  92304. private static _tempBuffer;
  92305. /**
  92306. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92307. * This is dynamic to allow compat with webgl 1 and 2.
  92308. * You will need to pass the name of the uniform as well as the value.
  92309. */
  92310. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92311. /**
  92312. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92313. * This is dynamic to allow compat with webgl 1 and 2.
  92314. * You will need to pass the name of the uniform as well as the value.
  92315. */
  92316. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92317. /**
  92318. * Lambda to Update a single float in a uniform buffer.
  92319. * This is dynamic to allow compat with webgl 1 and 2.
  92320. * You will need to pass the name of the uniform as well as the value.
  92321. */
  92322. updateFloat: (name: string, x: number) => void;
  92323. /**
  92324. * Lambda to Update a vec2 of float in a uniform buffer.
  92325. * This is dynamic to allow compat with webgl 1 and 2.
  92326. * You will need to pass the name of the uniform as well as the value.
  92327. */
  92328. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92329. /**
  92330. * Lambda to Update a vec3 of float in a uniform buffer.
  92331. * This is dynamic to allow compat with webgl 1 and 2.
  92332. * You will need to pass the name of the uniform as well as the value.
  92333. */
  92334. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92335. /**
  92336. * Lambda to Update a vec4 of float in a uniform buffer.
  92337. * This is dynamic to allow compat with webgl 1 and 2.
  92338. * You will need to pass the name of the uniform as well as the value.
  92339. */
  92340. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92341. /**
  92342. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92343. * This is dynamic to allow compat with webgl 1 and 2.
  92344. * You will need to pass the name of the uniform as well as the value.
  92345. */
  92346. updateMatrix: (name: string, mat: Matrix) => void;
  92347. /**
  92348. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92349. * This is dynamic to allow compat with webgl 1 and 2.
  92350. * You will need to pass the name of the uniform as well as the value.
  92351. */
  92352. updateVector3: (name: string, vector: Vector3) => void;
  92353. /**
  92354. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92355. * This is dynamic to allow compat with webgl 1 and 2.
  92356. * You will need to pass the name of the uniform as well as the value.
  92357. */
  92358. updateVector4: (name: string, vector: Vector4) => void;
  92359. /**
  92360. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92361. * This is dynamic to allow compat with webgl 1 and 2.
  92362. * You will need to pass the name of the uniform as well as the value.
  92363. */
  92364. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92365. /**
  92366. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92367. * This is dynamic to allow compat with webgl 1 and 2.
  92368. * You will need to pass the name of the uniform as well as the value.
  92369. */
  92370. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92371. /**
  92372. * Instantiates a new Uniform buffer objects.
  92373. *
  92374. * Handles blocks of uniform on the GPU.
  92375. *
  92376. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92377. *
  92378. * For more information, please refer to :
  92379. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92380. * @param engine Define the engine the buffer is associated with
  92381. * @param data Define the data contained in the buffer
  92382. * @param dynamic Define if the buffer is updatable
  92383. */
  92384. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  92385. /**
  92386. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92387. * or just falling back on setUniformXXX calls.
  92388. */
  92389. readonly useUbo: boolean;
  92390. /**
  92391. * Indicates if the WebGL underlying uniform buffer is in sync
  92392. * with the javascript cache data.
  92393. */
  92394. readonly isSync: boolean;
  92395. /**
  92396. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92397. * Also, a dynamic UniformBuffer will disable cache verification and always
  92398. * update the underlying WebGL uniform buffer to the GPU.
  92399. * @returns if Dynamic, otherwise false
  92400. */
  92401. isDynamic(): boolean;
  92402. /**
  92403. * The data cache on JS side.
  92404. * @returns the underlying data as a float array
  92405. */
  92406. getData(): Float32Array;
  92407. /**
  92408. * The underlying WebGL Uniform buffer.
  92409. * @returns the webgl buffer
  92410. */
  92411. getBuffer(): Nullable<DataBuffer>;
  92412. /**
  92413. * std140 layout specifies how to align data within an UBO structure.
  92414. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  92415. * for specs.
  92416. */
  92417. private _fillAlignment;
  92418. /**
  92419. * Adds an uniform in the buffer.
  92420. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  92421. * for the layout to be correct !
  92422. * @param name Name of the uniform, as used in the uniform block in the shader.
  92423. * @param size Data size, or data directly.
  92424. */
  92425. addUniform(name: string, size: number | number[]): void;
  92426. /**
  92427. * Adds a Matrix 4x4 to the uniform buffer.
  92428. * @param name Name of the uniform, as used in the uniform block in the shader.
  92429. * @param mat A 4x4 matrix.
  92430. */
  92431. addMatrix(name: string, mat: Matrix): void;
  92432. /**
  92433. * Adds a vec2 to the uniform buffer.
  92434. * @param name Name of the uniform, as used in the uniform block in the shader.
  92435. * @param x Define the x component value of the vec2
  92436. * @param y Define the y component value of the vec2
  92437. */
  92438. addFloat2(name: string, x: number, y: number): void;
  92439. /**
  92440. * Adds a vec3 to the uniform buffer.
  92441. * @param name Name of the uniform, as used in the uniform block in the shader.
  92442. * @param x Define the x component value of the vec3
  92443. * @param y Define the y component value of the vec3
  92444. * @param z Define the z component value of the vec3
  92445. */
  92446. addFloat3(name: string, x: number, y: number, z: number): void;
  92447. /**
  92448. * Adds a vec3 to the uniform buffer.
  92449. * @param name Name of the uniform, as used in the uniform block in the shader.
  92450. * @param color Define the vec3 from a Color
  92451. */
  92452. addColor3(name: string, color: Color3): void;
  92453. /**
  92454. * Adds a vec4 to the uniform buffer.
  92455. * @param name Name of the uniform, as used in the uniform block in the shader.
  92456. * @param color Define the rgb components from a Color
  92457. * @param alpha Define the a component of the vec4
  92458. */
  92459. addColor4(name: string, color: Color3, alpha: number): void;
  92460. /**
  92461. * Adds a vec3 to the uniform buffer.
  92462. * @param name Name of the uniform, as used in the uniform block in the shader.
  92463. * @param vector Define the vec3 components from a Vector
  92464. */
  92465. addVector3(name: string, vector: Vector3): void;
  92466. /**
  92467. * Adds a Matrix 3x3 to the uniform buffer.
  92468. * @param name Name of the uniform, as used in the uniform block in the shader.
  92469. */
  92470. addMatrix3x3(name: string): void;
  92471. /**
  92472. * Adds a Matrix 2x2 to the uniform buffer.
  92473. * @param name Name of the uniform, as used in the uniform block in the shader.
  92474. */
  92475. addMatrix2x2(name: string): void;
  92476. /**
  92477. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  92478. */
  92479. create(): void;
  92480. /** @hidden */
  92481. _rebuild(): void;
  92482. /**
  92483. * Updates the WebGL Uniform Buffer on the GPU.
  92484. * If the `dynamic` flag is set to true, no cache comparison is done.
  92485. * Otherwise, the buffer will be updated only if the cache differs.
  92486. */
  92487. update(): void;
  92488. /**
  92489. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  92490. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92491. * @param data Define the flattened data
  92492. * @param size Define the size of the data.
  92493. */
  92494. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  92495. private _updateMatrix3x3ForUniform;
  92496. private _updateMatrix3x3ForEffect;
  92497. private _updateMatrix2x2ForEffect;
  92498. private _updateMatrix2x2ForUniform;
  92499. private _updateFloatForEffect;
  92500. private _updateFloatForUniform;
  92501. private _updateFloat2ForEffect;
  92502. private _updateFloat2ForUniform;
  92503. private _updateFloat3ForEffect;
  92504. private _updateFloat3ForUniform;
  92505. private _updateFloat4ForEffect;
  92506. private _updateFloat4ForUniform;
  92507. private _updateMatrixForEffect;
  92508. private _updateMatrixForUniform;
  92509. private _updateVector3ForEffect;
  92510. private _updateVector3ForUniform;
  92511. private _updateVector4ForEffect;
  92512. private _updateVector4ForUniform;
  92513. private _updateColor3ForEffect;
  92514. private _updateColor3ForUniform;
  92515. private _updateColor4ForEffect;
  92516. private _updateColor4ForUniform;
  92517. /**
  92518. * Sets a sampler uniform on the effect.
  92519. * @param name Define the name of the sampler.
  92520. * @param texture Define the texture to set in the sampler
  92521. */
  92522. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  92523. /**
  92524. * Directly updates the value of the uniform in the cache AND on the GPU.
  92525. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92526. * @param data Define the flattened data
  92527. */
  92528. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  92529. /**
  92530. * Binds this uniform buffer to an effect.
  92531. * @param effect Define the effect to bind the buffer to
  92532. * @param name Name of the uniform block in the shader.
  92533. */
  92534. bindToEffect(effect: Effect, name: string): void;
  92535. /**
  92536. * Disposes the uniform buffer.
  92537. */
  92538. dispose(): void;
  92539. }
  92540. }
  92541. declare module BABYLON {
  92542. /**
  92543. * Class used to work with sound analyzer using fast fourier transform (FFT)
  92544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92545. */
  92546. export class Analyser {
  92547. /**
  92548. * Gets or sets the smoothing
  92549. * @ignorenaming
  92550. */
  92551. SMOOTHING: number;
  92552. /**
  92553. * Gets or sets the FFT table size
  92554. * @ignorenaming
  92555. */
  92556. FFT_SIZE: number;
  92557. /**
  92558. * Gets or sets the bar graph amplitude
  92559. * @ignorenaming
  92560. */
  92561. BARGRAPHAMPLITUDE: number;
  92562. /**
  92563. * Gets or sets the position of the debug canvas
  92564. * @ignorenaming
  92565. */
  92566. DEBUGCANVASPOS: {
  92567. x: number;
  92568. y: number;
  92569. };
  92570. /**
  92571. * Gets or sets the debug canvas size
  92572. * @ignorenaming
  92573. */
  92574. DEBUGCANVASSIZE: {
  92575. width: number;
  92576. height: number;
  92577. };
  92578. private _byteFreqs;
  92579. private _byteTime;
  92580. private _floatFreqs;
  92581. private _webAudioAnalyser;
  92582. private _debugCanvas;
  92583. private _debugCanvasContext;
  92584. private _scene;
  92585. private _registerFunc;
  92586. private _audioEngine;
  92587. /**
  92588. * Creates a new analyser
  92589. * @param scene defines hosting scene
  92590. */
  92591. constructor(scene: Scene);
  92592. /**
  92593. * Get the number of data values you will have to play with for the visualization
  92594. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  92595. * @returns a number
  92596. */
  92597. getFrequencyBinCount(): number;
  92598. /**
  92599. * Gets the current frequency data as a byte array
  92600. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92601. * @returns a Uint8Array
  92602. */
  92603. getByteFrequencyData(): Uint8Array;
  92604. /**
  92605. * Gets the current waveform as a byte array
  92606. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  92607. * @returns a Uint8Array
  92608. */
  92609. getByteTimeDomainData(): Uint8Array;
  92610. /**
  92611. * Gets the current frequency data as a float array
  92612. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92613. * @returns a Float32Array
  92614. */
  92615. getFloatFrequencyData(): Float32Array;
  92616. /**
  92617. * Renders the debug canvas
  92618. */
  92619. drawDebugCanvas(): void;
  92620. /**
  92621. * Stops rendering the debug canvas and removes it
  92622. */
  92623. stopDebugCanvas(): void;
  92624. /**
  92625. * Connects two audio nodes
  92626. * @param inputAudioNode defines first node to connect
  92627. * @param outputAudioNode defines second node to connect
  92628. */
  92629. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  92630. /**
  92631. * Releases all associated resources
  92632. */
  92633. dispose(): void;
  92634. }
  92635. }
  92636. declare module BABYLON {
  92637. /**
  92638. * This represents an audio engine and it is responsible
  92639. * to play, synchronize and analyse sounds throughout the application.
  92640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92641. */
  92642. export interface IAudioEngine extends IDisposable {
  92643. /**
  92644. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92645. */
  92646. readonly canUseWebAudio: boolean;
  92647. /**
  92648. * Gets the current AudioContext if available.
  92649. */
  92650. readonly audioContext: Nullable<AudioContext>;
  92651. /**
  92652. * The master gain node defines the global audio volume of your audio engine.
  92653. */
  92654. readonly masterGain: GainNode;
  92655. /**
  92656. * Gets whether or not mp3 are supported by your browser.
  92657. */
  92658. readonly isMP3supported: boolean;
  92659. /**
  92660. * Gets whether or not ogg are supported by your browser.
  92661. */
  92662. readonly isOGGsupported: boolean;
  92663. /**
  92664. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92665. * @ignoreNaming
  92666. */
  92667. WarnedWebAudioUnsupported: boolean;
  92668. /**
  92669. * Defines if the audio engine relies on a custom unlocked button.
  92670. * In this case, the embedded button will not be displayed.
  92671. */
  92672. useCustomUnlockedButton: boolean;
  92673. /**
  92674. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  92675. */
  92676. readonly unlocked: boolean;
  92677. /**
  92678. * Event raised when audio has been unlocked on the browser.
  92679. */
  92680. onAudioUnlockedObservable: Observable<AudioEngine>;
  92681. /**
  92682. * Event raised when audio has been locked on the browser.
  92683. */
  92684. onAudioLockedObservable: Observable<AudioEngine>;
  92685. /**
  92686. * Flags the audio engine in Locked state.
  92687. * This happens due to new browser policies preventing audio to autoplay.
  92688. */
  92689. lock(): void;
  92690. /**
  92691. * Unlocks the audio engine once a user action has been done on the dom.
  92692. * This is helpful to resume play once browser policies have been satisfied.
  92693. */
  92694. unlock(): void;
  92695. }
  92696. /**
  92697. * This represents the default audio engine used in babylon.
  92698. * It is responsible to play, synchronize and analyse sounds throughout the application.
  92699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92700. */
  92701. export class AudioEngine implements IAudioEngine {
  92702. private _audioContext;
  92703. private _audioContextInitialized;
  92704. private _muteButton;
  92705. private _hostElement;
  92706. /**
  92707. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92708. */
  92709. canUseWebAudio: boolean;
  92710. /**
  92711. * The master gain node defines the global audio volume of your audio engine.
  92712. */
  92713. masterGain: GainNode;
  92714. /**
  92715. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92716. * @ignoreNaming
  92717. */
  92718. WarnedWebAudioUnsupported: boolean;
  92719. /**
  92720. * Gets whether or not mp3 are supported by your browser.
  92721. */
  92722. isMP3supported: boolean;
  92723. /**
  92724. * Gets whether or not ogg are supported by your browser.
  92725. */
  92726. isOGGsupported: boolean;
  92727. /**
  92728. * Gets whether audio has been unlocked on the device.
  92729. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  92730. * a user interaction has happened.
  92731. */
  92732. unlocked: boolean;
  92733. /**
  92734. * Defines if the audio engine relies on a custom unlocked button.
  92735. * In this case, the embedded button will not be displayed.
  92736. */
  92737. useCustomUnlockedButton: boolean;
  92738. /**
  92739. * Event raised when audio has been unlocked on the browser.
  92740. */
  92741. onAudioUnlockedObservable: Observable<AudioEngine>;
  92742. /**
  92743. * Event raised when audio has been locked on the browser.
  92744. */
  92745. onAudioLockedObservable: Observable<AudioEngine>;
  92746. /**
  92747. * Gets the current AudioContext if available.
  92748. */
  92749. readonly audioContext: Nullable<AudioContext>;
  92750. private _connectedAnalyser;
  92751. /**
  92752. * Instantiates a new audio engine.
  92753. *
  92754. * There should be only one per page as some browsers restrict the number
  92755. * of audio contexts you can create.
  92756. * @param hostElement defines the host element where to display the mute icon if necessary
  92757. */
  92758. constructor(hostElement?: Nullable<HTMLElement>);
  92759. /**
  92760. * Flags the audio engine in Locked state.
  92761. * This happens due to new browser policies preventing audio to autoplay.
  92762. */
  92763. lock(): void;
  92764. /**
  92765. * Unlocks the audio engine once a user action has been done on the dom.
  92766. * This is helpful to resume play once browser policies have been satisfied.
  92767. */
  92768. unlock(): void;
  92769. private _resumeAudioContext;
  92770. private _initializeAudioContext;
  92771. private _tryToRun;
  92772. private _triggerRunningState;
  92773. private _triggerSuspendedState;
  92774. private _displayMuteButton;
  92775. private _moveButtonToTopLeft;
  92776. private _onResize;
  92777. private _hideMuteButton;
  92778. /**
  92779. * Destroy and release the resources associated with the audio ccontext.
  92780. */
  92781. dispose(): void;
  92782. /**
  92783. * Gets the global volume sets on the master gain.
  92784. * @returns the global volume if set or -1 otherwise
  92785. */
  92786. getGlobalVolume(): number;
  92787. /**
  92788. * Sets the global volume of your experience (sets on the master gain).
  92789. * @param newVolume Defines the new global volume of the application
  92790. */
  92791. setGlobalVolume(newVolume: number): void;
  92792. /**
  92793. * Connect the audio engine to an audio analyser allowing some amazing
  92794. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92796. * @param analyser The analyser to connect to the engine
  92797. */
  92798. connectToAnalyser(analyser: Analyser): void;
  92799. }
  92800. }
  92801. declare module BABYLON {
  92802. /**
  92803. * Interface used to present a loading screen while loading a scene
  92804. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92805. */
  92806. export interface ILoadingScreen {
  92807. /**
  92808. * Function called to display the loading screen
  92809. */
  92810. displayLoadingUI: () => void;
  92811. /**
  92812. * Function called to hide the loading screen
  92813. */
  92814. hideLoadingUI: () => void;
  92815. /**
  92816. * Gets or sets the color to use for the background
  92817. */
  92818. loadingUIBackgroundColor: string;
  92819. /**
  92820. * Gets or sets the text to display while loading
  92821. */
  92822. loadingUIText: string;
  92823. }
  92824. /**
  92825. * Class used for the default loading screen
  92826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92827. */
  92828. export class DefaultLoadingScreen implements ILoadingScreen {
  92829. private _renderingCanvas;
  92830. private _loadingText;
  92831. private _loadingDivBackgroundColor;
  92832. private _loadingDiv;
  92833. private _loadingTextDiv;
  92834. /** Gets or sets the logo url to use for the default loading screen */
  92835. static DefaultLogoUrl: string;
  92836. /** Gets or sets the spinner url to use for the default loading screen */
  92837. static DefaultSpinnerUrl: string;
  92838. /**
  92839. * Creates a new default loading screen
  92840. * @param _renderingCanvas defines the canvas used to render the scene
  92841. * @param _loadingText defines the default text to display
  92842. * @param _loadingDivBackgroundColor defines the default background color
  92843. */
  92844. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  92845. /**
  92846. * Function called to display the loading screen
  92847. */
  92848. displayLoadingUI(): void;
  92849. /**
  92850. * Function called to hide the loading screen
  92851. */
  92852. hideLoadingUI(): void;
  92853. /**
  92854. * Gets or sets the text to display while loading
  92855. */
  92856. loadingUIText: string;
  92857. /**
  92858. * Gets or sets the color to use for the background
  92859. */
  92860. loadingUIBackgroundColor: string;
  92861. private _resizeLoadingUI;
  92862. }
  92863. }
  92864. declare module BABYLON {
  92865. /** @hidden */
  92866. export class WebGLPipelineContext implements IPipelineContext {
  92867. engine: Engine;
  92868. program: Nullable<WebGLProgram>;
  92869. context?: WebGLRenderingContext;
  92870. vertexShader?: WebGLShader;
  92871. fragmentShader?: WebGLShader;
  92872. isParallelCompiled: boolean;
  92873. onCompiled?: () => void;
  92874. transformFeedback?: WebGLTransformFeedback | null;
  92875. readonly isAsync: boolean;
  92876. readonly isReady: boolean;
  92877. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  92878. }
  92879. }
  92880. declare module BABYLON {
  92881. /** @hidden */
  92882. export class WebGLDataBuffer extends DataBuffer {
  92883. private _buffer;
  92884. constructor(resource: WebGLBuffer);
  92885. readonly underlyingResource: any;
  92886. }
  92887. }
  92888. declare module BABYLON {
  92889. /** @hidden */
  92890. export class WebGL2ShaderProcessor implements IShaderProcessor {
  92891. attributeProcessor(attribute: string): string;
  92892. varyingProcessor(varying: string, isFragment: boolean): string;
  92893. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  92894. }
  92895. }
  92896. declare module BABYLON {
  92897. /**
  92898. * This class is used to track a performance counter which is number based.
  92899. * The user has access to many properties which give statistics of different nature.
  92900. *
  92901. * The implementer can track two kinds of Performance Counter: time and count.
  92902. * 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.
  92903. * 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.
  92904. */
  92905. export class PerfCounter {
  92906. /**
  92907. * Gets or sets a global boolean to turn on and off all the counters
  92908. */
  92909. static Enabled: boolean;
  92910. /**
  92911. * Returns the smallest value ever
  92912. */
  92913. readonly min: number;
  92914. /**
  92915. * Returns the biggest value ever
  92916. */
  92917. readonly max: number;
  92918. /**
  92919. * Returns the average value since the performance counter is running
  92920. */
  92921. readonly average: number;
  92922. /**
  92923. * Returns the average value of the last second the counter was monitored
  92924. */
  92925. readonly lastSecAverage: number;
  92926. /**
  92927. * Returns the current value
  92928. */
  92929. readonly current: number;
  92930. /**
  92931. * Gets the accumulated total
  92932. */
  92933. readonly total: number;
  92934. /**
  92935. * Gets the total value count
  92936. */
  92937. readonly count: number;
  92938. /**
  92939. * Creates a new counter
  92940. */
  92941. constructor();
  92942. /**
  92943. * Call this method to start monitoring a new frame.
  92944. * 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.
  92945. */
  92946. fetchNewFrame(): void;
  92947. /**
  92948. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  92949. * @param newCount the count value to add to the monitored count
  92950. * @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.
  92951. */
  92952. addCount(newCount: number, fetchResult: boolean): void;
  92953. /**
  92954. * Start monitoring this performance counter
  92955. */
  92956. beginMonitoring(): void;
  92957. /**
  92958. * Compute the time lapsed since the previous beginMonitoring() call.
  92959. * @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
  92960. */
  92961. endMonitoring(newFrame?: boolean): void;
  92962. private _fetchResult;
  92963. private _startMonitoringTime;
  92964. private _min;
  92965. private _max;
  92966. private _average;
  92967. private _current;
  92968. private _totalValueCount;
  92969. private _totalAccumulated;
  92970. private _lastSecAverage;
  92971. private _lastSecAccumulated;
  92972. private _lastSecTime;
  92973. private _lastSecValueCount;
  92974. }
  92975. }
  92976. declare module BABYLON {
  92977. /**
  92978. * Interface for any object that can request an animation frame
  92979. */
  92980. export interface ICustomAnimationFrameRequester {
  92981. /**
  92982. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  92983. */
  92984. renderFunction?: Function;
  92985. /**
  92986. * Called to request the next frame to render to
  92987. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  92988. */
  92989. requestAnimationFrame: Function;
  92990. /**
  92991. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  92992. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  92993. */
  92994. requestID?: number;
  92995. }
  92996. }
  92997. declare module BABYLON {
  92998. /**
  92999. * Settings for finer control over video usage
  93000. */
  93001. export interface VideoTextureSettings {
  93002. /**
  93003. * Applies `autoplay` to video, if specified
  93004. */
  93005. autoPlay?: boolean;
  93006. /**
  93007. * Applies `loop` to video, if specified
  93008. */
  93009. loop?: boolean;
  93010. /**
  93011. * Automatically updates internal texture from video at every frame in the render loop
  93012. */
  93013. autoUpdateTexture: boolean;
  93014. /**
  93015. * Image src displayed during the video loading or until the user interacts with the video.
  93016. */
  93017. poster?: string;
  93018. }
  93019. /**
  93020. * If you want to display a video in your scene, this is the special texture for that.
  93021. * This special texture works similar to other textures, with the exception of a few parameters.
  93022. * @see https://doc.babylonjs.com/how_to/video_texture
  93023. */
  93024. export class VideoTexture extends Texture {
  93025. /**
  93026. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93027. */
  93028. readonly autoUpdateTexture: boolean;
  93029. /**
  93030. * The video instance used by the texture internally
  93031. */
  93032. readonly video: HTMLVideoElement;
  93033. private _onUserActionRequestedObservable;
  93034. /**
  93035. * Event triggerd when a dom action is required by the user to play the video.
  93036. * This happens due to recent changes in browser policies preventing video to auto start.
  93037. */
  93038. readonly onUserActionRequestedObservable: Observable<Texture>;
  93039. private _generateMipMaps;
  93040. private _engine;
  93041. private _stillImageCaptured;
  93042. private _displayingPosterTexture;
  93043. private _settings;
  93044. private _createInternalTextureOnEvent;
  93045. /**
  93046. * Creates a video texture.
  93047. * If you want to display a video in your scene, this is the special texture for that.
  93048. * This special texture works similar to other textures, with the exception of a few parameters.
  93049. * @see https://doc.babylonjs.com/how_to/video_texture
  93050. * @param name optional name, will detect from video source, if not defined
  93051. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93052. * @param scene is obviously the current scene.
  93053. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93054. * @param invertY is false by default but can be used to invert video on Y axis
  93055. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93056. * @param settings allows finer control over video usage
  93057. */
  93058. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93059. private _getName;
  93060. private _getVideo;
  93061. private _createInternalTexture;
  93062. private reset;
  93063. /**
  93064. * @hidden Internal method to initiate `update`.
  93065. */
  93066. _rebuild(): void;
  93067. /**
  93068. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93069. */
  93070. update(): void;
  93071. /**
  93072. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93073. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93074. */
  93075. updateTexture(isVisible: boolean): void;
  93076. protected _updateInternalTexture: () => void;
  93077. /**
  93078. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93079. * @param url New url.
  93080. */
  93081. updateURL(url: string): void;
  93082. /**
  93083. * Dispose the texture and release its associated resources.
  93084. */
  93085. dispose(): void;
  93086. /**
  93087. * Creates a video texture straight from a stream.
  93088. * @param scene Define the scene the texture should be created in
  93089. * @param stream Define the stream the texture should be created from
  93090. * @returns The created video texture as a promise
  93091. */
  93092. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  93093. /**
  93094. * Creates a video texture straight from your WebCam video feed.
  93095. * @param scene Define the scene the texture should be created in
  93096. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93097. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93098. * @returns The created video texture as a promise
  93099. */
  93100. static CreateFromWebCamAsync(scene: Scene, constraints: {
  93101. minWidth: number;
  93102. maxWidth: number;
  93103. minHeight: number;
  93104. maxHeight: number;
  93105. deviceId: string;
  93106. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  93107. /**
  93108. * Creates a video texture straight from your WebCam video feed.
  93109. * @param scene Define the scene the texture should be created in
  93110. * @param onReady Define a callback to triggered once the texture will be ready
  93111. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93112. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93113. */
  93114. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  93115. minWidth: number;
  93116. maxWidth: number;
  93117. minHeight: number;
  93118. maxHeight: number;
  93119. deviceId: string;
  93120. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  93121. }
  93122. }
  93123. declare module BABYLON {
  93124. /**
  93125. * Defines the interface used by objects containing a viewport (like a camera)
  93126. */
  93127. interface IViewportOwnerLike {
  93128. /**
  93129. * Gets or sets the viewport
  93130. */
  93131. viewport: IViewportLike;
  93132. }
  93133. /**
  93134. * Interface for attribute information associated with buffer instanciation
  93135. */
  93136. export class InstancingAttributeInfo {
  93137. /**
  93138. * Index/offset of the attribute in the vertex shader
  93139. */
  93140. index: number;
  93141. /**
  93142. * size of the attribute, 1, 2, 3 or 4
  93143. */
  93144. attributeSize: number;
  93145. /**
  93146. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  93147. * default is FLOAT
  93148. */
  93149. attribyteType: number;
  93150. /**
  93151. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  93152. */
  93153. normalized: boolean;
  93154. /**
  93155. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  93156. */
  93157. offset: number;
  93158. /**
  93159. * Name of the GLSL attribute, for debugging purpose only
  93160. */
  93161. attributeName: string;
  93162. }
  93163. /**
  93164. * Define options used to create a depth texture
  93165. */
  93166. export class DepthTextureCreationOptions {
  93167. /** Specifies whether or not a stencil should be allocated in the texture */
  93168. generateStencil?: boolean;
  93169. /** Specifies whether or not bilinear filtering is enable on the texture */
  93170. bilinearFiltering?: boolean;
  93171. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  93172. comparisonFunction?: number;
  93173. /** Specifies if the created texture is a cube texture */
  93174. isCube?: boolean;
  93175. }
  93176. /**
  93177. * Class used to describe the capabilities of the engine relatively to the current browser
  93178. */
  93179. export class EngineCapabilities {
  93180. /** Maximum textures units per fragment shader */
  93181. maxTexturesImageUnits: number;
  93182. /** Maximum texture units per vertex shader */
  93183. maxVertexTextureImageUnits: number;
  93184. /** Maximum textures units in the entire pipeline */
  93185. maxCombinedTexturesImageUnits: number;
  93186. /** Maximum texture size */
  93187. maxTextureSize: number;
  93188. /** Maximum cube texture size */
  93189. maxCubemapTextureSize: number;
  93190. /** Maximum render texture size */
  93191. maxRenderTextureSize: number;
  93192. /** Maximum number of vertex attributes */
  93193. maxVertexAttribs: number;
  93194. /** Maximum number of varyings */
  93195. maxVaryingVectors: number;
  93196. /** Maximum number of uniforms per vertex shader */
  93197. maxVertexUniformVectors: number;
  93198. /** Maximum number of uniforms per fragment shader */
  93199. maxFragmentUniformVectors: number;
  93200. /** Defines if standard derivates (dx/dy) are supported */
  93201. standardDerivatives: boolean;
  93202. /** Defines if s3tc texture compression is supported */
  93203. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  93204. /** Defines if pvrtc texture compression is supported */
  93205. pvrtc: any;
  93206. /** Defines if etc1 texture compression is supported */
  93207. etc1: any;
  93208. /** Defines if etc2 texture compression is supported */
  93209. etc2: any;
  93210. /** Defines if astc texture compression is supported */
  93211. astc: any;
  93212. /** Defines if float textures are supported */
  93213. textureFloat: boolean;
  93214. /** Defines if vertex array objects are supported */
  93215. vertexArrayObject: boolean;
  93216. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  93217. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  93218. /** Gets the maximum level of anisotropy supported */
  93219. maxAnisotropy: number;
  93220. /** Defines if instancing is supported */
  93221. instancedArrays: boolean;
  93222. /** Defines if 32 bits indices are supported */
  93223. uintIndices: boolean;
  93224. /** Defines if high precision shaders are supported */
  93225. highPrecisionShaderSupported: boolean;
  93226. /** Defines if depth reading in the fragment shader is supported */
  93227. fragmentDepthSupported: boolean;
  93228. /** Defines if float texture linear filtering is supported*/
  93229. textureFloatLinearFiltering: boolean;
  93230. /** Defines if rendering to float textures is supported */
  93231. textureFloatRender: boolean;
  93232. /** Defines if half float textures are supported*/
  93233. textureHalfFloat: boolean;
  93234. /** Defines if half float texture linear filtering is supported*/
  93235. textureHalfFloatLinearFiltering: boolean;
  93236. /** Defines if rendering to half float textures is supported */
  93237. textureHalfFloatRender: boolean;
  93238. /** Defines if textureLOD shader command is supported */
  93239. textureLOD: boolean;
  93240. /** Defines if draw buffers extension is supported */
  93241. drawBuffersExtension: boolean;
  93242. /** Defines if depth textures are supported */
  93243. depthTextureExtension: boolean;
  93244. /** Defines if float color buffer are supported */
  93245. colorBufferFloat: boolean;
  93246. /** Gets disjoint timer query extension (null if not supported) */
  93247. timerQuery: EXT_disjoint_timer_query;
  93248. /** Defines if timestamp can be used with timer query */
  93249. canUseTimestampForTimerQuery: boolean;
  93250. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  93251. multiview: any;
  93252. /** Function used to let the system compiles shaders in background */
  93253. parallelShaderCompile: {
  93254. COMPLETION_STATUS_KHR: number;
  93255. };
  93256. }
  93257. /** Interface defining initialization parameters for Engine class */
  93258. export interface EngineOptions extends WebGLContextAttributes {
  93259. /**
  93260. * Defines if the engine should no exceed a specified device ratio
  93261. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  93262. */
  93263. limitDeviceRatio?: number;
  93264. /**
  93265. * Defines if webvr should be enabled automatically
  93266. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93267. */
  93268. autoEnableWebVR?: boolean;
  93269. /**
  93270. * Defines if webgl2 should be turned off even if supported
  93271. * @see http://doc.babylonjs.com/features/webgl2
  93272. */
  93273. disableWebGL2Support?: boolean;
  93274. /**
  93275. * Defines if webaudio should be initialized as well
  93276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93277. */
  93278. audioEngine?: boolean;
  93279. /**
  93280. * Defines if animations should run using a deterministic lock step
  93281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93282. */
  93283. deterministicLockstep?: boolean;
  93284. /** Defines the maximum steps to use with deterministic lock step mode */
  93285. lockstepMaxSteps?: number;
  93286. /**
  93287. * Defines that engine should ignore context lost events
  93288. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  93289. */
  93290. doNotHandleContextLost?: boolean;
  93291. /**
  93292. * Defines that engine should ignore modifying touch action attribute and style
  93293. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  93294. */
  93295. doNotHandleTouchAction?: boolean;
  93296. /**
  93297. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  93298. */
  93299. useHighPrecisionFloats?: boolean;
  93300. }
  93301. /**
  93302. * Defines the interface used by display changed events
  93303. */
  93304. export interface IDisplayChangedEventArgs {
  93305. /** Gets the vrDisplay object (if any) */
  93306. vrDisplay: Nullable<any>;
  93307. /** Gets a boolean indicating if webVR is supported */
  93308. vrSupported: boolean;
  93309. }
  93310. /**
  93311. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  93312. */
  93313. export class Engine {
  93314. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  93315. static ExceptionList: ({
  93316. key: string;
  93317. capture: string;
  93318. captureConstraint: number;
  93319. targets: string[];
  93320. } | {
  93321. key: string;
  93322. capture: null;
  93323. captureConstraint: null;
  93324. targets: string[];
  93325. })[];
  93326. /** Gets the list of created engines */
  93327. static readonly Instances: Engine[];
  93328. /**
  93329. * Gets the latest created engine
  93330. */
  93331. static readonly LastCreatedEngine: Nullable<Engine>;
  93332. /**
  93333. * Gets the latest created scene
  93334. */
  93335. static readonly LastCreatedScene: Nullable<Scene>;
  93336. /**
  93337. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  93338. * @param flag defines which part of the materials must be marked as dirty
  93339. * @param predicate defines a predicate used to filter which materials should be affected
  93340. */
  93341. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93342. /** @hidden */
  93343. static _TextureLoaders: IInternalTextureLoader[];
  93344. /** Defines that alpha blending is disabled */
  93345. static readonly ALPHA_DISABLE: number;
  93346. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  93347. static readonly ALPHA_ADD: number;
  93348. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  93349. static readonly ALPHA_COMBINE: number;
  93350. /** Defines that alpha blending to DEST - SRC * DEST */
  93351. static readonly ALPHA_SUBTRACT: number;
  93352. /** Defines that alpha blending to SRC * DEST */
  93353. static readonly ALPHA_MULTIPLY: number;
  93354. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  93355. static readonly ALPHA_MAXIMIZED: number;
  93356. /** Defines that alpha blending to SRC + DEST */
  93357. static readonly ALPHA_ONEONE: number;
  93358. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  93359. static readonly ALPHA_PREMULTIPLIED: number;
  93360. /**
  93361. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  93362. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  93363. */
  93364. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  93365. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  93366. static readonly ALPHA_INTERPOLATE: number;
  93367. /**
  93368. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  93369. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  93370. */
  93371. static readonly ALPHA_SCREENMODE: number;
  93372. /** Defines that the ressource is not delayed*/
  93373. static readonly DELAYLOADSTATE_NONE: number;
  93374. /** Defines that the ressource was successfully delay loaded */
  93375. static readonly DELAYLOADSTATE_LOADED: number;
  93376. /** Defines that the ressource is currently delay loading */
  93377. static readonly DELAYLOADSTATE_LOADING: number;
  93378. /** Defines that the ressource is delayed and has not started loading */
  93379. static readonly DELAYLOADSTATE_NOTLOADED: number;
  93380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  93381. static readonly NEVER: number;
  93382. /** 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 */
  93383. static readonly ALWAYS: number;
  93384. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  93385. static readonly LESS: number;
  93386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  93387. static readonly EQUAL: number;
  93388. /** 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 */
  93389. static readonly LEQUAL: number;
  93390. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  93391. static readonly GREATER: number;
  93392. /** 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 */
  93393. static readonly GEQUAL: number;
  93394. /** 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 */
  93395. static readonly NOTEQUAL: number;
  93396. /** Passed to stencilOperation to specify that stencil value must be kept */
  93397. static readonly KEEP: number;
  93398. /** Passed to stencilOperation to specify that stencil value must be replaced */
  93399. static readonly REPLACE: number;
  93400. /** Passed to stencilOperation to specify that stencil value must be incremented */
  93401. static readonly INCR: number;
  93402. /** Passed to stencilOperation to specify that stencil value must be decremented */
  93403. static readonly DECR: number;
  93404. /** Passed to stencilOperation to specify that stencil value must be inverted */
  93405. static readonly INVERT: number;
  93406. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  93407. static readonly INCR_WRAP: number;
  93408. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  93409. static readonly DECR_WRAP: number;
  93410. /** Texture is not repeating outside of 0..1 UVs */
  93411. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  93412. /** Texture is repeating outside of 0..1 UVs */
  93413. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  93414. /** Texture is repeating and mirrored */
  93415. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  93416. /** ALPHA */
  93417. static readonly TEXTUREFORMAT_ALPHA: number;
  93418. /** LUMINANCE */
  93419. static readonly TEXTUREFORMAT_LUMINANCE: number;
  93420. /** LUMINANCE_ALPHA */
  93421. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  93422. /** RGB */
  93423. static readonly TEXTUREFORMAT_RGB: number;
  93424. /** RGBA */
  93425. static readonly TEXTUREFORMAT_RGBA: number;
  93426. /** RED */
  93427. static readonly TEXTUREFORMAT_RED: number;
  93428. /** RED (2nd reference) */
  93429. static readonly TEXTUREFORMAT_R: number;
  93430. /** RG */
  93431. static readonly TEXTUREFORMAT_RG: number;
  93432. /** RED_INTEGER */
  93433. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  93434. /** RED_INTEGER (2nd reference) */
  93435. static readonly TEXTUREFORMAT_R_INTEGER: number;
  93436. /** RG_INTEGER */
  93437. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  93438. /** RGB_INTEGER */
  93439. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  93440. /** RGBA_INTEGER */
  93441. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  93442. /** UNSIGNED_BYTE */
  93443. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  93444. /** UNSIGNED_BYTE (2nd reference) */
  93445. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  93446. /** FLOAT */
  93447. static readonly TEXTURETYPE_FLOAT: number;
  93448. /** HALF_FLOAT */
  93449. static readonly TEXTURETYPE_HALF_FLOAT: number;
  93450. /** BYTE */
  93451. static readonly TEXTURETYPE_BYTE: number;
  93452. /** SHORT */
  93453. static readonly TEXTURETYPE_SHORT: number;
  93454. /** UNSIGNED_SHORT */
  93455. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  93456. /** INT */
  93457. static readonly TEXTURETYPE_INT: number;
  93458. /** UNSIGNED_INT */
  93459. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  93460. /** UNSIGNED_SHORT_4_4_4_4 */
  93461. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  93462. /** UNSIGNED_SHORT_5_5_5_1 */
  93463. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  93464. /** UNSIGNED_SHORT_5_6_5 */
  93465. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  93466. /** UNSIGNED_INT_2_10_10_10_REV */
  93467. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  93468. /** UNSIGNED_INT_24_8 */
  93469. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  93470. /** UNSIGNED_INT_10F_11F_11F_REV */
  93471. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  93472. /** UNSIGNED_INT_5_9_9_9_REV */
  93473. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  93474. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  93475. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  93476. /** nearest is mag = nearest and min = nearest and mip = linear */
  93477. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  93478. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93479. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  93480. /** Trilinear is mag = linear and min = linear and mip = linear */
  93481. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  93482. /** nearest is mag = nearest and min = nearest and mip = linear */
  93483. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  93484. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93485. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  93486. /** Trilinear is mag = linear and min = linear and mip = linear */
  93487. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  93488. /** mag = nearest and min = nearest and mip = nearest */
  93489. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  93490. /** mag = nearest and min = linear and mip = nearest */
  93491. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  93492. /** mag = nearest and min = linear and mip = linear */
  93493. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  93494. /** mag = nearest and min = linear and mip = none */
  93495. static readonly TEXTURE_NEAREST_LINEAR: number;
  93496. /** mag = nearest and min = nearest and mip = none */
  93497. static readonly TEXTURE_NEAREST_NEAREST: number;
  93498. /** mag = linear and min = nearest and mip = nearest */
  93499. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  93500. /** mag = linear and min = nearest and mip = linear */
  93501. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  93502. /** mag = linear and min = linear and mip = none */
  93503. static readonly TEXTURE_LINEAR_LINEAR: number;
  93504. /** mag = linear and min = nearest and mip = none */
  93505. static readonly TEXTURE_LINEAR_NEAREST: number;
  93506. /** Explicit coordinates mode */
  93507. static readonly TEXTURE_EXPLICIT_MODE: number;
  93508. /** Spherical coordinates mode */
  93509. static readonly TEXTURE_SPHERICAL_MODE: number;
  93510. /** Planar coordinates mode */
  93511. static readonly TEXTURE_PLANAR_MODE: number;
  93512. /** Cubic coordinates mode */
  93513. static readonly TEXTURE_CUBIC_MODE: number;
  93514. /** Projection coordinates mode */
  93515. static readonly TEXTURE_PROJECTION_MODE: number;
  93516. /** Skybox coordinates mode */
  93517. static readonly TEXTURE_SKYBOX_MODE: number;
  93518. /** Inverse Cubic coordinates mode */
  93519. static readonly TEXTURE_INVCUBIC_MODE: number;
  93520. /** Equirectangular coordinates mode */
  93521. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  93522. /** Equirectangular Fixed coordinates mode */
  93523. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  93524. /** Equirectangular Fixed Mirrored coordinates mode */
  93525. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93526. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  93527. static readonly SCALEMODE_FLOOR: number;
  93528. /** Defines that texture rescaling will look for the nearest power of 2 size */
  93529. static readonly SCALEMODE_NEAREST: number;
  93530. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  93531. static readonly SCALEMODE_CEILING: number;
  93532. /**
  93533. * Returns the current npm package of the sdk
  93534. */
  93535. static readonly NpmPackage: string;
  93536. /**
  93537. * Returns the current version of the framework
  93538. */
  93539. static readonly Version: string;
  93540. /**
  93541. * Returns a string describing the current engine
  93542. */
  93543. readonly description: string;
  93544. /**
  93545. * Gets or sets the epsilon value used by collision engine
  93546. */
  93547. static CollisionsEpsilon: number;
  93548. /**
  93549. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93550. */
  93551. static ShadersRepository: string;
  93552. /**
  93553. * Method called to create the default loading screen.
  93554. * This can be overriden in your own app.
  93555. * @param canvas The rendering canvas element
  93556. * @returns The loading screen
  93557. */
  93558. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  93559. /**
  93560. * Method called to create the default rescale post process on each engine.
  93561. */
  93562. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  93563. /** @hidden */
  93564. _shaderProcessor: IShaderProcessor;
  93565. /**
  93566. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  93567. */
  93568. forcePOTTextures: boolean;
  93569. /**
  93570. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  93571. */
  93572. isFullscreen: boolean;
  93573. /**
  93574. * Gets a boolean indicating if the pointer is currently locked
  93575. */
  93576. isPointerLock: boolean;
  93577. /**
  93578. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  93579. */
  93580. cullBackFaces: boolean;
  93581. /**
  93582. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  93583. */
  93584. renderEvenInBackground: boolean;
  93585. /**
  93586. * Gets or sets a boolean indicating that cache can be kept between frames
  93587. */
  93588. preventCacheWipeBetweenFrames: boolean;
  93589. /**
  93590. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  93591. **/
  93592. enableOfflineSupport: boolean;
  93593. /**
  93594. * 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)
  93595. **/
  93596. disableManifestCheck: boolean;
  93597. /**
  93598. * Gets the list of created scenes
  93599. */
  93600. scenes: Scene[];
  93601. /**
  93602. * Event raised when a new scene is created
  93603. */
  93604. onNewSceneAddedObservable: Observable<Scene>;
  93605. /**
  93606. * Gets the list of created postprocesses
  93607. */
  93608. postProcesses: PostProcess[];
  93609. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  93610. validateShaderPrograms: boolean;
  93611. /**
  93612. * Observable event triggered each time the rendering canvas is resized
  93613. */
  93614. onResizeObservable: Observable<Engine>;
  93615. /**
  93616. * Observable event triggered each time the canvas loses focus
  93617. */
  93618. onCanvasBlurObservable: Observable<Engine>;
  93619. /**
  93620. * Observable event triggered each time the canvas gains focus
  93621. */
  93622. onCanvasFocusObservable: Observable<Engine>;
  93623. /**
  93624. * Observable event triggered each time the canvas receives pointerout event
  93625. */
  93626. onCanvasPointerOutObservable: Observable<PointerEvent>;
  93627. /**
  93628. * Observable event triggered before each texture is initialized
  93629. */
  93630. onBeforeTextureInitObservable: Observable<Texture>;
  93631. /**
  93632. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  93633. */
  93634. disableUniformBuffers: boolean;
  93635. /** @hidden */
  93636. _uniformBuffers: UniformBuffer[];
  93637. /**
  93638. * Gets a boolean indicating that the engine supports uniform buffers
  93639. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93640. */
  93641. readonly supportsUniformBuffers: boolean;
  93642. /**
  93643. * Observable raised when the engine begins a new frame
  93644. */
  93645. onBeginFrameObservable: Observable<Engine>;
  93646. /**
  93647. * If set, will be used to request the next animation frame for the render loop
  93648. */
  93649. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  93650. /**
  93651. * Observable raised when the engine ends the current frame
  93652. */
  93653. onEndFrameObservable: Observable<Engine>;
  93654. /**
  93655. * Observable raised when the engine is about to compile a shader
  93656. */
  93657. onBeforeShaderCompilationObservable: Observable<Engine>;
  93658. /**
  93659. * Observable raised when the engine has jsut compiled a shader
  93660. */
  93661. onAfterShaderCompilationObservable: Observable<Engine>;
  93662. /** @hidden */
  93663. _gl: WebGLRenderingContext;
  93664. private _renderingCanvas;
  93665. private _windowIsBackground;
  93666. private _webGLVersion;
  93667. protected _highPrecisionShadersAllowed: boolean;
  93668. /** @hidden */
  93669. readonly _shouldUseHighPrecisionShader: boolean;
  93670. /**
  93671. * Gets a boolean indicating that only power of 2 textures are supported
  93672. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  93673. */
  93674. readonly needPOTTextures: boolean;
  93675. /** @hidden */
  93676. _badOS: boolean;
  93677. /** @hidden */
  93678. _badDesktopOS: boolean;
  93679. /**
  93680. * Gets the audio engine
  93681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93682. * @ignorenaming
  93683. */
  93684. static audioEngine: IAudioEngine;
  93685. /**
  93686. * Default AudioEngine factory responsible of creating the Audio Engine.
  93687. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  93688. */
  93689. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  93690. /**
  93691. * Default offline support factory responsible of creating a tool used to store data locally.
  93692. * By default, this will create a Database object if the workload has been embedded.
  93693. */
  93694. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  93695. private _onFocus;
  93696. private _onBlur;
  93697. private _onCanvasPointerOut;
  93698. private _onCanvasBlur;
  93699. private _onCanvasFocus;
  93700. private _onFullscreenChange;
  93701. private _onPointerLockChange;
  93702. private _hardwareScalingLevel;
  93703. /** @hidden */
  93704. _caps: EngineCapabilities;
  93705. private _pointerLockRequested;
  93706. private _isStencilEnable;
  93707. private _colorWrite;
  93708. private _loadingScreen;
  93709. /** @hidden */
  93710. _drawCalls: PerfCounter;
  93711. private _glVersion;
  93712. private _glRenderer;
  93713. private _glVendor;
  93714. private _videoTextureSupported;
  93715. private _renderingQueueLaunched;
  93716. private _activeRenderLoops;
  93717. private _deterministicLockstep;
  93718. private _lockstepMaxSteps;
  93719. /**
  93720. * Observable signaled when a context lost event is raised
  93721. */
  93722. onContextLostObservable: Observable<Engine>;
  93723. /**
  93724. * Observable signaled when a context restored event is raised
  93725. */
  93726. onContextRestoredObservable: Observable<Engine>;
  93727. private _onContextLost;
  93728. private _onContextRestored;
  93729. private _contextWasLost;
  93730. /** @hidden */
  93731. _doNotHandleContextLost: boolean;
  93732. /**
  93733. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  93734. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  93735. */
  93736. doNotHandleContextLost: boolean;
  93737. private _performanceMonitor;
  93738. private _fps;
  93739. private _deltaTime;
  93740. /**
  93741. * Turn this value on if you want to pause FPS computation when in background
  93742. */
  93743. disablePerformanceMonitorInBackground: boolean;
  93744. /**
  93745. * Gets the performance monitor attached to this engine
  93746. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  93747. */
  93748. readonly performanceMonitor: PerformanceMonitor;
  93749. /**
  93750. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  93751. */
  93752. disableVertexArrayObjects: boolean;
  93753. /** @hidden */
  93754. protected _depthCullingState: _DepthCullingState;
  93755. /** @hidden */
  93756. protected _stencilState: _StencilState;
  93757. /** @hidden */
  93758. protected _alphaState: _AlphaState;
  93759. /** @hidden */
  93760. protected _alphaMode: number;
  93761. /** @hidden */
  93762. _internalTexturesCache: InternalTexture[];
  93763. /** @hidden */
  93764. protected _activeChannel: number;
  93765. private _currentTextureChannel;
  93766. /** @hidden */
  93767. protected _boundTexturesCache: {
  93768. [key: string]: Nullable<InternalTexture>;
  93769. };
  93770. /** @hidden */
  93771. protected _currentEffect: Nullable<Effect>;
  93772. /** @hidden */
  93773. protected _currentProgram: Nullable<WebGLProgram>;
  93774. private _compiledEffects;
  93775. private _vertexAttribArraysEnabled;
  93776. /** @hidden */
  93777. protected _cachedViewport: Nullable<IViewportLike>;
  93778. private _cachedVertexArrayObject;
  93779. /** @hidden */
  93780. protected _cachedVertexBuffers: any;
  93781. /** @hidden */
  93782. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  93783. /** @hidden */
  93784. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  93785. /** @hidden */
  93786. _currentRenderTarget: Nullable<InternalTexture>;
  93787. private _uintIndicesCurrentlySet;
  93788. private _currentBoundBuffer;
  93789. /** @hidden */
  93790. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  93791. private _currentBufferPointers;
  93792. private _currentInstanceLocations;
  93793. private _currentInstanceBuffers;
  93794. private _textureUnits;
  93795. /** @hidden */
  93796. _workingCanvas: Nullable<HTMLCanvasElement>;
  93797. /** @hidden */
  93798. _workingContext: Nullable<CanvasRenderingContext2D>;
  93799. private _rescalePostProcess;
  93800. private _dummyFramebuffer;
  93801. private _externalData;
  93802. /** @hidden */
  93803. _bindedRenderFunction: any;
  93804. private _vaoRecordInProgress;
  93805. private _mustWipeVertexAttributes;
  93806. private _emptyTexture;
  93807. private _emptyCubeTexture;
  93808. private _emptyTexture3D;
  93809. /** @hidden */
  93810. _frameHandler: number;
  93811. private _nextFreeTextureSlots;
  93812. private _maxSimultaneousTextures;
  93813. private _activeRequests;
  93814. private _texturesSupported;
  93815. /** @hidden */
  93816. _textureFormatInUse: Nullable<string>;
  93817. /**
  93818. * Gets the list of texture formats supported
  93819. */
  93820. readonly texturesSupported: Array<string>;
  93821. /**
  93822. * Gets the list of texture formats in use
  93823. */
  93824. readonly textureFormatInUse: Nullable<string>;
  93825. /**
  93826. * Gets the current viewport
  93827. */
  93828. readonly currentViewport: Nullable<IViewportLike>;
  93829. /**
  93830. * Gets the default empty texture
  93831. */
  93832. readonly emptyTexture: InternalTexture;
  93833. /**
  93834. * Gets the default empty 3D texture
  93835. */
  93836. readonly emptyTexture3D: InternalTexture;
  93837. /**
  93838. * Gets the default empty cube texture
  93839. */
  93840. readonly emptyCubeTexture: InternalTexture;
  93841. /**
  93842. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  93843. */
  93844. readonly premultipliedAlpha: boolean;
  93845. /**
  93846. * Creates a new engine
  93847. * @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
  93848. * @param antialias defines enable antialiasing (default: false)
  93849. * @param options defines further options to be sent to the getContext() function
  93850. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  93851. */
  93852. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  93853. /**
  93854. * Initializes a webVR display and starts listening to display change events
  93855. * The onVRDisplayChangedObservable will be notified upon these changes
  93856. * @returns The onVRDisplayChangedObservable
  93857. */
  93858. initWebVR(): Observable<IDisplayChangedEventArgs>;
  93859. /** @hidden */
  93860. _prepareVRComponent(): void;
  93861. /** @hidden */
  93862. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  93863. /** @hidden */
  93864. _submitVRFrame(): void;
  93865. /**
  93866. * Call this function to leave webVR mode
  93867. * Will do nothing if webVR is not supported or if there is no webVR device
  93868. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93869. */
  93870. disableVR(): void;
  93871. /**
  93872. * Gets a boolean indicating that the system is in VR mode and is presenting
  93873. * @returns true if VR mode is engaged
  93874. */
  93875. isVRPresenting(): boolean;
  93876. /** @hidden */
  93877. _requestVRFrame(): void;
  93878. private _disableTouchAction;
  93879. private _rebuildInternalTextures;
  93880. private _rebuildEffects;
  93881. /**
  93882. * Gets a boolean indicating if all created effects are ready
  93883. * @returns true if all effects are ready
  93884. */
  93885. areAllEffectsReady(): boolean;
  93886. private _rebuildBuffers;
  93887. private _initGLContext;
  93888. /**
  93889. * Gets version of the current webGL context
  93890. */
  93891. readonly webGLVersion: number;
  93892. /**
  93893. * Gets a string idenfifying the name of the class
  93894. * @returns "Engine" string
  93895. */
  93896. getClassName(): string;
  93897. /**
  93898. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  93899. */
  93900. readonly isStencilEnable: boolean;
  93901. /** @hidden */
  93902. _prepareWorkingCanvas(): void;
  93903. /**
  93904. * Reset the texture cache to empty state
  93905. */
  93906. resetTextureCache(): void;
  93907. /**
  93908. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  93909. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93910. * @returns true if engine is in deterministic lock step mode
  93911. */
  93912. isDeterministicLockStep(): boolean;
  93913. /**
  93914. * Gets the max steps when engine is running in deterministic lock step
  93915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93916. * @returns the max steps
  93917. */
  93918. getLockstepMaxSteps(): number;
  93919. /**
  93920. * Gets an object containing information about the current webGL context
  93921. * @returns an object containing the vender, the renderer and the version of the current webGL context
  93922. */
  93923. getGlInfo(): {
  93924. vendor: string;
  93925. renderer: string;
  93926. version: string;
  93927. };
  93928. /**
  93929. * Gets current aspect ratio
  93930. * @param viewportOwner defines the camera to use to get the aspect ratio
  93931. * @param useScreen defines if screen size must be used (or the current render target if any)
  93932. * @returns a number defining the aspect ratio
  93933. */
  93934. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  93935. /**
  93936. * Gets current screen aspect ratio
  93937. * @returns a number defining the aspect ratio
  93938. */
  93939. getScreenAspectRatio(): number;
  93940. /**
  93941. * Gets the current render width
  93942. * @param useScreen defines if screen size must be used (or the current render target if any)
  93943. * @returns a number defining the current render width
  93944. */
  93945. getRenderWidth(useScreen?: boolean): number;
  93946. /**
  93947. * Gets the current render height
  93948. * @param useScreen defines if screen size must be used (or the current render target if any)
  93949. * @returns a number defining the current render height
  93950. */
  93951. getRenderHeight(useScreen?: boolean): number;
  93952. /**
  93953. * Gets the HTML canvas attached with the current webGL context
  93954. * @returns a HTML canvas
  93955. */
  93956. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  93957. /**
  93958. * Gets the client rect of the HTML canvas attached with the current webGL context
  93959. * @returns a client rectanglee
  93960. */
  93961. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  93962. /**
  93963. * Defines the hardware scaling level.
  93964. * By default the hardware scaling level is computed from the window device ratio.
  93965. * 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.
  93966. * @param level defines the level to use
  93967. */
  93968. setHardwareScalingLevel(level: number): void;
  93969. /**
  93970. * Gets the current hardware scaling level.
  93971. * By default the hardware scaling level is computed from the window device ratio.
  93972. * 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.
  93973. * @returns a number indicating the current hardware scaling level
  93974. */
  93975. getHardwareScalingLevel(): number;
  93976. /**
  93977. * Gets the list of loaded textures
  93978. * @returns an array containing all loaded textures
  93979. */
  93980. getLoadedTexturesCache(): InternalTexture[];
  93981. /**
  93982. * Gets the object containing all engine capabilities
  93983. * @returns the EngineCapabilities object
  93984. */
  93985. getCaps(): EngineCapabilities;
  93986. /**
  93987. * Gets the current depth function
  93988. * @returns a number defining the depth function
  93989. */
  93990. getDepthFunction(): Nullable<number>;
  93991. /**
  93992. * Sets the current depth function
  93993. * @param depthFunc defines the function to use
  93994. */
  93995. setDepthFunction(depthFunc: number): void;
  93996. /**
  93997. * Sets the current depth function to GREATER
  93998. */
  93999. setDepthFunctionToGreater(): void;
  94000. /**
  94001. * Sets the current depth function to GEQUAL
  94002. */
  94003. setDepthFunctionToGreaterOrEqual(): void;
  94004. /**
  94005. * Sets the current depth function to LESS
  94006. */
  94007. setDepthFunctionToLess(): void;
  94008. private _cachedStencilBuffer;
  94009. private _cachedStencilFunction;
  94010. private _cachedStencilMask;
  94011. private _cachedStencilOperationPass;
  94012. private _cachedStencilOperationFail;
  94013. private _cachedStencilOperationDepthFail;
  94014. private _cachedStencilReference;
  94015. /**
  94016. * Caches the the state of the stencil buffer
  94017. */
  94018. cacheStencilState(): void;
  94019. /**
  94020. * Restores the state of the stencil buffer
  94021. */
  94022. restoreStencilState(): void;
  94023. /**
  94024. * Sets the current depth function to LEQUAL
  94025. */
  94026. setDepthFunctionToLessOrEqual(): void;
  94027. /**
  94028. * Gets a boolean indicating if stencil buffer is enabled
  94029. * @returns the current stencil buffer state
  94030. */
  94031. getStencilBuffer(): boolean;
  94032. /**
  94033. * Enable or disable the stencil buffer
  94034. * @param enable defines if the stencil buffer must be enabled or disabled
  94035. */
  94036. setStencilBuffer(enable: boolean): void;
  94037. /**
  94038. * Gets the current stencil mask
  94039. * @returns a number defining the new stencil mask to use
  94040. */
  94041. getStencilMask(): number;
  94042. /**
  94043. * Sets the current stencil mask
  94044. * @param mask defines the new stencil mask to use
  94045. */
  94046. setStencilMask(mask: number): void;
  94047. /**
  94048. * Gets the current stencil function
  94049. * @returns a number defining the stencil function to use
  94050. */
  94051. getStencilFunction(): number;
  94052. /**
  94053. * Gets the current stencil reference value
  94054. * @returns a number defining the stencil reference value to use
  94055. */
  94056. getStencilFunctionReference(): number;
  94057. /**
  94058. * Gets the current stencil mask
  94059. * @returns a number defining the stencil mask to use
  94060. */
  94061. getStencilFunctionMask(): number;
  94062. /**
  94063. * Sets the current stencil function
  94064. * @param stencilFunc defines the new stencil function to use
  94065. */
  94066. setStencilFunction(stencilFunc: number): void;
  94067. /**
  94068. * Sets the current stencil reference
  94069. * @param reference defines the new stencil reference to use
  94070. */
  94071. setStencilFunctionReference(reference: number): void;
  94072. /**
  94073. * Sets the current stencil mask
  94074. * @param mask defines the new stencil mask to use
  94075. */
  94076. setStencilFunctionMask(mask: number): void;
  94077. /**
  94078. * Gets the current stencil operation when stencil fails
  94079. * @returns a number defining stencil operation to use when stencil fails
  94080. */
  94081. getStencilOperationFail(): number;
  94082. /**
  94083. * Gets the current stencil operation when depth fails
  94084. * @returns a number defining stencil operation to use when depth fails
  94085. */
  94086. getStencilOperationDepthFail(): number;
  94087. /**
  94088. * Gets the current stencil operation when stencil passes
  94089. * @returns a number defining stencil operation to use when stencil passes
  94090. */
  94091. getStencilOperationPass(): number;
  94092. /**
  94093. * Sets the stencil operation to use when stencil fails
  94094. * @param operation defines the stencil operation to use when stencil fails
  94095. */
  94096. setStencilOperationFail(operation: number): void;
  94097. /**
  94098. * Sets the stencil operation to use when depth fails
  94099. * @param operation defines the stencil operation to use when depth fails
  94100. */
  94101. setStencilOperationDepthFail(operation: number): void;
  94102. /**
  94103. * Sets the stencil operation to use when stencil passes
  94104. * @param operation defines the stencil operation to use when stencil passes
  94105. */
  94106. setStencilOperationPass(operation: number): void;
  94107. /**
  94108. * Sets a boolean indicating if the dithering state is enabled or disabled
  94109. * @param value defines the dithering state
  94110. */
  94111. setDitheringState(value: boolean): void;
  94112. /**
  94113. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  94114. * @param value defines the rasterizer state
  94115. */
  94116. setRasterizerState(value: boolean): void;
  94117. /**
  94118. * stop executing a render loop function and remove it from the execution array
  94119. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  94120. */
  94121. stopRenderLoop(renderFunction?: () => void): void;
  94122. /** @hidden */
  94123. _renderLoop(): void;
  94124. /**
  94125. * Register and execute a render loop. The engine can have more than one render function
  94126. * @param renderFunction defines the function to continuously execute
  94127. */
  94128. runRenderLoop(renderFunction: () => void): void;
  94129. /**
  94130. * Toggle full screen mode
  94131. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94132. */
  94133. switchFullscreen(requestPointerLock: boolean): void;
  94134. /**
  94135. * Enters full screen mode
  94136. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94137. */
  94138. enterFullscreen(requestPointerLock: boolean): void;
  94139. /**
  94140. * Exits full screen mode
  94141. */
  94142. exitFullscreen(): void;
  94143. /**
  94144. * Enters Pointerlock mode
  94145. */
  94146. enterPointerlock(): void;
  94147. /**
  94148. * Exits Pointerlock mode
  94149. */
  94150. exitPointerlock(): void;
  94151. /**
  94152. * Clear the current render buffer or the current render target (if any is set up)
  94153. * @param color defines the color to use
  94154. * @param backBuffer defines if the back buffer must be cleared
  94155. * @param depth defines if the depth buffer must be cleared
  94156. * @param stencil defines if the stencil buffer must be cleared
  94157. */
  94158. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  94159. /**
  94160. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  94161. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94162. * @param y defines the y-coordinate of the corner of the clear rectangle
  94163. * @param width defines the width of the clear rectangle
  94164. * @param height defines the height of the clear rectangle
  94165. * @param clearColor defines the clear color
  94166. */
  94167. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  94168. /**
  94169. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  94170. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94171. * @param y defines the y-coordinate of the corner of the clear rectangle
  94172. * @param width defines the width of the clear rectangle
  94173. * @param height defines the height of the clear rectangle
  94174. */
  94175. enableScissor(x: number, y: number, width: number, height: number): void;
  94176. /**
  94177. * Disable previously set scissor test rectangle
  94178. */
  94179. disableScissor(): void;
  94180. private _viewportCached;
  94181. /** @hidden */
  94182. _viewport(x: number, y: number, width: number, height: number): void;
  94183. /**
  94184. * Set the WebGL's viewport
  94185. * @param viewport defines the viewport element to be used
  94186. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  94187. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  94188. */
  94189. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  94190. /**
  94191. * Directly set the WebGL Viewport
  94192. * @param x defines the x coordinate of the viewport (in screen space)
  94193. * @param y defines the y coordinate of the viewport (in screen space)
  94194. * @param width defines the width of the viewport (in screen space)
  94195. * @param height defines the height of the viewport (in screen space)
  94196. * @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
  94197. */
  94198. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  94199. /**
  94200. * Begin a new frame
  94201. */
  94202. beginFrame(): void;
  94203. /**
  94204. * Enf the current frame
  94205. */
  94206. endFrame(): void;
  94207. /**
  94208. * Resize the view according to the canvas' size
  94209. */
  94210. resize(): void;
  94211. /**
  94212. * Force a specific size of the canvas
  94213. * @param width defines the new canvas' width
  94214. * @param height defines the new canvas' height
  94215. */
  94216. setSize(width: number, height: number): void;
  94217. /**
  94218. * Binds the frame buffer to the specified texture.
  94219. * @param texture The texture to render to or null for the default canvas
  94220. * @param faceIndex The face of the texture to render to in case of cube texture
  94221. * @param requiredWidth The width of the target to render to
  94222. * @param requiredHeight The height of the target to render to
  94223. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  94224. * @param depthStencilTexture The depth stencil texture to use to render
  94225. * @param lodLevel defines le lod level to bind to the frame buffer
  94226. */
  94227. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  94228. /** @hidden */
  94229. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  94230. /**
  94231. * Unbind the current render target texture from the webGL context
  94232. * @param texture defines the render target texture to unbind
  94233. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  94234. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  94235. */
  94236. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  94237. /**
  94238. * Force the mipmap generation for the given render target texture
  94239. * @param texture defines the render target texture to use
  94240. */
  94241. generateMipMapsForCubemap(texture: InternalTexture): void;
  94242. /**
  94243. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  94244. */
  94245. flushFramebuffer(): void;
  94246. /**
  94247. * Unbind the current render target and bind the default framebuffer
  94248. */
  94249. restoreDefaultFramebuffer(): void;
  94250. /**
  94251. * Create an uniform buffer
  94252. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94253. * @param elements defines the content of the uniform buffer
  94254. * @returns the webGL uniform buffer
  94255. */
  94256. createUniformBuffer(elements: FloatArray): DataBuffer;
  94257. /**
  94258. * Create a dynamic uniform buffer
  94259. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94260. * @param elements defines the content of the uniform buffer
  94261. * @returns the webGL uniform buffer
  94262. */
  94263. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  94264. /**
  94265. * Update an existing uniform buffer
  94266. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94267. * @param uniformBuffer defines the target uniform buffer
  94268. * @param elements defines the content to update
  94269. * @param offset defines the offset in the uniform buffer where update should start
  94270. * @param count defines the size of the data to update
  94271. */
  94272. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  94273. private _resetVertexBufferBinding;
  94274. /**
  94275. * Creates a vertex buffer
  94276. * @param data the data for the vertex buffer
  94277. * @returns the new WebGL static buffer
  94278. */
  94279. createVertexBuffer(data: DataArray): DataBuffer;
  94280. /**
  94281. * Creates a dynamic vertex buffer
  94282. * @param data the data for the dynamic vertex buffer
  94283. * @returns the new WebGL dynamic buffer
  94284. */
  94285. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  94286. /**
  94287. * Update a dynamic index buffer
  94288. * @param indexBuffer defines the target index buffer
  94289. * @param indices defines the data to update
  94290. * @param offset defines the offset in the target index buffer where update should start
  94291. */
  94292. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  94293. /**
  94294. * Updates a dynamic vertex buffer.
  94295. * @param vertexBuffer the vertex buffer to update
  94296. * @param data the data used to update the vertex buffer
  94297. * @param byteOffset the byte offset of the data
  94298. * @param byteLength the byte length of the data
  94299. */
  94300. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  94301. private _resetIndexBufferBinding;
  94302. /**
  94303. * Creates a new index buffer
  94304. * @param indices defines the content of the index buffer
  94305. * @param updatable defines if the index buffer must be updatable
  94306. * @returns a new webGL buffer
  94307. */
  94308. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  94309. /**
  94310. * Bind a webGL buffer to the webGL context
  94311. * @param buffer defines the buffer to bind
  94312. */
  94313. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  94314. /**
  94315. * Bind an uniform buffer to the current webGL context
  94316. * @param buffer defines the buffer to bind
  94317. */
  94318. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  94319. /**
  94320. * Bind a buffer to the current webGL context at a given location
  94321. * @param buffer defines the buffer to bind
  94322. * @param location defines the index where to bind the buffer
  94323. */
  94324. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  94325. /**
  94326. * Bind a specific block at a given index in a specific shader program
  94327. * @param pipelineContext defines the pipeline context to use
  94328. * @param blockName defines the block name
  94329. * @param index defines the index where to bind the block
  94330. */
  94331. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  94332. private bindIndexBuffer;
  94333. private bindBuffer;
  94334. /**
  94335. * update the bound buffer with the given data
  94336. * @param data defines the data to update
  94337. */
  94338. updateArrayBuffer(data: Float32Array): void;
  94339. private _vertexAttribPointer;
  94340. private _bindIndexBufferWithCache;
  94341. private _bindVertexBuffersAttributes;
  94342. /**
  94343. * Records a vertex array object
  94344. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94345. * @param vertexBuffers defines the list of vertex buffers to store
  94346. * @param indexBuffer defines the index buffer to store
  94347. * @param effect defines the effect to store
  94348. * @returns the new vertex array object
  94349. */
  94350. recordVertexArrayObject(vertexBuffers: {
  94351. [key: string]: VertexBuffer;
  94352. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  94353. /**
  94354. * Bind a specific vertex array object
  94355. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94356. * @param vertexArrayObject defines the vertex array object to bind
  94357. * @param indexBuffer defines the index buffer to bind
  94358. */
  94359. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  94360. /**
  94361. * Bind webGl buffers directly to the webGL context
  94362. * @param vertexBuffer defines the vertex buffer to bind
  94363. * @param indexBuffer defines the index buffer to bind
  94364. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  94365. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  94366. * @param effect defines the effect associated with the vertex buffer
  94367. */
  94368. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  94369. private _unbindVertexArrayObject;
  94370. /**
  94371. * Bind a list of vertex buffers to the webGL context
  94372. * @param vertexBuffers defines the list of vertex buffers to bind
  94373. * @param indexBuffer defines the index buffer to bind
  94374. * @param effect defines the effect associated with the vertex buffers
  94375. */
  94376. bindBuffers(vertexBuffers: {
  94377. [key: string]: Nullable<VertexBuffer>;
  94378. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  94379. /**
  94380. * Unbind all instance attributes
  94381. */
  94382. unbindInstanceAttributes(): void;
  94383. /**
  94384. * Release and free the memory of a vertex array object
  94385. * @param vao defines the vertex array object to delete
  94386. */
  94387. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  94388. /** @hidden */
  94389. _releaseBuffer(buffer: DataBuffer): boolean;
  94390. /**
  94391. * Creates a webGL buffer to use with instanciation
  94392. * @param capacity defines the size of the buffer
  94393. * @returns the webGL buffer
  94394. */
  94395. createInstancesBuffer(capacity: number): DataBuffer;
  94396. /**
  94397. * Delete a webGL buffer used with instanciation
  94398. * @param buffer defines the webGL buffer to delete
  94399. */
  94400. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  94401. /**
  94402. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  94403. * @param instancesBuffer defines the webGL buffer to update and bind
  94404. * @param data defines the data to store in the buffer
  94405. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  94406. */
  94407. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  94408. /**
  94409. * Apply all cached states (depth, culling, stencil and alpha)
  94410. */
  94411. applyStates(): void;
  94412. /**
  94413. * Send a draw order
  94414. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94415. * @param indexStart defines the starting index
  94416. * @param indexCount defines the number of index to draw
  94417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94418. */
  94419. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  94420. /**
  94421. * Draw a list of points
  94422. * @param verticesStart defines the index of first vertex to draw
  94423. * @param verticesCount defines the count of vertices to draw
  94424. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94425. */
  94426. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94427. /**
  94428. * Draw a list of unindexed primitives
  94429. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94430. * @param verticesStart defines the index of first vertex to draw
  94431. * @param verticesCount defines the count of vertices to draw
  94432. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94433. */
  94434. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94435. /**
  94436. * Draw a list of indexed primitives
  94437. * @param fillMode defines the primitive to use
  94438. * @param indexStart defines the starting index
  94439. * @param indexCount defines the number of index to draw
  94440. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94441. */
  94442. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  94443. /**
  94444. * Draw a list of unindexed primitives
  94445. * @param fillMode defines the primitive to use
  94446. * @param verticesStart defines the index of first vertex to draw
  94447. * @param verticesCount defines the count of vertices to draw
  94448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94449. */
  94450. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94451. private _drawMode;
  94452. /** @hidden */
  94453. _releaseEffect(effect: Effect): void;
  94454. /** @hidden */
  94455. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  94456. /**
  94457. * Create a new effect (used to store vertex/fragment shaders)
  94458. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  94459. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  94460. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  94461. * @param samplers defines an array of string used to represent textures
  94462. * @param defines defines the string containing the defines to use to compile the shaders
  94463. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  94464. * @param onCompiled defines a function to call when the effect creation is successful
  94465. * @param onError defines a function to call when the effect creation has failed
  94466. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  94467. * @returns the new Effect
  94468. */
  94469. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  94470. private _compileShader;
  94471. private _compileRawShader;
  94472. /**
  94473. * Directly creates a webGL program
  94474. * @param pipelineContext defines the pipeline context to attach to
  94475. * @param vertexCode defines the vertex shader code to use
  94476. * @param fragmentCode defines the fragment shader code to use
  94477. * @param context defines the webGL context to use (if not set, the current one will be used)
  94478. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94479. * @returns the new webGL program
  94480. */
  94481. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94482. /**
  94483. * Creates a webGL program
  94484. * @param pipelineContext defines the pipeline context to attach to
  94485. * @param vertexCode defines the vertex shader code to use
  94486. * @param fragmentCode defines the fragment shader code to use
  94487. * @param defines defines the string containing the defines to use to compile the shaders
  94488. * @param context defines the webGL context to use (if not set, the current one will be used)
  94489. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94490. * @returns the new webGL program
  94491. */
  94492. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94493. /**
  94494. * Creates a new pipeline context
  94495. * @returns the new pipeline
  94496. */
  94497. createPipelineContext(): WebGLPipelineContext;
  94498. private _createShaderProgram;
  94499. private _finalizePipelineContext;
  94500. /** @hidden */
  94501. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  94502. /** @hidden */
  94503. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  94504. /** @hidden */
  94505. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  94506. /**
  94507. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  94508. * @param pipelineContext defines the pipeline context to use
  94509. * @param uniformsNames defines the list of uniform names
  94510. * @returns an array of webGL uniform locations
  94511. */
  94512. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  94513. /**
  94514. * Gets the lsit of active attributes for a given webGL program
  94515. * @param pipelineContext defines the pipeline context to use
  94516. * @param attributesNames defines the list of attribute names to get
  94517. * @returns an array of indices indicating the offset of each attribute
  94518. */
  94519. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  94520. /**
  94521. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  94522. * @param effect defines the effect to activate
  94523. */
  94524. enableEffect(effect: Nullable<Effect>): void;
  94525. /**
  94526. * Set the value of an uniform to an array of int32
  94527. * @param uniform defines the webGL uniform location where to store the value
  94528. * @param array defines the array of int32 to store
  94529. */
  94530. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94531. /**
  94532. * Set the value of an uniform to an array of int32 (stored as vec2)
  94533. * @param uniform defines the webGL uniform location where to store the value
  94534. * @param array defines the array of int32 to store
  94535. */
  94536. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94537. /**
  94538. * Set the value of an uniform to an array of int32 (stored as vec3)
  94539. * @param uniform defines the webGL uniform location where to store the value
  94540. * @param array defines the array of int32 to store
  94541. */
  94542. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94543. /**
  94544. * Set the value of an uniform to an array of int32 (stored as vec4)
  94545. * @param uniform defines the webGL uniform location where to store the value
  94546. * @param array defines the array of int32 to store
  94547. */
  94548. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94549. /**
  94550. * Set the value of an uniform to an array of float32
  94551. * @param uniform defines the webGL uniform location where to store the value
  94552. * @param array defines the array of float32 to store
  94553. */
  94554. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94555. /**
  94556. * Set the value of an uniform to an array of float32 (stored as vec2)
  94557. * @param uniform defines the webGL uniform location where to store the value
  94558. * @param array defines the array of float32 to store
  94559. */
  94560. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94561. /**
  94562. * Set the value of an uniform to an array of float32 (stored as vec3)
  94563. * @param uniform defines the webGL uniform location where to store the value
  94564. * @param array defines the array of float32 to store
  94565. */
  94566. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94567. /**
  94568. * Set the value of an uniform to an array of float32 (stored as vec4)
  94569. * @param uniform defines the webGL uniform location where to store the value
  94570. * @param array defines the array of float32 to store
  94571. */
  94572. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94573. /**
  94574. * Set the value of an uniform to an array of number
  94575. * @param uniform defines the webGL uniform location where to store the value
  94576. * @param array defines the array of number to store
  94577. */
  94578. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94579. /**
  94580. * Set the value of an uniform to an array of number (stored as vec2)
  94581. * @param uniform defines the webGL uniform location where to store the value
  94582. * @param array defines the array of number to store
  94583. */
  94584. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94585. /**
  94586. * Set the value of an uniform to an array of number (stored as vec3)
  94587. * @param uniform defines the webGL uniform location where to store the value
  94588. * @param array defines the array of number to store
  94589. */
  94590. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94591. /**
  94592. * Set the value of an uniform to an array of number (stored as vec4)
  94593. * @param uniform defines the webGL uniform location where to store the value
  94594. * @param array defines the array of number to store
  94595. */
  94596. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94597. /**
  94598. * Set the value of an uniform to an array of float32 (stored as matrices)
  94599. * @param uniform defines the webGL uniform location where to store the value
  94600. * @param matrices defines the array of float32 to store
  94601. */
  94602. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  94603. /**
  94604. * Set the value of an uniform to a matrix (3x3)
  94605. * @param uniform defines the webGL uniform location where to store the value
  94606. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  94607. */
  94608. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94609. /**
  94610. * Set the value of an uniform to a matrix (2x2)
  94611. * @param uniform defines the webGL uniform location where to store the value
  94612. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  94613. */
  94614. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94615. /**
  94616. * Set the value of an uniform to a number (int)
  94617. * @param uniform defines the webGL uniform location where to store the value
  94618. * @param value defines the int number to store
  94619. */
  94620. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94621. /**
  94622. * Set the value of an uniform to a number (float)
  94623. * @param uniform defines the webGL uniform location where to store the value
  94624. * @param value defines the float number to store
  94625. */
  94626. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94627. /**
  94628. * Set the value of an uniform to a vec2
  94629. * @param uniform defines the webGL uniform location where to store the value
  94630. * @param x defines the 1st component of the value
  94631. * @param y defines the 2nd component of the value
  94632. */
  94633. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  94634. /**
  94635. * Set the value of an uniform to a vec3
  94636. * @param uniform defines the webGL uniform location where to store the value
  94637. * @param x defines the 1st component of the value
  94638. * @param y defines the 2nd component of the value
  94639. * @param z defines the 3rd component of the value
  94640. */
  94641. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  94642. /**
  94643. * Set the value of an uniform to a boolean
  94644. * @param uniform defines the webGL uniform location where to store the value
  94645. * @param bool defines the boolean to store
  94646. */
  94647. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  94648. /**
  94649. * Set the value of an uniform to a vec4
  94650. * @param uniform defines the webGL uniform location where to store the value
  94651. * @param x defines the 1st component of the value
  94652. * @param y defines the 2nd component of the value
  94653. * @param z defines the 3rd component of the value
  94654. * @param w defines the 4th component of the value
  94655. */
  94656. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  94657. /**
  94658. * Sets a Color4 on a uniform variable
  94659. * @param uniform defines the uniform location
  94660. * @param color4 defines the value to be set
  94661. */
  94662. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  94663. /**
  94664. * Set various states to the webGL context
  94665. * @param culling defines backface culling state
  94666. * @param zOffset defines the value to apply to zOffset (0 by default)
  94667. * @param force defines if states must be applied even if cache is up to date
  94668. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  94669. */
  94670. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  94671. /**
  94672. * Set the z offset to apply to current rendering
  94673. * @param value defines the offset to apply
  94674. */
  94675. setZOffset(value: number): void;
  94676. /**
  94677. * Gets the current value of the zOffset
  94678. * @returns the current zOffset state
  94679. */
  94680. getZOffset(): number;
  94681. /**
  94682. * Enable or disable depth buffering
  94683. * @param enable defines the state to set
  94684. */
  94685. setDepthBuffer(enable: boolean): void;
  94686. /**
  94687. * Gets a boolean indicating if depth writing is enabled
  94688. * @returns the current depth writing state
  94689. */
  94690. getDepthWrite(): boolean;
  94691. /**
  94692. * Enable or disable depth writing
  94693. * @param enable defines the state to set
  94694. */
  94695. setDepthWrite(enable: boolean): void;
  94696. /**
  94697. * Enable or disable color writing
  94698. * @param enable defines the state to set
  94699. */
  94700. setColorWrite(enable: boolean): void;
  94701. /**
  94702. * Gets a boolean indicating if color writing is enabled
  94703. * @returns the current color writing state
  94704. */
  94705. getColorWrite(): boolean;
  94706. /**
  94707. * Sets alpha constants used by some alpha blending modes
  94708. * @param r defines the red component
  94709. * @param g defines the green component
  94710. * @param b defines the blue component
  94711. * @param a defines the alpha component
  94712. */
  94713. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  94714. /**
  94715. * Sets the current alpha mode
  94716. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  94717. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  94718. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94719. */
  94720. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  94721. /**
  94722. * Gets the current alpha mode
  94723. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94724. * @returns the current alpha mode
  94725. */
  94726. getAlphaMode(): number;
  94727. /**
  94728. * Clears the list of texture accessible through engine.
  94729. * This can help preventing texture load conflict due to name collision.
  94730. */
  94731. clearInternalTexturesCache(): void;
  94732. /**
  94733. * Force the entire cache to be cleared
  94734. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  94735. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  94736. */
  94737. wipeCaches(bruteForce?: boolean): void;
  94738. /**
  94739. * Set the compressed texture format to use, based on the formats you have, and the formats
  94740. * supported by the hardware / browser.
  94741. *
  94742. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  94743. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  94744. * to API arguments needed to compressed textures. This puts the burden on the container
  94745. * generator to house the arcane code for determining these for current & future formats.
  94746. *
  94747. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  94748. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  94749. *
  94750. * Note: The result of this call is not taken into account when a texture is base64.
  94751. *
  94752. * @param formatsAvailable defines the list of those format families you have created
  94753. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  94754. *
  94755. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  94756. * @returns The extension selected.
  94757. */
  94758. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  94759. /** @hidden */
  94760. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  94761. min: number;
  94762. mag: number;
  94763. };
  94764. /** @hidden */
  94765. _createTexture(): WebGLTexture;
  94766. /**
  94767. * Usually called from Texture.ts.
  94768. * Passed information to create a WebGLTexture
  94769. * @param urlArg defines a value which contains one of the following:
  94770. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  94771. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  94772. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  94773. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  94774. * @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)
  94775. * @param scene needed for loading to the correct scene
  94776. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  94777. * @param onLoad optional callback to be called upon successful completion
  94778. * @param onError optional callback to be called upon failure
  94779. * @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
  94780. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  94781. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  94782. * @param forcedExtension defines the extension to use to pick the right loader
  94783. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  94784. * @returns a InternalTexture for assignment back into BABYLON.Texture
  94785. */
  94786. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  94787. /**
  94788. * @hidden
  94789. * Rescales a texture
  94790. * @param source input texutre
  94791. * @param destination destination texture
  94792. * @param scene scene to use to render the resize
  94793. * @param internalFormat format to use when resizing
  94794. * @param onComplete callback to be called when resize has completed
  94795. */
  94796. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  94797. private _unpackFlipYCached;
  94798. /**
  94799. * In case you are sharing the context with other applications, it might
  94800. * be interested to not cache the unpack flip y state to ensure a consistent
  94801. * value would be set.
  94802. */
  94803. enableUnpackFlipYCached: boolean;
  94804. /** @hidden */
  94805. _unpackFlipY(value: boolean): void;
  94806. /** @hidden */
  94807. _getUnpackAlignement(): number;
  94808. /**
  94809. * Creates a dynamic texture
  94810. * @param width defines the width of the texture
  94811. * @param height defines the height of the texture
  94812. * @param generateMipMaps defines if the engine should generate the mip levels
  94813. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  94814. * @returns the dynamic texture inside an InternalTexture
  94815. */
  94816. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  94817. /**
  94818. * Update the sampling mode of a given texture
  94819. * @param samplingMode defines the required sampling mode
  94820. * @param texture defines the texture to update
  94821. */
  94822. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  94823. /**
  94824. * Update the content of a dynamic texture
  94825. * @param texture defines the texture to update
  94826. * @param canvas defines the canvas containing the source
  94827. * @param invertY defines if data must be stored with Y axis inverted
  94828. * @param premulAlpha defines if alpha is stored as premultiplied
  94829. * @param format defines the format of the data
  94830. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  94831. */
  94832. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  94833. /**
  94834. * Update a video texture
  94835. * @param texture defines the texture to update
  94836. * @param video defines the video element to use
  94837. * @param invertY defines if data must be stored with Y axis inverted
  94838. */
  94839. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  94840. /**
  94841. * Updates a depth texture Comparison Mode and Function.
  94842. * If the comparison Function is equal to 0, the mode will be set to none.
  94843. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  94844. * @param texture The texture to set the comparison function for
  94845. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  94846. */
  94847. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  94848. /** @hidden */
  94849. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  94850. width: number;
  94851. height: number;
  94852. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  94853. /**
  94854. * Creates a depth stencil texture.
  94855. * This is only available in WebGL 2 or with the depth texture extension available.
  94856. * @param size The size of face edge in the texture.
  94857. * @param options The options defining the texture.
  94858. * @returns The texture
  94859. */
  94860. createDepthStencilTexture(size: number | {
  94861. width: number;
  94862. height: number;
  94863. }, options: DepthTextureCreationOptions): InternalTexture;
  94864. /**
  94865. * Creates a depth stencil texture.
  94866. * This is only available in WebGL 2 or with the depth texture extension available.
  94867. * @param size The size of face edge in the texture.
  94868. * @param options The options defining the texture.
  94869. * @returns The texture
  94870. */
  94871. private _createDepthStencilTexture;
  94872. /**
  94873. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  94874. * @param renderTarget The render target to set the frame buffer for
  94875. */
  94876. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  94877. /**
  94878. * Creates a new render target texture
  94879. * @param size defines the size of the texture
  94880. * @param options defines the options used to create the texture
  94881. * @returns a new render target texture stored in an InternalTexture
  94882. */
  94883. createRenderTargetTexture(size: number | {
  94884. width: number;
  94885. height: number;
  94886. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  94887. /** @hidden */
  94888. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  94889. /**
  94890. * Updates the sample count of a render target texture
  94891. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  94892. * @param texture defines the texture to update
  94893. * @param samples defines the sample count to set
  94894. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  94895. */
  94896. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  94897. /** @hidden */
  94898. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  94899. /** @hidden */
  94900. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  94901. /** @hidden */
  94902. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  94903. /** @hidden */
  94904. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  94905. /**
  94906. * @hidden
  94907. */
  94908. _setCubeMapTextureParams(loadMipmap: boolean): void;
  94909. private _prepareWebGLTextureContinuation;
  94910. private _prepareWebGLTexture;
  94911. /** @hidden */
  94912. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  94913. /** @hidden */
  94914. _releaseFramebufferObjects(texture: InternalTexture): void;
  94915. /** @hidden */
  94916. _releaseTexture(texture: InternalTexture): void;
  94917. private setProgram;
  94918. private _boundUniforms;
  94919. /**
  94920. * Binds an effect to the webGL context
  94921. * @param effect defines the effect to bind
  94922. */
  94923. bindSamplers(effect: Effect): void;
  94924. private _activateCurrentTexture;
  94925. /** @hidden */
  94926. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  94927. /** @hidden */
  94928. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  94929. /**
  94930. * Sets a texture to the webGL context from a postprocess
  94931. * @param channel defines the channel to use
  94932. * @param postProcess defines the source postprocess
  94933. */
  94934. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  94935. /**
  94936. * Binds the output of the passed in post process to the texture channel specified
  94937. * @param channel The channel the texture should be bound to
  94938. * @param postProcess The post process which's output should be bound
  94939. */
  94940. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  94941. /**
  94942. * Unbind all textures from the webGL context
  94943. */
  94944. unbindAllTextures(): void;
  94945. /**
  94946. * Sets a texture to the according uniform.
  94947. * @param channel The texture channel
  94948. * @param uniform The uniform to set
  94949. * @param texture The texture to apply
  94950. */
  94951. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  94952. /**
  94953. * Sets a depth stencil texture from a render target to the according uniform.
  94954. * @param channel The texture channel
  94955. * @param uniform The uniform to set
  94956. * @param texture The render target texture containing the depth stencil texture to apply
  94957. */
  94958. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  94959. private _bindSamplerUniformToChannel;
  94960. private _getTextureWrapMode;
  94961. private _setTexture;
  94962. /**
  94963. * Sets an array of texture to the webGL context
  94964. * @param channel defines the channel where the texture array must be set
  94965. * @param uniform defines the associated uniform location
  94966. * @param textures defines the array of textures to bind
  94967. */
  94968. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  94969. /** @hidden */
  94970. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  94971. private _setTextureParameterFloat;
  94972. private _setTextureParameterInteger;
  94973. /**
  94974. * Reads pixels from the current frame buffer. Please note that this function can be slow
  94975. * @param x defines the x coordinate of the rectangle where pixels must be read
  94976. * @param y defines the y coordinate of the rectangle where pixels must be read
  94977. * @param width defines the width of the rectangle where pixels must be read
  94978. * @param height defines the height of the rectangle where pixels must be read
  94979. * @returns a Uint8Array containing RGBA colors
  94980. */
  94981. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  94982. /**
  94983. * Add an externaly attached data from its key.
  94984. * This method call will fail and return false, if such key already exists.
  94985. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  94986. * @param key the unique key that identifies the data
  94987. * @param data the data object to associate to the key for this Engine instance
  94988. * @return true if no such key were already present and the data was added successfully, false otherwise
  94989. */
  94990. addExternalData<T>(key: string, data: T): boolean;
  94991. /**
  94992. * Get an externaly attached data from its key
  94993. * @param key the unique key that identifies the data
  94994. * @return the associated data, if present (can be null), or undefined if not present
  94995. */
  94996. getExternalData<T>(key: string): T;
  94997. /**
  94998. * Get an externaly attached data from its key, create it using a factory if it's not already present
  94999. * @param key the unique key that identifies the data
  95000. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95001. * @return the associated data, can be null if the factory returned null.
  95002. */
  95003. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95004. /**
  95005. * Remove an externaly attached data from the Engine instance
  95006. * @param key the unique key that identifies the data
  95007. * @return true if the data was successfully removed, false if it doesn't exist
  95008. */
  95009. removeExternalData(key: string): boolean;
  95010. /**
  95011. * Unbind all vertex attributes from the webGL context
  95012. */
  95013. unbindAllAttributes(): void;
  95014. /**
  95015. * 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
  95016. */
  95017. releaseEffects(): void;
  95018. /**
  95019. * Dispose and release all associated resources
  95020. */
  95021. dispose(): void;
  95022. /**
  95023. * Display the loading screen
  95024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95025. */
  95026. displayLoadingUI(): void;
  95027. /**
  95028. * Hide the loading screen
  95029. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95030. */
  95031. hideLoadingUI(): void;
  95032. /**
  95033. * Gets the current loading screen object
  95034. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95035. */
  95036. /**
  95037. * Sets the current loading screen object
  95038. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95039. */
  95040. loadingScreen: ILoadingScreen;
  95041. /**
  95042. * Sets the current loading screen text
  95043. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95044. */
  95045. loadingUIText: string;
  95046. /**
  95047. * Sets the current loading screen background color
  95048. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95049. */
  95050. loadingUIBackgroundColor: string;
  95051. /**
  95052. * Attach a new callback raised when context lost event is fired
  95053. * @param callback defines the callback to call
  95054. */
  95055. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95056. /**
  95057. * Attach a new callback raised when context restored event is fired
  95058. * @param callback defines the callback to call
  95059. */
  95060. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95061. /**
  95062. * Gets the source code of the vertex shader associated with a specific webGL program
  95063. * @param program defines the program to use
  95064. * @returns a string containing the source code of the vertex shader associated with the program
  95065. */
  95066. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95067. /**
  95068. * Gets the source code of the fragment shader associated with a specific webGL program
  95069. * @param program defines the program to use
  95070. * @returns a string containing the source code of the fragment shader associated with the program
  95071. */
  95072. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  95073. /**
  95074. * Get the current error code of the webGL context
  95075. * @returns the error code
  95076. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  95077. */
  95078. getError(): number;
  95079. /**
  95080. * Gets the current framerate
  95081. * @returns a number representing the framerate
  95082. */
  95083. getFps(): number;
  95084. /**
  95085. * Gets the time spent between current and previous frame
  95086. * @returns a number representing the delta time in ms
  95087. */
  95088. getDeltaTime(): number;
  95089. private _measureFps;
  95090. /** @hidden */
  95091. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  95092. private _canRenderToFloatFramebuffer;
  95093. private _canRenderToHalfFloatFramebuffer;
  95094. private _canRenderToFramebuffer;
  95095. /** @hidden */
  95096. _getWebGLTextureType(type: number): number;
  95097. /** @hidden */
  95098. _getInternalFormat(format: number): number;
  95099. /** @hidden */
  95100. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  95101. /** @hidden */
  95102. _getRGBAMultiSampleBufferFormat(type: number): number;
  95103. /** @hidden */
  95104. _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;
  95105. /** @hidden */
  95106. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95107. /**
  95108. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  95109. * @returns true if the engine can be created
  95110. * @ignorenaming
  95111. */
  95112. static isSupported(): boolean;
  95113. /**
  95114. * Find the next highest power of two.
  95115. * @param x Number to start search from.
  95116. * @return Next highest power of two.
  95117. */
  95118. static CeilingPOT(x: number): number;
  95119. /**
  95120. * Find the next lowest power of two.
  95121. * @param x Number to start search from.
  95122. * @return Next lowest power of two.
  95123. */
  95124. static FloorPOT(x: number): number;
  95125. /**
  95126. * Find the nearest power of two.
  95127. * @param x Number to start search from.
  95128. * @return Next nearest power of two.
  95129. */
  95130. static NearestPOT(x: number): number;
  95131. /**
  95132. * Get the closest exponent of two
  95133. * @param value defines the value to approximate
  95134. * @param max defines the maximum value to return
  95135. * @param mode defines how to define the closest value
  95136. * @returns closest exponent of two of the given value
  95137. */
  95138. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  95139. /**
  95140. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  95141. * @param func - the function to be called
  95142. * @param requester - the object that will request the next frame. Falls back to window.
  95143. * @returns frame number
  95144. */
  95145. static QueueNewFrame(func: () => void, requester?: any): number;
  95146. /**
  95147. * Ask the browser to promote the current element to pointerlock mode
  95148. * @param element defines the DOM element to promote
  95149. */
  95150. static _RequestPointerlock(element: HTMLElement): void;
  95151. /**
  95152. * Asks the browser to exit pointerlock mode
  95153. */
  95154. static _ExitPointerlock(): void;
  95155. /**
  95156. * Ask the browser to promote the current element to fullscreen rendering mode
  95157. * @param element defines the DOM element to promote
  95158. */
  95159. static _RequestFullscreen(element: HTMLElement): void;
  95160. /**
  95161. * Asks the browser to exit fullscreen mode
  95162. */
  95163. static _ExitFullscreen(): void;
  95164. }
  95165. }
  95166. declare module BABYLON {
  95167. /**
  95168. * The engine store class is responsible to hold all the instances of Engine and Scene created
  95169. * during the life time of the application.
  95170. */
  95171. export class EngineStore {
  95172. /** Gets the list of created engines */
  95173. static Instances: Engine[];
  95174. /** @hidden */
  95175. static _LastCreatedScene: Nullable<Scene>;
  95176. /**
  95177. * Gets the latest created engine
  95178. */
  95179. static readonly LastCreatedEngine: Nullable<Engine>;
  95180. /**
  95181. * Gets the latest created scene
  95182. */
  95183. static readonly LastCreatedScene: Nullable<Scene>;
  95184. /**
  95185. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95186. * @ignorenaming
  95187. */
  95188. static UseFallbackTexture: boolean;
  95189. /**
  95190. * Texture content used if a texture cannot loaded
  95191. * @ignorenaming
  95192. */
  95193. static FallbackTexture: string;
  95194. }
  95195. }
  95196. declare module BABYLON {
  95197. /**
  95198. * Helper class that provides a small promise polyfill
  95199. */
  95200. export class PromisePolyfill {
  95201. /**
  95202. * Static function used to check if the polyfill is required
  95203. * If this is the case then the function will inject the polyfill to window.Promise
  95204. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95205. */
  95206. static Apply(force?: boolean): void;
  95207. }
  95208. }
  95209. declare module BABYLON {
  95210. interface IColor4Like {
  95211. r: float;
  95212. g: float;
  95213. b: float;
  95214. a: float;
  95215. }
  95216. /**
  95217. * Class containing a set of static utilities functions
  95218. */
  95219. export class Tools {
  95220. /**
  95221. * Gets or sets the base URL to use to load assets
  95222. */
  95223. static BaseUrl: string;
  95224. /**
  95225. * Enable/Disable Custom HTTP Request Headers globally.
  95226. * default = false
  95227. * @see CustomRequestHeaders
  95228. */
  95229. static UseCustomRequestHeaders: boolean;
  95230. /**
  95231. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  95232. * i.e. when loading files, where the server/service expects an Authorization header
  95233. */
  95234. static CustomRequestHeaders: {
  95235. [key: string]: string;
  95236. };
  95237. /**
  95238. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  95239. */
  95240. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  95241. /**
  95242. * Default behaviour for cors in the application.
  95243. * It can be a string if the expected behavior is identical in the entire app.
  95244. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  95245. */
  95246. static CorsBehavior: string | ((url: string | string[]) => string);
  95247. /**
  95248. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95249. * @ignorenaming
  95250. */
  95251. static UseFallbackTexture: boolean;
  95252. /**
  95253. * Use this object to register external classes like custom textures or material
  95254. * to allow the laoders to instantiate them
  95255. */
  95256. static RegisteredExternalClasses: {
  95257. [key: string]: Object;
  95258. };
  95259. /**
  95260. * Texture content used if a texture cannot loaded
  95261. * @ignorenaming
  95262. */
  95263. static fallbackTexture: string;
  95264. /**
  95265. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  95266. * @param u defines the coordinate on X axis
  95267. * @param v defines the coordinate on Y axis
  95268. * @param width defines the width of the source data
  95269. * @param height defines the height of the source data
  95270. * @param pixels defines the source byte array
  95271. * @param color defines the output color
  95272. */
  95273. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  95274. /**
  95275. * Interpolates between a and b via alpha
  95276. * @param a The lower value (returned when alpha = 0)
  95277. * @param b The upper value (returned when alpha = 1)
  95278. * @param alpha The interpolation-factor
  95279. * @return The mixed value
  95280. */
  95281. static Mix(a: number, b: number, alpha: number): number;
  95282. /**
  95283. * Tries to instantiate a new object from a given class name
  95284. * @param className defines the class name to instantiate
  95285. * @returns the new object or null if the system was not able to do the instantiation
  95286. */
  95287. static Instantiate(className: string): any;
  95288. /**
  95289. * Provides a slice function that will work even on IE
  95290. * @param data defines the array to slice
  95291. * @param start defines the start of the data (optional)
  95292. * @param end defines the end of the data (optional)
  95293. * @returns the new sliced array
  95294. */
  95295. static Slice<T>(data: T, start?: number, end?: number): T;
  95296. /**
  95297. * Polyfill for setImmediate
  95298. * @param action defines the action to execute after the current execution block
  95299. */
  95300. static SetImmediate(action: () => void): void;
  95301. /**
  95302. * Function indicating if a number is an exponent of 2
  95303. * @param value defines the value to test
  95304. * @returns true if the value is an exponent of 2
  95305. */
  95306. static IsExponentOfTwo(value: number): boolean;
  95307. private static _tmpFloatArray;
  95308. /**
  95309. * Returns the nearest 32-bit single precision float representation of a Number
  95310. * @param value A Number. If the parameter is of a different type, it will get converted
  95311. * to a number or to NaN if it cannot be converted
  95312. * @returns number
  95313. */
  95314. static FloatRound(value: number): number;
  95315. /**
  95316. * Extracts the filename from a path
  95317. * @param path defines the path to use
  95318. * @returns the filename
  95319. */
  95320. static GetFilename(path: string): string;
  95321. /**
  95322. * Extracts the "folder" part of a path (everything before the filename).
  95323. * @param uri The URI to extract the info from
  95324. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  95325. * @returns The "folder" part of the path
  95326. */
  95327. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  95328. /**
  95329. * Extracts text content from a DOM element hierarchy
  95330. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  95331. */
  95332. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  95333. /**
  95334. * Convert an angle in radians to degrees
  95335. * @param angle defines the angle to convert
  95336. * @returns the angle in degrees
  95337. */
  95338. static ToDegrees(angle: number): number;
  95339. /**
  95340. * Convert an angle in degrees to radians
  95341. * @param angle defines the angle to convert
  95342. * @returns the angle in radians
  95343. */
  95344. static ToRadians(angle: number): number;
  95345. /**
  95346. * Encode a buffer to a base64 string
  95347. * @param buffer defines the buffer to encode
  95348. * @returns the encoded string
  95349. */
  95350. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  95351. /**
  95352. * Returns an array if obj is not an array
  95353. * @param obj defines the object to evaluate as an array
  95354. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  95355. * @returns either obj directly if obj is an array or a new array containing obj
  95356. */
  95357. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  95358. /**
  95359. * Gets the pointer prefix to use
  95360. * @returns "pointer" if touch is enabled. Else returns "mouse"
  95361. */
  95362. static GetPointerPrefix(): string;
  95363. /**
  95364. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  95365. * @param url define the url we are trying
  95366. * @param element define the dom element where to configure the cors policy
  95367. */
  95368. static SetCorsBehavior(url: string | string[], element: {
  95369. crossOrigin: string | null;
  95370. }): void;
  95371. /**
  95372. * Removes unwanted characters from an url
  95373. * @param url defines the url to clean
  95374. * @returns the cleaned url
  95375. */
  95376. static CleanUrl(url: string): string;
  95377. /**
  95378. * Gets or sets a function used to pre-process url before using them to load assets
  95379. */
  95380. static PreprocessUrl: (url: string) => string;
  95381. /**
  95382. * Loads an image as an HTMLImageElement.
  95383. * @param input url string, ArrayBuffer, or Blob to load
  95384. * @param onLoad callback called when the image successfully loads
  95385. * @param onError callback called when the image fails to load
  95386. * @param offlineProvider offline provider for caching
  95387. * @returns the HTMLImageElement of the loaded image
  95388. */
  95389. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  95390. /**
  95391. * Loads a file
  95392. * @param url url string, ArrayBuffer, or Blob to load
  95393. * @param onSuccess callback called when the file successfully loads
  95394. * @param onProgress callback called while file is loading (if the server supports this mode)
  95395. * @param offlineProvider defines the offline provider for caching
  95396. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  95397. * @param onError callback called when the file fails to load
  95398. * @returns a file request object
  95399. */
  95400. 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;
  95401. /**
  95402. * Loads a file from a url
  95403. * @param url the file url to load
  95404. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  95405. */
  95406. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  95407. /**
  95408. * Load a script (identified by an url). When the url returns, the
  95409. * content of this file is added into a new script element, attached to the DOM (body element)
  95410. * @param scriptUrl defines the url of the script to laod
  95411. * @param onSuccess defines the callback called when the script is loaded
  95412. * @param onError defines the callback to call if an error occurs
  95413. * @param scriptId defines the id of the script element
  95414. */
  95415. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  95416. /**
  95417. * Load an asynchronous script (identified by an url). When the url returns, the
  95418. * content of this file is added into a new script element, attached to the DOM (body element)
  95419. * @param scriptUrl defines the url of the script to laod
  95420. * @param scriptId defines the id of the script element
  95421. * @returns a promise request object
  95422. */
  95423. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  95424. /**
  95425. * Loads a file from a blob
  95426. * @param fileToLoad defines the blob to use
  95427. * @param callback defines the callback to call when data is loaded
  95428. * @param progressCallback defines the callback to call during loading process
  95429. * @returns a file request object
  95430. */
  95431. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  95432. /**
  95433. * Loads a file
  95434. * @param fileToLoad defines the file to load
  95435. * @param callback defines the callback to call when data is loaded
  95436. * @param progressCallBack defines the callback to call during loading process
  95437. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  95438. * @returns a file request object
  95439. */
  95440. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  95441. /**
  95442. * Creates a data url from a given string content
  95443. * @param content defines the content to convert
  95444. * @returns the new data url link
  95445. */
  95446. static FileAsURL(content: string): string;
  95447. /**
  95448. * Format the given number to a specific decimal format
  95449. * @param value defines the number to format
  95450. * @param decimals defines the number of decimals to use
  95451. * @returns the formatted string
  95452. */
  95453. static Format(value: number, decimals?: number): string;
  95454. /**
  95455. * Tries to copy an object by duplicating every property
  95456. * @param source defines the source object
  95457. * @param destination defines the target object
  95458. * @param doNotCopyList defines a list of properties to avoid
  95459. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  95460. */
  95461. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  95462. /**
  95463. * Gets a boolean indicating if the given object has no own property
  95464. * @param obj defines the object to test
  95465. * @returns true if object has no own property
  95466. */
  95467. static IsEmpty(obj: any): boolean;
  95468. /**
  95469. * Function used to register events at window level
  95470. * @param events defines the events to register
  95471. */
  95472. static RegisterTopRootEvents(events: {
  95473. name: string;
  95474. handler: Nullable<(e: FocusEvent) => any>;
  95475. }[]): void;
  95476. /**
  95477. * Function used to unregister events from window level
  95478. * @param events defines the events to unregister
  95479. */
  95480. static UnregisterTopRootEvents(events: {
  95481. name: string;
  95482. handler: Nullable<(e: FocusEvent) => any>;
  95483. }[]): void;
  95484. /**
  95485. * @ignore
  95486. */
  95487. static _ScreenshotCanvas: HTMLCanvasElement;
  95488. /**
  95489. * Dumps the current bound framebuffer
  95490. * @param width defines the rendering width
  95491. * @param height defines the rendering height
  95492. * @param engine defines the hosting engine
  95493. * @param successCallback defines the callback triggered once the data are available
  95494. * @param mimeType defines the mime type of the result
  95495. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  95496. */
  95497. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95498. /**
  95499. * Converts the canvas data to blob.
  95500. * This acts as a polyfill for browsers not supporting the to blob function.
  95501. * @param canvas Defines the canvas to extract the data from
  95502. * @param successCallback Defines the callback triggered once the data are available
  95503. * @param mimeType Defines the mime type of the result
  95504. */
  95505. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  95506. /**
  95507. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  95508. * @param successCallback defines the callback triggered once the data are available
  95509. * @param mimeType defines the mime type of the result
  95510. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  95511. */
  95512. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95513. /**
  95514. * Downloads a blob in the browser
  95515. * @param blob defines the blob to download
  95516. * @param fileName defines the name of the downloaded file
  95517. */
  95518. static Download(blob: Blob, fileName: string): void;
  95519. /**
  95520. * Captures a screenshot of the current rendering
  95521. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95522. * @param engine defines the rendering engine
  95523. * @param camera defines the source camera
  95524. * @param size This parameter can be set to a single number or to an object with the
  95525. * following (optional) properties: precision, width, height. If a single number is passed,
  95526. * it will be used for both width and height. If an object is passed, the screenshot size
  95527. * will be derived from the parameters. The precision property is a multiplier allowing
  95528. * rendering at a higher or lower resolution
  95529. * @param successCallback defines the callback receives a single parameter which contains the
  95530. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95531. * src parameter of an <img> to display it
  95532. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95533. * Check your browser for supported MIME types
  95534. */
  95535. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  95536. /**
  95537. * Generates an image screenshot from the specified camera.
  95538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95539. * @param engine The engine to use for rendering
  95540. * @param camera The camera to use for rendering
  95541. * @param size This parameter can be set to a single number or to an object with the
  95542. * following (optional) properties: precision, width, height. If a single number is passed,
  95543. * it will be used for both width and height. If an object is passed, the screenshot size
  95544. * will be derived from the parameters. The precision property is a multiplier allowing
  95545. * rendering at a higher or lower resolution
  95546. * @param successCallback The callback receives a single parameter which contains the
  95547. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95548. * src parameter of an <img> to display it
  95549. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95550. * Check your browser for supported MIME types
  95551. * @param samples Texture samples (default: 1)
  95552. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95553. * @param fileName A name for for the downloaded file.
  95554. */
  95555. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  95556. /**
  95557. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95558. * Be aware Math.random() could cause collisions, but:
  95559. * "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"
  95560. * @returns a pseudo random id
  95561. */
  95562. static RandomId(): string;
  95563. /**
  95564. * Test if the given uri is a base64 string
  95565. * @param uri The uri to test
  95566. * @return True if the uri is a base64 string or false otherwise
  95567. */
  95568. static IsBase64(uri: string): boolean;
  95569. /**
  95570. * Decode the given base64 uri.
  95571. * @param uri The uri to decode
  95572. * @return The decoded base64 data.
  95573. */
  95574. static DecodeBase64(uri: string): ArrayBuffer;
  95575. /**
  95576. * Gets the absolute url.
  95577. * @param url the input url
  95578. * @return the absolute url
  95579. */
  95580. static GetAbsoluteUrl(url: string): string;
  95581. /**
  95582. * No log
  95583. */
  95584. static readonly NoneLogLevel: number;
  95585. /**
  95586. * Only message logs
  95587. */
  95588. static readonly MessageLogLevel: number;
  95589. /**
  95590. * Only warning logs
  95591. */
  95592. static readonly WarningLogLevel: number;
  95593. /**
  95594. * Only error logs
  95595. */
  95596. static readonly ErrorLogLevel: number;
  95597. /**
  95598. * All logs
  95599. */
  95600. static readonly AllLogLevel: number;
  95601. /**
  95602. * Gets a value indicating the number of loading errors
  95603. * @ignorenaming
  95604. */
  95605. static readonly errorsCount: number;
  95606. /**
  95607. * Callback called when a new log is added
  95608. */
  95609. static OnNewCacheEntry: (entry: string) => void;
  95610. /**
  95611. * Log a message to the console
  95612. * @param message defines the message to log
  95613. */
  95614. static Log(message: string): void;
  95615. /**
  95616. * Write a warning message to the console
  95617. * @param message defines the message to log
  95618. */
  95619. static Warn(message: string): void;
  95620. /**
  95621. * Write an error message to the console
  95622. * @param message defines the message to log
  95623. */
  95624. static Error(message: string): void;
  95625. /**
  95626. * Gets current log cache (list of logs)
  95627. */
  95628. static readonly LogCache: string;
  95629. /**
  95630. * Clears the log cache
  95631. */
  95632. static ClearLogCache(): void;
  95633. /**
  95634. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95635. */
  95636. static LogLevels: number;
  95637. /**
  95638. * Checks if the window object exists
  95639. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  95640. */
  95641. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  95642. /**
  95643. * No performance log
  95644. */
  95645. static readonly PerformanceNoneLogLevel: number;
  95646. /**
  95647. * Use user marks to log performance
  95648. */
  95649. static readonly PerformanceUserMarkLogLevel: number;
  95650. /**
  95651. * Log performance to the console
  95652. */
  95653. static readonly PerformanceConsoleLogLevel: number;
  95654. private static _performance;
  95655. /**
  95656. * Sets the current performance log level
  95657. */
  95658. static PerformanceLogLevel: number;
  95659. private static _StartPerformanceCounterDisabled;
  95660. private static _EndPerformanceCounterDisabled;
  95661. private static _StartUserMark;
  95662. private static _EndUserMark;
  95663. private static _StartPerformanceConsole;
  95664. private static _EndPerformanceConsole;
  95665. /**
  95666. * Starts a performance counter
  95667. */
  95668. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95669. /**
  95670. * Ends a specific performance coutner
  95671. */
  95672. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95673. /**
  95674. * Gets either window.performance.now() if supported or Date.now() else
  95675. */
  95676. static readonly Now: number;
  95677. /**
  95678. * This method will return the name of the class used to create the instance of the given object.
  95679. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  95680. * @param object the object to get the class name from
  95681. * @param isType defines if the object is actually a type
  95682. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  95683. */
  95684. static GetClassName(object: any, isType?: boolean): string;
  95685. /**
  95686. * Gets the first element of an array satisfying a given predicate
  95687. * @param array defines the array to browse
  95688. * @param predicate defines the predicate to use
  95689. * @returns null if not found or the element
  95690. */
  95691. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  95692. /**
  95693. * This method will return the name of the full name of the class, including its owning module (if any).
  95694. * 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).
  95695. * @param object the object to get the class name from
  95696. * @param isType defines if the object is actually a type
  95697. * @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.
  95698. * @ignorenaming
  95699. */
  95700. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  95701. /**
  95702. * Returns a promise that resolves after the given amount of time.
  95703. * @param delay Number of milliseconds to delay
  95704. * @returns Promise that resolves after the given amount of time
  95705. */
  95706. static DelayAsync(delay: number): Promise<void>;
  95707. }
  95708. /**
  95709. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  95710. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  95711. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  95712. * @param name The name of the class, case should be preserved
  95713. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  95714. */
  95715. export function className(name: string, module?: string): (target: Object) => void;
  95716. /**
  95717. * An implementation of a loop for asynchronous functions.
  95718. */
  95719. export class AsyncLoop {
  95720. /**
  95721. * Defines the number of iterations for the loop
  95722. */
  95723. iterations: number;
  95724. /**
  95725. * Defines the current index of the loop.
  95726. */
  95727. index: number;
  95728. private _done;
  95729. private _fn;
  95730. private _successCallback;
  95731. /**
  95732. * Constructor.
  95733. * @param iterations the number of iterations.
  95734. * @param func the function to run each iteration
  95735. * @param successCallback the callback that will be called upon succesful execution
  95736. * @param offset starting offset.
  95737. */
  95738. constructor(
  95739. /**
  95740. * Defines the number of iterations for the loop
  95741. */
  95742. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  95743. /**
  95744. * Execute the next iteration. Must be called after the last iteration was finished.
  95745. */
  95746. executeNext(): void;
  95747. /**
  95748. * Break the loop and run the success callback.
  95749. */
  95750. breakLoop(): void;
  95751. /**
  95752. * Create and run an async loop.
  95753. * @param iterations the number of iterations.
  95754. * @param fn the function to run each iteration
  95755. * @param successCallback the callback that will be called upon succesful execution
  95756. * @param offset starting offset.
  95757. * @returns the created async loop object
  95758. */
  95759. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  95760. /**
  95761. * A for-loop that will run a given number of iterations synchronous and the rest async.
  95762. * @param iterations total number of iterations
  95763. * @param syncedIterations number of synchronous iterations in each async iteration.
  95764. * @param fn the function to call each iteration.
  95765. * @param callback a success call back that will be called when iterating stops.
  95766. * @param breakFunction a break condition (optional)
  95767. * @param timeout timeout settings for the setTimeout function. default - 0.
  95768. * @returns the created async loop object
  95769. */
  95770. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  95771. }
  95772. }
  95773. declare module BABYLON {
  95774. /** @hidden */
  95775. export interface ICollisionCoordinator {
  95776. createCollider(): Collider;
  95777. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  95778. init(scene: Scene): void;
  95779. }
  95780. /** @hidden */
  95781. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  95782. private _scene;
  95783. private _scaledPosition;
  95784. private _scaledVelocity;
  95785. private _finalPosition;
  95786. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  95787. createCollider(): Collider;
  95788. init(scene: Scene): void;
  95789. private _collideWithWorld;
  95790. }
  95791. }
  95792. declare module BABYLON {
  95793. /**
  95794. * Class used to manage all inputs for the scene.
  95795. */
  95796. export class InputManager {
  95797. /** The distance in pixel that you have to move to prevent some events */
  95798. static DragMovementThreshold: number;
  95799. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  95800. static LongPressDelay: number;
  95801. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  95802. static DoubleClickDelay: number;
  95803. /** If you need to check double click without raising a single click at first click, enable this flag */
  95804. static ExclusiveDoubleClickMode: boolean;
  95805. private _wheelEventName;
  95806. private _onPointerMove;
  95807. private _onPointerDown;
  95808. private _onPointerUp;
  95809. private _initClickEvent;
  95810. private _initActionManager;
  95811. private _delayedSimpleClick;
  95812. private _delayedSimpleClickTimeout;
  95813. private _previousDelayedSimpleClickTimeout;
  95814. private _meshPickProceed;
  95815. private _previousButtonPressed;
  95816. private _currentPickResult;
  95817. private _previousPickResult;
  95818. private _totalPointersPressed;
  95819. private _doubleClickOccured;
  95820. private _pointerOverMesh;
  95821. private _pickedDownMesh;
  95822. private _pickedUpMesh;
  95823. private _pointerX;
  95824. private _pointerY;
  95825. private _unTranslatedPointerX;
  95826. private _unTranslatedPointerY;
  95827. private _startingPointerPosition;
  95828. private _previousStartingPointerPosition;
  95829. private _startingPointerTime;
  95830. private _previousStartingPointerTime;
  95831. private _pointerCaptures;
  95832. private _onKeyDown;
  95833. private _onKeyUp;
  95834. private _onCanvasFocusObserver;
  95835. private _onCanvasBlurObserver;
  95836. private _scene;
  95837. /**
  95838. * Creates a new InputManager
  95839. * @param scene defines the hosting scene
  95840. */
  95841. constructor(scene: Scene);
  95842. /**
  95843. * Gets the mesh that is currently under the pointer
  95844. */
  95845. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95846. /**
  95847. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  95848. */
  95849. readonly unTranslatedPointer: Vector2;
  95850. /**
  95851. * Gets or sets the current on-screen X position of the pointer
  95852. */
  95853. pointerX: number;
  95854. /**
  95855. * Gets or sets the current on-screen Y position of the pointer
  95856. */
  95857. pointerY: number;
  95858. private _updatePointerPosition;
  95859. private _processPointerMove;
  95860. private _setRayOnPointerInfo;
  95861. private _checkPrePointerObservable;
  95862. /**
  95863. * Use this method to simulate a pointer move on a mesh
  95864. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95865. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95866. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95867. */
  95868. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  95869. /**
  95870. * Use this method to simulate a pointer down on a mesh
  95871. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95872. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95873. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95874. */
  95875. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  95876. private _processPointerDown;
  95877. /** @hidden */
  95878. _isPointerSwiping(): boolean;
  95879. /**
  95880. * Use this method to simulate a pointer up on a mesh
  95881. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95882. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95883. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95884. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95885. */
  95886. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  95887. private _processPointerUp;
  95888. /**
  95889. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95890. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95891. * @returns true if the pointer was captured
  95892. */
  95893. isPointerCaptured(pointerId?: number): boolean;
  95894. /**
  95895. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95896. * @param attachUp defines if you want to attach events to pointerup
  95897. * @param attachDown defines if you want to attach events to pointerdown
  95898. * @param attachMove defines if you want to attach events to pointermove
  95899. */
  95900. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95901. /**
  95902. * Detaches all event handlers
  95903. */
  95904. detachControl(): void;
  95905. /**
  95906. * Force the value of meshUnderPointer
  95907. * @param mesh defines the mesh to use
  95908. */
  95909. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  95910. /**
  95911. * Gets the mesh under the pointer
  95912. * @returns a Mesh or null if no mesh is under the pointer
  95913. */
  95914. getPointerOverMesh(): Nullable<AbstractMesh>;
  95915. }
  95916. }
  95917. declare module BABYLON {
  95918. /**
  95919. * Helper class used to generate session unique ID
  95920. */
  95921. export class UniqueIdGenerator {
  95922. private static _UniqueIdCounter;
  95923. /**
  95924. * Gets an unique (relatively to the current scene) Id
  95925. */
  95926. static readonly UniqueId: number;
  95927. }
  95928. }
  95929. declare module BABYLON {
  95930. /**
  95931. * This class defines the direct association between an animation and a target
  95932. */
  95933. export class TargetedAnimation {
  95934. /**
  95935. * Animation to perform
  95936. */
  95937. animation: Animation;
  95938. /**
  95939. * Target to animate
  95940. */
  95941. target: any;
  95942. /**
  95943. * Serialize the object
  95944. * @returns the JSON object representing the current entity
  95945. */
  95946. serialize(): any;
  95947. }
  95948. /**
  95949. * Use this class to create coordinated animations on multiple targets
  95950. */
  95951. export class AnimationGroup implements IDisposable {
  95952. /** The name of the animation group */
  95953. name: string;
  95954. private _scene;
  95955. private _targetedAnimations;
  95956. private _animatables;
  95957. private _from;
  95958. private _to;
  95959. private _isStarted;
  95960. private _isPaused;
  95961. private _speedRatio;
  95962. private _loopAnimation;
  95963. /**
  95964. * Gets or sets the unique id of the node
  95965. */
  95966. uniqueId: number;
  95967. /**
  95968. * This observable will notify when one animation have ended
  95969. */
  95970. onAnimationEndObservable: Observable<TargetedAnimation>;
  95971. /**
  95972. * Observer raised when one animation loops
  95973. */
  95974. onAnimationLoopObservable: Observable<TargetedAnimation>;
  95975. /**
  95976. * This observable will notify when all animations have ended.
  95977. */
  95978. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  95979. /**
  95980. * This observable will notify when all animations have paused.
  95981. */
  95982. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  95983. /**
  95984. * This observable will notify when all animations are playing.
  95985. */
  95986. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  95987. /**
  95988. * Gets the first frame
  95989. */
  95990. readonly from: number;
  95991. /**
  95992. * Gets the last frame
  95993. */
  95994. readonly to: number;
  95995. /**
  95996. * Define if the animations are started
  95997. */
  95998. readonly isStarted: boolean;
  95999. /**
  96000. * Gets a value indicating that the current group is playing
  96001. */
  96002. readonly isPlaying: boolean;
  96003. /**
  96004. * Gets or sets the speed ratio to use for all animations
  96005. */
  96006. /**
  96007. * Gets or sets the speed ratio to use for all animations
  96008. */
  96009. speedRatio: number;
  96010. /**
  96011. * Gets or sets if all animations should loop or not
  96012. */
  96013. loopAnimation: boolean;
  96014. /**
  96015. * Gets the targeted animations for this animation group
  96016. */
  96017. readonly targetedAnimations: Array<TargetedAnimation>;
  96018. /**
  96019. * returning the list of animatables controlled by this animation group.
  96020. */
  96021. readonly animatables: Array<Animatable>;
  96022. /**
  96023. * Instantiates a new Animation Group.
  96024. * This helps managing several animations at once.
  96025. * @see http://doc.babylonjs.com/how_to/group
  96026. * @param name Defines the name of the group
  96027. * @param scene Defines the scene the group belongs to
  96028. */
  96029. constructor(
  96030. /** The name of the animation group */
  96031. name: string, scene?: Nullable<Scene>);
  96032. /**
  96033. * Add an animation (with its target) in the group
  96034. * @param animation defines the animation we want to add
  96035. * @param target defines the target of the animation
  96036. * @returns the TargetedAnimation object
  96037. */
  96038. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  96039. /**
  96040. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  96041. * It can add constant keys at begin or end
  96042. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  96043. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  96044. * @returns the animation group
  96045. */
  96046. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  96047. /**
  96048. * Start all animations on given targets
  96049. * @param loop defines if animations must loop
  96050. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  96051. * @param from defines the from key (optional)
  96052. * @param to defines the to key (optional)
  96053. * @returns the current animation group
  96054. */
  96055. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  96056. /**
  96057. * Pause all animations
  96058. * @returns the animation group
  96059. */
  96060. pause(): AnimationGroup;
  96061. /**
  96062. * Play all animations to initial state
  96063. * This function will start() the animations if they were not started or will restart() them if they were paused
  96064. * @param loop defines if animations must loop
  96065. * @returns the animation group
  96066. */
  96067. play(loop?: boolean): AnimationGroup;
  96068. /**
  96069. * Reset all animations to initial state
  96070. * @returns the animation group
  96071. */
  96072. reset(): AnimationGroup;
  96073. /**
  96074. * Restart animations from key 0
  96075. * @returns the animation group
  96076. */
  96077. restart(): AnimationGroup;
  96078. /**
  96079. * Stop all animations
  96080. * @returns the animation group
  96081. */
  96082. stop(): AnimationGroup;
  96083. /**
  96084. * Set animation weight for all animatables
  96085. * @param weight defines the weight to use
  96086. * @return the animationGroup
  96087. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96088. */
  96089. setWeightForAllAnimatables(weight: number): AnimationGroup;
  96090. /**
  96091. * Synchronize and normalize all animatables with a source animatable
  96092. * @param root defines the root animatable to synchronize with
  96093. * @return the animationGroup
  96094. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96095. */
  96096. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  96097. /**
  96098. * Goes to a specific frame in this animation group
  96099. * @param frame the frame number to go to
  96100. * @return the animationGroup
  96101. */
  96102. goToFrame(frame: number): AnimationGroup;
  96103. /**
  96104. * Dispose all associated resources
  96105. */
  96106. dispose(): void;
  96107. private _checkAnimationGroupEnded;
  96108. /**
  96109. * Clone the current animation group and returns a copy
  96110. * @param newName defines the name of the new group
  96111. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  96112. * @returns the new aniamtion group
  96113. */
  96114. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  96115. /**
  96116. * Serializes the animationGroup to an object
  96117. * @returns Serialized object
  96118. */
  96119. serialize(): any;
  96120. /**
  96121. * Returns a new AnimationGroup object parsed from the source provided.
  96122. * @param parsedAnimationGroup defines the source
  96123. * @param scene defines the scene that will receive the animationGroup
  96124. * @returns a new AnimationGroup
  96125. */
  96126. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  96127. /**
  96128. * Returns the string "AnimationGroup"
  96129. * @returns "AnimationGroup"
  96130. */
  96131. getClassName(): string;
  96132. /**
  96133. * Creates a detailled string about the object
  96134. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  96135. * @returns a string representing the object
  96136. */
  96137. toString(fullDetails?: boolean): string;
  96138. }
  96139. }
  96140. declare module BABYLON {
  96141. /**
  96142. * Define an interface for all classes that will hold resources
  96143. */
  96144. export interface IDisposable {
  96145. /**
  96146. * Releases all held resources
  96147. */
  96148. dispose(): void;
  96149. }
  96150. /** Interface defining initialization parameters for Scene class */
  96151. export interface SceneOptions {
  96152. /**
  96153. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  96154. * It will improve performance when the number of geometries becomes important.
  96155. */
  96156. useGeometryUniqueIdsMap?: boolean;
  96157. /**
  96158. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  96159. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96160. */
  96161. useMaterialMeshMap?: boolean;
  96162. /**
  96163. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  96164. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96165. */
  96166. useClonedMeshhMap?: boolean;
  96167. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  96168. virtual?: boolean;
  96169. }
  96170. /**
  96171. * Represents a scene to be rendered by the engine.
  96172. * @see http://doc.babylonjs.com/features/scene
  96173. */
  96174. export class Scene extends AbstractScene implements IAnimatable {
  96175. /** The fog is deactivated */
  96176. static readonly FOGMODE_NONE: number;
  96177. /** The fog density is following an exponential function */
  96178. static readonly FOGMODE_EXP: number;
  96179. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  96180. static readonly FOGMODE_EXP2: number;
  96181. /** The fog density is following a linear function. */
  96182. static readonly FOGMODE_LINEAR: number;
  96183. /**
  96184. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  96185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96186. */
  96187. static MinDeltaTime: number;
  96188. /**
  96189. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  96190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96191. */
  96192. static MaxDeltaTime: number;
  96193. /**
  96194. * Factory used to create the default material.
  96195. * @param name The name of the material to create
  96196. * @param scene The scene to create the material for
  96197. * @returns The default material
  96198. */
  96199. static DefaultMaterialFactory(scene: Scene): Material;
  96200. /**
  96201. * Factory used to create the a collision coordinator.
  96202. * @returns The collision coordinator
  96203. */
  96204. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  96205. /** @hidden */
  96206. _inputManager: InputManager;
  96207. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  96208. cameraToUseForPointers: Nullable<Camera>;
  96209. /** @hidden */
  96210. readonly _isScene: boolean;
  96211. /**
  96212. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  96213. */
  96214. autoClear: boolean;
  96215. /**
  96216. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  96217. */
  96218. autoClearDepthAndStencil: boolean;
  96219. /**
  96220. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  96221. */
  96222. clearColor: Color4;
  96223. /**
  96224. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  96225. */
  96226. ambientColor: Color3;
  96227. /**
  96228. * This is use to store the default BRDF lookup for PBR materials in your scene.
  96229. * It should only be one of the following (if not the default embedded one):
  96230. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  96231. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  96232. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  96233. * The material properties need to be setup according to the type of texture in use.
  96234. */
  96235. environmentBRDFTexture: BaseTexture;
  96236. /** @hidden */
  96237. protected _environmentTexture: Nullable<BaseTexture>;
  96238. /**
  96239. * Texture used in all pbr material as the reflection texture.
  96240. * As in the majority of the scene they are the same (exception for multi room and so on),
  96241. * this is easier to reference from here than from all the materials.
  96242. */
  96243. /**
  96244. * Texture used in all pbr material as the reflection texture.
  96245. * As in the majority of the scene they are the same (exception for multi room and so on),
  96246. * this is easier to set here than in all the materials.
  96247. */
  96248. environmentTexture: Nullable<BaseTexture>;
  96249. /** @hidden */
  96250. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96251. /**
  96252. * Default image processing configuration used either in the rendering
  96253. * Forward main pass or through the imageProcessingPostProcess if present.
  96254. * As in the majority of the scene they are the same (exception for multi camera),
  96255. * this is easier to reference from here than from all the materials and post process.
  96256. *
  96257. * No setter as we it is a shared configuration, you can set the values instead.
  96258. */
  96259. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  96260. private _forceWireframe;
  96261. /**
  96262. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  96263. */
  96264. forceWireframe: boolean;
  96265. private _forcePointsCloud;
  96266. /**
  96267. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  96268. */
  96269. forcePointsCloud: boolean;
  96270. /**
  96271. * Gets or sets the active clipplane 1
  96272. */
  96273. clipPlane: Nullable<Plane>;
  96274. /**
  96275. * Gets or sets the active clipplane 2
  96276. */
  96277. clipPlane2: Nullable<Plane>;
  96278. /**
  96279. * Gets or sets the active clipplane 3
  96280. */
  96281. clipPlane3: Nullable<Plane>;
  96282. /**
  96283. * Gets or sets the active clipplane 4
  96284. */
  96285. clipPlane4: Nullable<Plane>;
  96286. /**
  96287. * Gets or sets a boolean indicating if animations are enabled
  96288. */
  96289. animationsEnabled: boolean;
  96290. private _animationPropertiesOverride;
  96291. /**
  96292. * Gets or sets the animation properties override
  96293. */
  96294. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  96295. /**
  96296. * Gets or sets a boolean indicating if a constant deltatime has to be used
  96297. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  96298. */
  96299. useConstantAnimationDeltaTime: boolean;
  96300. /**
  96301. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  96302. * Please note that it requires to run a ray cast through the scene on every frame
  96303. */
  96304. constantlyUpdateMeshUnderPointer: boolean;
  96305. /**
  96306. * Defines the HTML cursor to use when hovering over interactive elements
  96307. */
  96308. hoverCursor: string;
  96309. /**
  96310. * Defines the HTML default cursor to use (empty by default)
  96311. */
  96312. defaultCursor: string;
  96313. /**
  96314. * This is used to call preventDefault() on pointer down
  96315. * in order to block unwanted artifacts like system double clicks
  96316. */
  96317. preventDefaultOnPointerDown: boolean;
  96318. /**
  96319. * This is used to call preventDefault() on pointer up
  96320. * in order to block unwanted artifacts like system double clicks
  96321. */
  96322. preventDefaultOnPointerUp: boolean;
  96323. /**
  96324. * Gets or sets user defined metadata
  96325. */
  96326. metadata: any;
  96327. /**
  96328. * For internal use only. Please do not use.
  96329. */
  96330. reservedDataStore: any;
  96331. /**
  96332. * Gets the name of the plugin used to load this scene (null by default)
  96333. */
  96334. loadingPluginName: string;
  96335. /**
  96336. * Use this array to add regular expressions used to disable offline support for specific urls
  96337. */
  96338. disableOfflineSupportExceptionRules: RegExp[];
  96339. /**
  96340. * An event triggered when the scene is disposed.
  96341. */
  96342. onDisposeObservable: Observable<Scene>;
  96343. private _onDisposeObserver;
  96344. /** Sets a function to be executed when this scene is disposed. */
  96345. onDispose: () => void;
  96346. /**
  96347. * An event triggered before rendering the scene (right after animations and physics)
  96348. */
  96349. onBeforeRenderObservable: Observable<Scene>;
  96350. private _onBeforeRenderObserver;
  96351. /** Sets a function to be executed before rendering this scene */
  96352. beforeRender: Nullable<() => void>;
  96353. /**
  96354. * An event triggered after rendering the scene
  96355. */
  96356. onAfterRenderObservable: Observable<Scene>;
  96357. /**
  96358. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  96359. */
  96360. onAfterRenderCameraObservable: Observable<Camera>;
  96361. private _onAfterRenderObserver;
  96362. /** Sets a function to be executed after rendering this scene */
  96363. afterRender: Nullable<() => void>;
  96364. /**
  96365. * An event triggered before animating the scene
  96366. */
  96367. onBeforeAnimationsObservable: Observable<Scene>;
  96368. /**
  96369. * An event triggered after animations processing
  96370. */
  96371. onAfterAnimationsObservable: Observable<Scene>;
  96372. /**
  96373. * An event triggered before draw calls are ready to be sent
  96374. */
  96375. onBeforeDrawPhaseObservable: Observable<Scene>;
  96376. /**
  96377. * An event triggered after draw calls have been sent
  96378. */
  96379. onAfterDrawPhaseObservable: Observable<Scene>;
  96380. /**
  96381. * An event triggered when the scene is ready
  96382. */
  96383. onReadyObservable: Observable<Scene>;
  96384. /**
  96385. * An event triggered before rendering a camera
  96386. */
  96387. onBeforeCameraRenderObservable: Observable<Camera>;
  96388. private _onBeforeCameraRenderObserver;
  96389. /** Sets a function to be executed before rendering a camera*/
  96390. beforeCameraRender: () => void;
  96391. /**
  96392. * An event triggered after rendering a camera
  96393. */
  96394. onAfterCameraRenderObservable: Observable<Camera>;
  96395. private _onAfterCameraRenderObserver;
  96396. /** Sets a function to be executed after rendering a camera*/
  96397. afterCameraRender: () => void;
  96398. /**
  96399. * An event triggered when active meshes evaluation is about to start
  96400. */
  96401. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  96402. /**
  96403. * An event triggered when active meshes evaluation is done
  96404. */
  96405. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  96406. /**
  96407. * An event triggered when particles rendering is about to start
  96408. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96409. */
  96410. onBeforeParticlesRenderingObservable: Observable<Scene>;
  96411. /**
  96412. * An event triggered when particles rendering is done
  96413. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96414. */
  96415. onAfterParticlesRenderingObservable: Observable<Scene>;
  96416. /**
  96417. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  96418. */
  96419. onDataLoadedObservable: Observable<Scene>;
  96420. /**
  96421. * An event triggered when a camera is created
  96422. */
  96423. onNewCameraAddedObservable: Observable<Camera>;
  96424. /**
  96425. * An event triggered when a camera is removed
  96426. */
  96427. onCameraRemovedObservable: Observable<Camera>;
  96428. /**
  96429. * An event triggered when a light is created
  96430. */
  96431. onNewLightAddedObservable: Observable<Light>;
  96432. /**
  96433. * An event triggered when a light is removed
  96434. */
  96435. onLightRemovedObservable: Observable<Light>;
  96436. /**
  96437. * An event triggered when a geometry is created
  96438. */
  96439. onNewGeometryAddedObservable: Observable<Geometry>;
  96440. /**
  96441. * An event triggered when a geometry is removed
  96442. */
  96443. onGeometryRemovedObservable: Observable<Geometry>;
  96444. /**
  96445. * An event triggered when a transform node is created
  96446. */
  96447. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  96448. /**
  96449. * An event triggered when a transform node is removed
  96450. */
  96451. onTransformNodeRemovedObservable: Observable<TransformNode>;
  96452. /**
  96453. * An event triggered when a mesh is created
  96454. */
  96455. onNewMeshAddedObservable: Observable<AbstractMesh>;
  96456. /**
  96457. * An event triggered when a mesh is removed
  96458. */
  96459. onMeshRemovedObservable: Observable<AbstractMesh>;
  96460. /**
  96461. * An event triggered when a skeleton is created
  96462. */
  96463. onNewSkeletonAddedObservable: Observable<Skeleton>;
  96464. /**
  96465. * An event triggered when a skeleton is removed
  96466. */
  96467. onSkeletonRemovedObservable: Observable<Skeleton>;
  96468. /**
  96469. * An event triggered when a material is created
  96470. */
  96471. onNewMaterialAddedObservable: Observable<Material>;
  96472. /**
  96473. * An event triggered when a material is removed
  96474. */
  96475. onMaterialRemovedObservable: Observable<Material>;
  96476. /**
  96477. * An event triggered when a texture is created
  96478. */
  96479. onNewTextureAddedObservable: Observable<BaseTexture>;
  96480. /**
  96481. * An event triggered when a texture is removed
  96482. */
  96483. onTextureRemovedObservable: Observable<BaseTexture>;
  96484. /**
  96485. * An event triggered when render targets are about to be rendered
  96486. * Can happen multiple times per frame.
  96487. */
  96488. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  96489. /**
  96490. * An event triggered when render targets were rendered.
  96491. * Can happen multiple times per frame.
  96492. */
  96493. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  96494. /**
  96495. * An event triggered before calculating deterministic simulation step
  96496. */
  96497. onBeforeStepObservable: Observable<Scene>;
  96498. /**
  96499. * An event triggered after calculating deterministic simulation step
  96500. */
  96501. onAfterStepObservable: Observable<Scene>;
  96502. /**
  96503. * An event triggered when the activeCamera property is updated
  96504. */
  96505. onActiveCameraChanged: Observable<Scene>;
  96506. /**
  96507. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  96508. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96509. * 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)
  96510. */
  96511. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96512. /**
  96513. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  96514. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96515. * 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)
  96516. */
  96517. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96518. /**
  96519. * This Observable will when a mesh has been imported into the scene.
  96520. */
  96521. onMeshImportedObservable: Observable<AbstractMesh>;
  96522. /**
  96523. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  96524. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  96525. */
  96526. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  96527. /** @hidden */
  96528. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  96529. /**
  96530. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  96531. */
  96532. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  96533. /**
  96534. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  96535. */
  96536. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  96537. /**
  96538. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  96539. */
  96540. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  96541. /** Callback called when a pointer move is detected */
  96542. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96543. /** Callback called when a pointer down is detected */
  96544. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96545. /** Callback called when a pointer up is detected */
  96546. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  96547. /** Callback called when a pointer pick is detected */
  96548. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  96549. /**
  96550. * 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).
  96551. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  96552. */
  96553. onPrePointerObservable: Observable<PointerInfoPre>;
  96554. /**
  96555. * Observable event triggered each time an input event is received from the rendering canvas
  96556. */
  96557. onPointerObservable: Observable<PointerInfo>;
  96558. /**
  96559. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  96560. */
  96561. readonly unTranslatedPointer: Vector2;
  96562. /**
  96563. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  96564. */
  96565. static DragMovementThreshold: number;
  96566. /**
  96567. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  96568. */
  96569. static LongPressDelay: number;
  96570. /**
  96571. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  96572. */
  96573. static DoubleClickDelay: number;
  96574. /** If you need to check double click without raising a single click at first click, enable this flag */
  96575. static ExclusiveDoubleClickMode: boolean;
  96576. /** @hidden */
  96577. _mirroredCameraPosition: Nullable<Vector3>;
  96578. /**
  96579. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  96580. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  96581. */
  96582. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  96583. /**
  96584. * Observable event triggered each time an keyboard event is received from the hosting window
  96585. */
  96586. onKeyboardObservable: Observable<KeyboardInfo>;
  96587. private _useRightHandedSystem;
  96588. /**
  96589. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  96590. */
  96591. useRightHandedSystem: boolean;
  96592. private _timeAccumulator;
  96593. private _currentStepId;
  96594. private _currentInternalStep;
  96595. /**
  96596. * Sets the step Id used by deterministic lock step
  96597. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96598. * @param newStepId defines the step Id
  96599. */
  96600. setStepId(newStepId: number): void;
  96601. /**
  96602. * Gets the step Id used by deterministic lock step
  96603. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96604. * @returns the step Id
  96605. */
  96606. getStepId(): number;
  96607. /**
  96608. * Gets the internal step used by deterministic lock step
  96609. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96610. * @returns the internal step
  96611. */
  96612. getInternalStep(): number;
  96613. private _fogEnabled;
  96614. /**
  96615. * Gets or sets a boolean indicating if fog is enabled on this scene
  96616. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96617. * (Default is true)
  96618. */
  96619. fogEnabled: boolean;
  96620. private _fogMode;
  96621. /**
  96622. * Gets or sets the fog mode to use
  96623. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96624. * | mode | value |
  96625. * | --- | --- |
  96626. * | FOGMODE_NONE | 0 |
  96627. * | FOGMODE_EXP | 1 |
  96628. * | FOGMODE_EXP2 | 2 |
  96629. * | FOGMODE_LINEAR | 3 |
  96630. */
  96631. fogMode: number;
  96632. /**
  96633. * Gets or sets the fog color to use
  96634. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96635. * (Default is Color3(0.2, 0.2, 0.3))
  96636. */
  96637. fogColor: Color3;
  96638. /**
  96639. * Gets or sets the fog density to use
  96640. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96641. * (Default is 0.1)
  96642. */
  96643. fogDensity: number;
  96644. /**
  96645. * Gets or sets the fog start distance to use
  96646. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96647. * (Default is 0)
  96648. */
  96649. fogStart: number;
  96650. /**
  96651. * Gets or sets the fog end distance to use
  96652. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96653. * (Default is 1000)
  96654. */
  96655. fogEnd: number;
  96656. private _shadowsEnabled;
  96657. /**
  96658. * Gets or sets a boolean indicating if shadows are enabled on this scene
  96659. */
  96660. shadowsEnabled: boolean;
  96661. private _lightsEnabled;
  96662. /**
  96663. * Gets or sets a boolean indicating if lights are enabled on this scene
  96664. */
  96665. lightsEnabled: boolean;
  96666. /** All of the active cameras added to this scene. */
  96667. activeCameras: Camera[];
  96668. /** @hidden */
  96669. _activeCamera: Nullable<Camera>;
  96670. /** Gets or sets the current active camera */
  96671. activeCamera: Nullable<Camera>;
  96672. private _defaultMaterial;
  96673. /** The default material used on meshes when no material is affected */
  96674. /** The default material used on meshes when no material is affected */
  96675. defaultMaterial: Material;
  96676. private _texturesEnabled;
  96677. /**
  96678. * Gets or sets a boolean indicating if textures are enabled on this scene
  96679. */
  96680. texturesEnabled: boolean;
  96681. /**
  96682. * Gets or sets a boolean indicating if particles are enabled on this scene
  96683. */
  96684. particlesEnabled: boolean;
  96685. /**
  96686. * Gets or sets a boolean indicating if sprites are enabled on this scene
  96687. */
  96688. spritesEnabled: boolean;
  96689. private _skeletonsEnabled;
  96690. /**
  96691. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  96692. */
  96693. skeletonsEnabled: boolean;
  96694. /**
  96695. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  96696. */
  96697. lensFlaresEnabled: boolean;
  96698. /**
  96699. * Gets or sets a boolean indicating if collisions are enabled on this scene
  96700. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96701. */
  96702. collisionsEnabled: boolean;
  96703. private _collisionCoordinator;
  96704. /** @hidden */
  96705. readonly collisionCoordinator: ICollisionCoordinator;
  96706. /**
  96707. * Defines the gravity applied to this scene (used only for collisions)
  96708. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96709. */
  96710. gravity: Vector3;
  96711. /**
  96712. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  96713. */
  96714. postProcessesEnabled: boolean;
  96715. /**
  96716. * The list of postprocesses added to the scene
  96717. */
  96718. postProcesses: PostProcess[];
  96719. /**
  96720. * Gets the current postprocess manager
  96721. */
  96722. postProcessManager: PostProcessManager;
  96723. /**
  96724. * Gets or sets a boolean indicating if render targets are enabled on this scene
  96725. */
  96726. renderTargetsEnabled: boolean;
  96727. /**
  96728. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  96729. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  96730. */
  96731. dumpNextRenderTargets: boolean;
  96732. /**
  96733. * The list of user defined render targets added to the scene
  96734. */
  96735. customRenderTargets: RenderTargetTexture[];
  96736. /**
  96737. * Defines if texture loading must be delayed
  96738. * If true, textures will only be loaded when they need to be rendered
  96739. */
  96740. useDelayedTextureLoading: boolean;
  96741. /**
  96742. * Gets the list of meshes imported to the scene through SceneLoader
  96743. */
  96744. importedMeshesFiles: String[];
  96745. /**
  96746. * Gets or sets a boolean indicating if probes are enabled on this scene
  96747. */
  96748. probesEnabled: boolean;
  96749. /**
  96750. * Gets or sets the current offline provider to use to store scene data
  96751. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  96752. */
  96753. offlineProvider: IOfflineProvider;
  96754. /**
  96755. * Gets or sets the action manager associated with the scene
  96756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96757. */
  96758. actionManager: AbstractActionManager;
  96759. private _meshesForIntersections;
  96760. /**
  96761. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  96762. */
  96763. proceduralTexturesEnabled: boolean;
  96764. private _engine;
  96765. private _totalVertices;
  96766. /** @hidden */
  96767. _activeIndices: PerfCounter;
  96768. /** @hidden */
  96769. _activeParticles: PerfCounter;
  96770. /** @hidden */
  96771. _activeBones: PerfCounter;
  96772. private _animationRatio;
  96773. /** @hidden */
  96774. _animationTimeLast: number;
  96775. /** @hidden */
  96776. _animationTime: number;
  96777. /**
  96778. * Gets or sets a general scale for animation speed
  96779. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  96780. */
  96781. animationTimeScale: number;
  96782. /** @hidden */
  96783. _cachedMaterial: Nullable<Material>;
  96784. /** @hidden */
  96785. _cachedEffect: Nullable<Effect>;
  96786. /** @hidden */
  96787. _cachedVisibility: Nullable<number>;
  96788. private _renderId;
  96789. private _frameId;
  96790. private _executeWhenReadyTimeoutId;
  96791. private _intermediateRendering;
  96792. private _viewUpdateFlag;
  96793. private _projectionUpdateFlag;
  96794. /** @hidden */
  96795. _toBeDisposed: Nullable<IDisposable>[];
  96796. private _activeRequests;
  96797. /** @hidden */
  96798. _pendingData: any[];
  96799. private _isDisposed;
  96800. /**
  96801. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  96802. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  96803. */
  96804. dispatchAllSubMeshesOfActiveMeshes: boolean;
  96805. private _activeMeshes;
  96806. private _processedMaterials;
  96807. private _renderTargets;
  96808. /** @hidden */
  96809. _activeParticleSystems: SmartArray<IParticleSystem>;
  96810. private _activeSkeletons;
  96811. private _softwareSkinnedMeshes;
  96812. private _renderingManager;
  96813. /** @hidden */
  96814. _activeAnimatables: Animatable[];
  96815. private _transformMatrix;
  96816. private _sceneUbo;
  96817. /** @hidden */
  96818. _viewMatrix: Matrix;
  96819. private _projectionMatrix;
  96820. /** @hidden */
  96821. _forcedViewPosition: Nullable<Vector3>;
  96822. /** @hidden */
  96823. _frustumPlanes: Plane[];
  96824. /**
  96825. * Gets the list of frustum planes (built from the active camera)
  96826. */
  96827. readonly frustumPlanes: Plane[];
  96828. /**
  96829. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  96830. * This is useful if there are more lights that the maximum simulteanous authorized
  96831. */
  96832. requireLightSorting: boolean;
  96833. /** @hidden */
  96834. readonly useMaterialMeshMap: boolean;
  96835. /** @hidden */
  96836. readonly useClonedMeshhMap: boolean;
  96837. private _externalData;
  96838. private _uid;
  96839. /**
  96840. * @hidden
  96841. * Backing store of defined scene components.
  96842. */
  96843. _components: ISceneComponent[];
  96844. /**
  96845. * @hidden
  96846. * Backing store of defined scene components.
  96847. */
  96848. _serializableComponents: ISceneSerializableComponent[];
  96849. /**
  96850. * List of components to register on the next registration step.
  96851. */
  96852. private _transientComponents;
  96853. /**
  96854. * Registers the transient components if needed.
  96855. */
  96856. private _registerTransientComponents;
  96857. /**
  96858. * @hidden
  96859. * Add a component to the scene.
  96860. * Note that the ccomponent could be registered on th next frame if this is called after
  96861. * the register component stage.
  96862. * @param component Defines the component to add to the scene
  96863. */
  96864. _addComponent(component: ISceneComponent): void;
  96865. /**
  96866. * @hidden
  96867. * Gets a component from the scene.
  96868. * @param name defines the name of the component to retrieve
  96869. * @returns the component or null if not present
  96870. */
  96871. _getComponent(name: string): Nullable<ISceneComponent>;
  96872. /**
  96873. * @hidden
  96874. * Defines the actions happening before camera updates.
  96875. */
  96876. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  96877. /**
  96878. * @hidden
  96879. * Defines the actions happening before clear the canvas.
  96880. */
  96881. _beforeClearStage: Stage<SimpleStageAction>;
  96882. /**
  96883. * @hidden
  96884. * Defines the actions when collecting render targets for the frame.
  96885. */
  96886. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  96887. /**
  96888. * @hidden
  96889. * Defines the actions happening for one camera in the frame.
  96890. */
  96891. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  96892. /**
  96893. * @hidden
  96894. * Defines the actions happening during the per mesh ready checks.
  96895. */
  96896. _isReadyForMeshStage: Stage<MeshStageAction>;
  96897. /**
  96898. * @hidden
  96899. * Defines the actions happening before evaluate active mesh checks.
  96900. */
  96901. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  96902. /**
  96903. * @hidden
  96904. * Defines the actions happening during the evaluate sub mesh checks.
  96905. */
  96906. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  96907. /**
  96908. * @hidden
  96909. * Defines the actions happening during the active mesh stage.
  96910. */
  96911. _activeMeshStage: Stage<ActiveMeshStageAction>;
  96912. /**
  96913. * @hidden
  96914. * Defines the actions happening during the per camera render target step.
  96915. */
  96916. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  96917. /**
  96918. * @hidden
  96919. * Defines the actions happening just before the active camera is drawing.
  96920. */
  96921. _beforeCameraDrawStage: Stage<CameraStageAction>;
  96922. /**
  96923. * @hidden
  96924. * Defines the actions happening just before a render target is drawing.
  96925. */
  96926. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  96927. /**
  96928. * @hidden
  96929. * Defines the actions happening just before a rendering group is drawing.
  96930. */
  96931. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  96932. /**
  96933. * @hidden
  96934. * Defines the actions happening just before a mesh is drawing.
  96935. */
  96936. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  96937. /**
  96938. * @hidden
  96939. * Defines the actions happening just after a mesh has been drawn.
  96940. */
  96941. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  96942. /**
  96943. * @hidden
  96944. * Defines the actions happening just after a rendering group has been drawn.
  96945. */
  96946. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  96947. /**
  96948. * @hidden
  96949. * Defines the actions happening just after the active camera has been drawn.
  96950. */
  96951. _afterCameraDrawStage: Stage<CameraStageAction>;
  96952. /**
  96953. * @hidden
  96954. * Defines the actions happening just after a render target has been drawn.
  96955. */
  96956. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  96957. /**
  96958. * @hidden
  96959. * Defines the actions happening just after rendering all cameras and computing intersections.
  96960. */
  96961. _afterRenderStage: Stage<SimpleStageAction>;
  96962. /**
  96963. * @hidden
  96964. * Defines the actions happening when a pointer move event happens.
  96965. */
  96966. _pointerMoveStage: Stage<PointerMoveStageAction>;
  96967. /**
  96968. * @hidden
  96969. * Defines the actions happening when a pointer down event happens.
  96970. */
  96971. _pointerDownStage: Stage<PointerUpDownStageAction>;
  96972. /**
  96973. * @hidden
  96974. * Defines the actions happening when a pointer up event happens.
  96975. */
  96976. _pointerUpStage: Stage<PointerUpDownStageAction>;
  96977. /**
  96978. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  96979. */
  96980. private geometriesByUniqueId;
  96981. /**
  96982. * Creates a new Scene
  96983. * @param engine defines the engine to use to render this scene
  96984. * @param options defines the scene options
  96985. */
  96986. constructor(engine: Engine, options?: SceneOptions);
  96987. /**
  96988. * Gets a string idenfifying the name of the class
  96989. * @returns "Scene" string
  96990. */
  96991. getClassName(): string;
  96992. private _defaultMeshCandidates;
  96993. /**
  96994. * @hidden
  96995. */
  96996. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96997. private _defaultSubMeshCandidates;
  96998. /**
  96999. * @hidden
  97000. */
  97001. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97002. /**
  97003. * Sets the default candidate providers for the scene.
  97004. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  97005. * and getCollidingSubMeshCandidates to their default function
  97006. */
  97007. setDefaultCandidateProviders(): void;
  97008. /**
  97009. * Gets the mesh that is currently under the pointer
  97010. */
  97011. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97012. /**
  97013. * Gets or sets the current on-screen X position of the pointer
  97014. */
  97015. pointerX: number;
  97016. /**
  97017. * Gets or sets the current on-screen Y position of the pointer
  97018. */
  97019. pointerY: number;
  97020. /**
  97021. * Gets the cached material (ie. the latest rendered one)
  97022. * @returns the cached material
  97023. */
  97024. getCachedMaterial(): Nullable<Material>;
  97025. /**
  97026. * Gets the cached effect (ie. the latest rendered one)
  97027. * @returns the cached effect
  97028. */
  97029. getCachedEffect(): Nullable<Effect>;
  97030. /**
  97031. * Gets the cached visibility state (ie. the latest rendered one)
  97032. * @returns the cached visibility state
  97033. */
  97034. getCachedVisibility(): Nullable<number>;
  97035. /**
  97036. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  97037. * @param material defines the current material
  97038. * @param effect defines the current effect
  97039. * @param visibility defines the current visibility state
  97040. * @returns true if one parameter is not cached
  97041. */
  97042. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  97043. /**
  97044. * Gets the engine associated with the scene
  97045. * @returns an Engine
  97046. */
  97047. getEngine(): Engine;
  97048. /**
  97049. * Gets the total number of vertices rendered per frame
  97050. * @returns the total number of vertices rendered per frame
  97051. */
  97052. getTotalVertices(): number;
  97053. /**
  97054. * Gets the performance counter for total vertices
  97055. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97056. */
  97057. readonly totalVerticesPerfCounter: PerfCounter;
  97058. /**
  97059. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  97060. * @returns the total number of active indices rendered per frame
  97061. */
  97062. getActiveIndices(): number;
  97063. /**
  97064. * Gets the performance counter for active indices
  97065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97066. */
  97067. readonly totalActiveIndicesPerfCounter: PerfCounter;
  97068. /**
  97069. * Gets the total number of active particles rendered per frame
  97070. * @returns the total number of active particles rendered per frame
  97071. */
  97072. getActiveParticles(): number;
  97073. /**
  97074. * Gets the performance counter for active particles
  97075. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97076. */
  97077. readonly activeParticlesPerfCounter: PerfCounter;
  97078. /**
  97079. * Gets the total number of active bones rendered per frame
  97080. * @returns the total number of active bones rendered per frame
  97081. */
  97082. getActiveBones(): number;
  97083. /**
  97084. * Gets the performance counter for active bones
  97085. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97086. */
  97087. readonly activeBonesPerfCounter: PerfCounter;
  97088. /**
  97089. * Gets the array of active meshes
  97090. * @returns an array of AbstractMesh
  97091. */
  97092. getActiveMeshes(): SmartArray<AbstractMesh>;
  97093. /**
  97094. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  97095. * @returns a number
  97096. */
  97097. getAnimationRatio(): number;
  97098. /**
  97099. * Gets an unique Id for the current render phase
  97100. * @returns a number
  97101. */
  97102. getRenderId(): number;
  97103. /**
  97104. * Gets an unique Id for the current frame
  97105. * @returns a number
  97106. */
  97107. getFrameId(): number;
  97108. /** Call this function if you want to manually increment the render Id*/
  97109. incrementRenderId(): void;
  97110. private _createUbo;
  97111. /**
  97112. * Use this method to simulate a pointer move on a mesh
  97113. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97114. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97115. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97116. * @returns the current scene
  97117. */
  97118. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97119. /**
  97120. * Use this method to simulate a pointer down on a mesh
  97121. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97122. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97123. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97124. * @returns the current scene
  97125. */
  97126. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97127. /**
  97128. * Use this method to simulate a pointer up on a mesh
  97129. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97130. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97131. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97132. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97133. * @returns the current scene
  97134. */
  97135. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  97136. /**
  97137. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97138. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97139. * @returns true if the pointer was captured
  97140. */
  97141. isPointerCaptured(pointerId?: number): boolean;
  97142. /**
  97143. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97144. * @param attachUp defines if you want to attach events to pointerup
  97145. * @param attachDown defines if you want to attach events to pointerdown
  97146. * @param attachMove defines if you want to attach events to pointermove
  97147. */
  97148. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97149. /** Detaches all event handlers*/
  97150. detachControl(): void;
  97151. /**
  97152. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  97153. * Delay loaded resources are not taking in account
  97154. * @return true if all required resources are ready
  97155. */
  97156. isReady(): boolean;
  97157. /** Resets all cached information relative to material (including effect and visibility) */
  97158. resetCachedMaterial(): void;
  97159. /**
  97160. * Registers a function to be called before every frame render
  97161. * @param func defines the function to register
  97162. */
  97163. registerBeforeRender(func: () => void): void;
  97164. /**
  97165. * Unregisters a function called before every frame render
  97166. * @param func defines the function to unregister
  97167. */
  97168. unregisterBeforeRender(func: () => void): void;
  97169. /**
  97170. * Registers a function to be called after every frame render
  97171. * @param func defines the function to register
  97172. */
  97173. registerAfterRender(func: () => void): void;
  97174. /**
  97175. * Unregisters a function called after every frame render
  97176. * @param func defines the function to unregister
  97177. */
  97178. unregisterAfterRender(func: () => void): void;
  97179. private _executeOnceBeforeRender;
  97180. /**
  97181. * The provided function will run before render once and will be disposed afterwards.
  97182. * A timeout delay can be provided so that the function will be executed in N ms.
  97183. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  97184. * @param func The function to be executed.
  97185. * @param timeout optional delay in ms
  97186. */
  97187. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  97188. /** @hidden */
  97189. _addPendingData(data: any): void;
  97190. /** @hidden */
  97191. _removePendingData(data: any): void;
  97192. /**
  97193. * Returns the number of items waiting to be loaded
  97194. * @returns the number of items waiting to be loaded
  97195. */
  97196. getWaitingItemsCount(): number;
  97197. /**
  97198. * Returns a boolean indicating if the scene is still loading data
  97199. */
  97200. readonly isLoading: boolean;
  97201. /**
  97202. * Registers a function to be executed when the scene is ready
  97203. * @param {Function} func - the function to be executed
  97204. */
  97205. executeWhenReady(func: () => void): void;
  97206. /**
  97207. * Returns a promise that resolves when the scene is ready
  97208. * @returns A promise that resolves when the scene is ready
  97209. */
  97210. whenReadyAsync(): Promise<void>;
  97211. /** @hidden */
  97212. _checkIsReady(): void;
  97213. /**
  97214. * Gets all animatable attached to the scene
  97215. */
  97216. readonly animatables: Animatable[];
  97217. /**
  97218. * Resets the last animation time frame.
  97219. * Useful to override when animations start running when loading a scene for the first time.
  97220. */
  97221. resetLastAnimationTimeFrame(): void;
  97222. /**
  97223. * Gets the current view matrix
  97224. * @returns a Matrix
  97225. */
  97226. getViewMatrix(): Matrix;
  97227. /**
  97228. * Gets the current projection matrix
  97229. * @returns a Matrix
  97230. */
  97231. getProjectionMatrix(): Matrix;
  97232. /**
  97233. * Gets the current transform matrix
  97234. * @returns a Matrix made of View * Projection
  97235. */
  97236. getTransformMatrix(): Matrix;
  97237. /**
  97238. * Sets the current transform matrix
  97239. * @param viewL defines the View matrix to use
  97240. * @param projectionL defines the Projection matrix to use
  97241. * @param viewR defines the right View matrix to use (if provided)
  97242. * @param projectionR defines the right Projection matrix to use (if provided)
  97243. */
  97244. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  97245. /**
  97246. * Gets the uniform buffer used to store scene data
  97247. * @returns a UniformBuffer
  97248. */
  97249. getSceneUniformBuffer(): UniformBuffer;
  97250. /**
  97251. * Gets an unique (relatively to the current scene) Id
  97252. * @returns an unique number for the scene
  97253. */
  97254. getUniqueId(): number;
  97255. /**
  97256. * Add a mesh to the list of scene's meshes
  97257. * @param newMesh defines the mesh to add
  97258. * @param recursive if all child meshes should also be added to the scene
  97259. */
  97260. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  97261. /**
  97262. * Remove a mesh for the list of scene's meshes
  97263. * @param toRemove defines the mesh to remove
  97264. * @param recursive if all child meshes should also be removed from the scene
  97265. * @returns the index where the mesh was in the mesh list
  97266. */
  97267. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  97268. /**
  97269. * Add a transform node to the list of scene's transform nodes
  97270. * @param newTransformNode defines the transform node to add
  97271. */
  97272. addTransformNode(newTransformNode: TransformNode): void;
  97273. /**
  97274. * Remove a transform node for the list of scene's transform nodes
  97275. * @param toRemove defines the transform node to remove
  97276. * @returns the index where the transform node was in the transform node list
  97277. */
  97278. removeTransformNode(toRemove: TransformNode): number;
  97279. /**
  97280. * Remove a skeleton for the list of scene's skeletons
  97281. * @param toRemove defines the skeleton to remove
  97282. * @returns the index where the skeleton was in the skeleton list
  97283. */
  97284. removeSkeleton(toRemove: Skeleton): number;
  97285. /**
  97286. * Remove a morph target for the list of scene's morph targets
  97287. * @param toRemove defines the morph target to remove
  97288. * @returns the index where the morph target was in the morph target list
  97289. */
  97290. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  97291. /**
  97292. * Remove a light for the list of scene's lights
  97293. * @param toRemove defines the light to remove
  97294. * @returns the index where the light was in the light list
  97295. */
  97296. removeLight(toRemove: Light): number;
  97297. /**
  97298. * Remove a camera for the list of scene's cameras
  97299. * @param toRemove defines the camera to remove
  97300. * @returns the index where the camera was in the camera list
  97301. */
  97302. removeCamera(toRemove: Camera): number;
  97303. /**
  97304. * Remove a particle system for the list of scene's particle systems
  97305. * @param toRemove defines the particle system to remove
  97306. * @returns the index where the particle system was in the particle system list
  97307. */
  97308. removeParticleSystem(toRemove: IParticleSystem): number;
  97309. /**
  97310. * Remove a animation for the list of scene's animations
  97311. * @param toRemove defines the animation to remove
  97312. * @returns the index where the animation was in the animation list
  97313. */
  97314. removeAnimation(toRemove: Animation): number;
  97315. /**
  97316. * Will stop the animation of the given target
  97317. * @param target - the target
  97318. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  97319. * @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)
  97320. */
  97321. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  97322. /**
  97323. * Removes the given animation group from this scene.
  97324. * @param toRemove The animation group to remove
  97325. * @returns The index of the removed animation group
  97326. */
  97327. removeAnimationGroup(toRemove: AnimationGroup): number;
  97328. /**
  97329. * Removes the given multi-material from this scene.
  97330. * @param toRemove The multi-material to remove
  97331. * @returns The index of the removed multi-material
  97332. */
  97333. removeMultiMaterial(toRemove: MultiMaterial): number;
  97334. /**
  97335. * Removes the given material from this scene.
  97336. * @param toRemove The material to remove
  97337. * @returns The index of the removed material
  97338. */
  97339. removeMaterial(toRemove: Material): number;
  97340. /**
  97341. * Removes the given action manager from this scene.
  97342. * @param toRemove The action manager to remove
  97343. * @returns The index of the removed action manager
  97344. */
  97345. removeActionManager(toRemove: AbstractActionManager): number;
  97346. /**
  97347. * Removes the given texture from this scene.
  97348. * @param toRemove The texture to remove
  97349. * @returns The index of the removed texture
  97350. */
  97351. removeTexture(toRemove: BaseTexture): number;
  97352. /**
  97353. * Adds the given light to this scene
  97354. * @param newLight The light to add
  97355. */
  97356. addLight(newLight: Light): void;
  97357. /**
  97358. * Sorts the list list based on light priorities
  97359. */
  97360. sortLightsByPriority(): void;
  97361. /**
  97362. * Adds the given camera to this scene
  97363. * @param newCamera The camera to add
  97364. */
  97365. addCamera(newCamera: Camera): void;
  97366. /**
  97367. * Adds the given skeleton to this scene
  97368. * @param newSkeleton The skeleton to add
  97369. */
  97370. addSkeleton(newSkeleton: Skeleton): void;
  97371. /**
  97372. * Adds the given particle system to this scene
  97373. * @param newParticleSystem The particle system to add
  97374. */
  97375. addParticleSystem(newParticleSystem: IParticleSystem): void;
  97376. /**
  97377. * Adds the given animation to this scene
  97378. * @param newAnimation The animation to add
  97379. */
  97380. addAnimation(newAnimation: Animation): void;
  97381. /**
  97382. * Adds the given animation group to this scene.
  97383. * @param newAnimationGroup The animation group to add
  97384. */
  97385. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  97386. /**
  97387. * Adds the given multi-material to this scene
  97388. * @param newMultiMaterial The multi-material to add
  97389. */
  97390. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  97391. /**
  97392. * Adds the given material to this scene
  97393. * @param newMaterial The material to add
  97394. */
  97395. addMaterial(newMaterial: Material): void;
  97396. /**
  97397. * Adds the given morph target to this scene
  97398. * @param newMorphTargetManager The morph target to add
  97399. */
  97400. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  97401. /**
  97402. * Adds the given geometry to this scene
  97403. * @param newGeometry The geometry to add
  97404. */
  97405. addGeometry(newGeometry: Geometry): void;
  97406. /**
  97407. * Adds the given action manager to this scene
  97408. * @param newActionManager The action manager to add
  97409. */
  97410. addActionManager(newActionManager: AbstractActionManager): void;
  97411. /**
  97412. * Adds the given texture to this scene.
  97413. * @param newTexture The texture to add
  97414. */
  97415. addTexture(newTexture: BaseTexture): void;
  97416. /**
  97417. * Switch active camera
  97418. * @param newCamera defines the new active camera
  97419. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  97420. */
  97421. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  97422. /**
  97423. * sets the active camera of the scene using its ID
  97424. * @param id defines the camera's ID
  97425. * @return the new active camera or null if none found.
  97426. */
  97427. setActiveCameraByID(id: string): Nullable<Camera>;
  97428. /**
  97429. * sets the active camera of the scene using its name
  97430. * @param name defines the camera's name
  97431. * @returns the new active camera or null if none found.
  97432. */
  97433. setActiveCameraByName(name: string): Nullable<Camera>;
  97434. /**
  97435. * get an animation group using its name
  97436. * @param name defines the material's name
  97437. * @return the animation group or null if none found.
  97438. */
  97439. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  97440. /**
  97441. * Get a material using its unique id
  97442. * @param uniqueId defines the material's unique id
  97443. * @return the material or null if none found.
  97444. */
  97445. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  97446. /**
  97447. * get a material using its id
  97448. * @param id defines the material's ID
  97449. * @return the material or null if none found.
  97450. */
  97451. getMaterialByID(id: string): Nullable<Material>;
  97452. /**
  97453. * Gets a the last added material using a given id
  97454. * @param id defines the material's ID
  97455. * @return the last material with the given id or null if none found.
  97456. */
  97457. getLastMaterialByID(id: string): Nullable<Material>;
  97458. /**
  97459. * Gets a material using its name
  97460. * @param name defines the material's name
  97461. * @return the material or null if none found.
  97462. */
  97463. getMaterialByName(name: string): Nullable<Material>;
  97464. /**
  97465. * Gets a camera using its id
  97466. * @param id defines the id to look for
  97467. * @returns the camera or null if not found
  97468. */
  97469. getCameraByID(id: string): Nullable<Camera>;
  97470. /**
  97471. * Gets a camera using its unique id
  97472. * @param uniqueId defines the unique id to look for
  97473. * @returns the camera or null if not found
  97474. */
  97475. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  97476. /**
  97477. * Gets a camera using its name
  97478. * @param name defines the camera's name
  97479. * @return the camera or null if none found.
  97480. */
  97481. getCameraByName(name: string): Nullable<Camera>;
  97482. /**
  97483. * Gets a bone using its id
  97484. * @param id defines the bone's id
  97485. * @return the bone or null if not found
  97486. */
  97487. getBoneByID(id: string): Nullable<Bone>;
  97488. /**
  97489. * Gets a bone using its id
  97490. * @param name defines the bone's name
  97491. * @return the bone or null if not found
  97492. */
  97493. getBoneByName(name: string): Nullable<Bone>;
  97494. /**
  97495. * Gets a light node using its name
  97496. * @param name defines the the light's name
  97497. * @return the light or null if none found.
  97498. */
  97499. getLightByName(name: string): Nullable<Light>;
  97500. /**
  97501. * Gets a light node using its id
  97502. * @param id defines the light's id
  97503. * @return the light or null if none found.
  97504. */
  97505. getLightByID(id: string): Nullable<Light>;
  97506. /**
  97507. * Gets a light node using its scene-generated unique ID
  97508. * @param uniqueId defines the light's unique id
  97509. * @return the light or null if none found.
  97510. */
  97511. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  97512. /**
  97513. * Gets a particle system by id
  97514. * @param id defines the particle system id
  97515. * @return the corresponding system or null if none found
  97516. */
  97517. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  97518. /**
  97519. * Gets a geometry using its ID
  97520. * @param id defines the geometry's id
  97521. * @return the geometry or null if none found.
  97522. */
  97523. getGeometryByID(id: string): Nullable<Geometry>;
  97524. private _getGeometryByUniqueID;
  97525. /**
  97526. * Add a new geometry to this scene
  97527. * @param geometry defines the geometry to be added to the scene.
  97528. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  97529. * @return a boolean defining if the geometry was added or not
  97530. */
  97531. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  97532. /**
  97533. * Removes an existing geometry
  97534. * @param geometry defines the geometry to be removed from the scene
  97535. * @return a boolean defining if the geometry was removed or not
  97536. */
  97537. removeGeometry(geometry: Geometry): boolean;
  97538. /**
  97539. * Gets the list of geometries attached to the scene
  97540. * @returns an array of Geometry
  97541. */
  97542. getGeometries(): Geometry[];
  97543. /**
  97544. * Gets the first added mesh found of a given ID
  97545. * @param id defines the id to search for
  97546. * @return the mesh found or null if not found at all
  97547. */
  97548. getMeshByID(id: string): Nullable<AbstractMesh>;
  97549. /**
  97550. * Gets a list of meshes using their id
  97551. * @param id defines the id to search for
  97552. * @returns a list of meshes
  97553. */
  97554. getMeshesByID(id: string): Array<AbstractMesh>;
  97555. /**
  97556. * Gets the first added transform node found of a given ID
  97557. * @param id defines the id to search for
  97558. * @return the found transform node or null if not found at all.
  97559. */
  97560. getTransformNodeByID(id: string): Nullable<TransformNode>;
  97561. /**
  97562. * Gets a transform node with its auto-generated unique id
  97563. * @param uniqueId efines the unique id to search for
  97564. * @return the found transform node or null if not found at all.
  97565. */
  97566. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  97567. /**
  97568. * Gets a list of transform nodes using their id
  97569. * @param id defines the id to search for
  97570. * @returns a list of transform nodes
  97571. */
  97572. getTransformNodesByID(id: string): Array<TransformNode>;
  97573. /**
  97574. * Gets a mesh with its auto-generated unique id
  97575. * @param uniqueId defines the unique id to search for
  97576. * @return the found mesh or null if not found at all.
  97577. */
  97578. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  97579. /**
  97580. * Gets a the last added mesh using a given id
  97581. * @param id defines the id to search for
  97582. * @return the found mesh or null if not found at all.
  97583. */
  97584. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  97585. /**
  97586. * Gets a the last added node (Mesh, Camera, Light) using a given id
  97587. * @param id defines the id to search for
  97588. * @return the found node or null if not found at all
  97589. */
  97590. getLastEntryByID(id: string): Nullable<Node>;
  97591. /**
  97592. * Gets a node (Mesh, Camera, Light) using a given id
  97593. * @param id defines the id to search for
  97594. * @return the found node or null if not found at all
  97595. */
  97596. getNodeByID(id: string): Nullable<Node>;
  97597. /**
  97598. * Gets a node (Mesh, Camera, Light) using a given name
  97599. * @param name defines the name to search for
  97600. * @return the found node or null if not found at all.
  97601. */
  97602. getNodeByName(name: string): Nullable<Node>;
  97603. /**
  97604. * Gets a mesh using a given name
  97605. * @param name defines the name to search for
  97606. * @return the found mesh or null if not found at all.
  97607. */
  97608. getMeshByName(name: string): Nullable<AbstractMesh>;
  97609. /**
  97610. * Gets a transform node using a given name
  97611. * @param name defines the name to search for
  97612. * @return the found transform node or null if not found at all.
  97613. */
  97614. getTransformNodeByName(name: string): Nullable<TransformNode>;
  97615. /**
  97616. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  97617. * @param id defines the id to search for
  97618. * @return the found skeleton or null if not found at all.
  97619. */
  97620. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  97621. /**
  97622. * Gets a skeleton using a given auto generated unique id
  97623. * @param uniqueId defines the unique id to search for
  97624. * @return the found skeleton or null if not found at all.
  97625. */
  97626. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  97627. /**
  97628. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  97629. * @param id defines the id to search for
  97630. * @return the found skeleton or null if not found at all.
  97631. */
  97632. getSkeletonById(id: string): Nullable<Skeleton>;
  97633. /**
  97634. * Gets a skeleton using a given name
  97635. * @param name defines the name to search for
  97636. * @return the found skeleton or null if not found at all.
  97637. */
  97638. getSkeletonByName(name: string): Nullable<Skeleton>;
  97639. /**
  97640. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  97641. * @param id defines the id to search for
  97642. * @return the found morph target manager or null if not found at all.
  97643. */
  97644. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  97645. /**
  97646. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  97647. * @param id defines the id to search for
  97648. * @return the found morph target or null if not found at all.
  97649. */
  97650. getMorphTargetById(id: string): Nullable<MorphTarget>;
  97651. /**
  97652. * Gets a boolean indicating if the given mesh is active
  97653. * @param mesh defines the mesh to look for
  97654. * @returns true if the mesh is in the active list
  97655. */
  97656. isActiveMesh(mesh: AbstractMesh): boolean;
  97657. /**
  97658. * Return a unique id as a string which can serve as an identifier for the scene
  97659. */
  97660. readonly uid: string;
  97661. /**
  97662. * Add an externaly attached data from its key.
  97663. * This method call will fail and return false, if such key already exists.
  97664. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97665. * @param key the unique key that identifies the data
  97666. * @param data the data object to associate to the key for this Engine instance
  97667. * @return true if no such key were already present and the data was added successfully, false otherwise
  97668. */
  97669. addExternalData<T>(key: string, data: T): boolean;
  97670. /**
  97671. * Get an externaly attached data from its key
  97672. * @param key the unique key that identifies the data
  97673. * @return the associated data, if present (can be null), or undefined if not present
  97674. */
  97675. getExternalData<T>(key: string): Nullable<T>;
  97676. /**
  97677. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97678. * @param key the unique key that identifies the data
  97679. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97680. * @return the associated data, can be null if the factory returned null.
  97681. */
  97682. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97683. /**
  97684. * Remove an externaly attached data from the Engine instance
  97685. * @param key the unique key that identifies the data
  97686. * @return true if the data was successfully removed, false if it doesn't exist
  97687. */
  97688. removeExternalData(key: string): boolean;
  97689. private _evaluateSubMesh;
  97690. /**
  97691. * Clear the processed materials smart array preventing retention point in material dispose.
  97692. */
  97693. freeProcessedMaterials(): void;
  97694. private _preventFreeActiveMeshesAndRenderingGroups;
  97695. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  97696. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  97697. * when disposing several meshes in a row or a hierarchy of meshes.
  97698. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  97699. */
  97700. blockfreeActiveMeshesAndRenderingGroups: boolean;
  97701. /**
  97702. * Clear the active meshes smart array preventing retention point in mesh dispose.
  97703. */
  97704. freeActiveMeshes(): void;
  97705. /**
  97706. * Clear the info related to rendering groups preventing retention points during dispose.
  97707. */
  97708. freeRenderingGroups(): void;
  97709. /** @hidden */
  97710. _isInIntermediateRendering(): boolean;
  97711. /**
  97712. * Lambda returning the list of potentially active meshes.
  97713. */
  97714. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  97715. /**
  97716. * Lambda returning the list of potentially active sub meshes.
  97717. */
  97718. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  97719. /**
  97720. * Lambda returning the list of potentially intersecting sub meshes.
  97721. */
  97722. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  97723. /**
  97724. * Lambda returning the list of potentially colliding sub meshes.
  97725. */
  97726. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  97727. private _activeMeshesFrozen;
  97728. /**
  97729. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  97730. * @returns the current scene
  97731. */
  97732. freezeActiveMeshes(): Scene;
  97733. /**
  97734. * Use this function to restart evaluating active meshes on every frame
  97735. * @returns the current scene
  97736. */
  97737. unfreezeActiveMeshes(): Scene;
  97738. private _evaluateActiveMeshes;
  97739. private _activeMesh;
  97740. /**
  97741. * Update the transform matrix to update from the current active camera
  97742. * @param force defines a boolean used to force the update even if cache is up to date
  97743. */
  97744. updateTransformMatrix(force?: boolean): void;
  97745. private _bindFrameBuffer;
  97746. /** @hidden */
  97747. _allowPostProcessClearColor: boolean;
  97748. /** @hidden */
  97749. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  97750. private _processSubCameras;
  97751. private _checkIntersections;
  97752. /** @hidden */
  97753. _advancePhysicsEngineStep(step: number): void;
  97754. /**
  97755. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  97756. */
  97757. getDeterministicFrameTime: () => number;
  97758. /** @hidden */
  97759. _animate(): void;
  97760. /** Execute all animations (for a frame) */
  97761. animate(): void;
  97762. /**
  97763. * Render the scene
  97764. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  97765. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  97766. */
  97767. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  97768. /**
  97769. * Freeze all materials
  97770. * A frozen material will not be updatable but should be faster to render
  97771. */
  97772. freezeMaterials(): void;
  97773. /**
  97774. * Unfreeze all materials
  97775. * A frozen material will not be updatable but should be faster to render
  97776. */
  97777. unfreezeMaterials(): void;
  97778. /**
  97779. * Releases all held ressources
  97780. */
  97781. dispose(): void;
  97782. /**
  97783. * Gets if the scene is already disposed
  97784. */
  97785. readonly isDisposed: boolean;
  97786. /**
  97787. * Call this function to reduce memory footprint of the scene.
  97788. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  97789. */
  97790. clearCachedVertexData(): void;
  97791. /**
  97792. * This function will remove the local cached buffer data from texture.
  97793. * It will save memory but will prevent the texture from being rebuilt
  97794. */
  97795. cleanCachedTextureBuffer(): void;
  97796. /**
  97797. * Get the world extend vectors with an optional filter
  97798. *
  97799. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  97800. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  97801. */
  97802. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  97803. min: Vector3;
  97804. max: Vector3;
  97805. };
  97806. /**
  97807. * Creates a ray that can be used to pick in the scene
  97808. * @param x defines the x coordinate of the origin (on-screen)
  97809. * @param y defines the y coordinate of the origin (on-screen)
  97810. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  97811. * @param camera defines the camera to use for the picking
  97812. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  97813. * @returns a Ray
  97814. */
  97815. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  97816. /**
  97817. * Creates a ray that can be used to pick in the scene
  97818. * @param x defines the x coordinate of the origin (on-screen)
  97819. * @param y defines the y coordinate of the origin (on-screen)
  97820. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  97821. * @param result defines the ray where to store the picking ray
  97822. * @param camera defines the camera to use for the picking
  97823. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  97824. * @returns the current scene
  97825. */
  97826. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  97827. /**
  97828. * Creates a ray that can be used to pick in the scene
  97829. * @param x defines the x coordinate of the origin (on-screen)
  97830. * @param y defines the y coordinate of the origin (on-screen)
  97831. * @param camera defines the camera to use for the picking
  97832. * @returns a Ray
  97833. */
  97834. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  97835. /**
  97836. * Creates a ray that can be used to pick in the scene
  97837. * @param x defines the x coordinate of the origin (on-screen)
  97838. * @param y defines the y coordinate of the origin (on-screen)
  97839. * @param result defines the ray where to store the picking ray
  97840. * @param camera defines the camera to use for the picking
  97841. * @returns the current scene
  97842. */
  97843. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  97844. /** Launch a ray to try to pick a mesh in the scene
  97845. * @param x position on screen
  97846. * @param y position on screen
  97847. * @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
  97848. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  97849. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  97850. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97851. * @returns a PickingInfo
  97852. */
  97853. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  97854. /** Use the given ray to pick a mesh in the scene
  97855. * @param ray The ray to use to pick meshes
  97856. * @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
  97857. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  97858. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97859. * @returns a PickingInfo
  97860. */
  97861. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  97862. /**
  97863. * Launch a ray to try to pick a mesh in the scene
  97864. * @param x X position on screen
  97865. * @param y Y position on screen
  97866. * @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
  97867. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  97868. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97869. * @returns an array of PickingInfo
  97870. */
  97871. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  97872. /**
  97873. * Launch a ray to try to pick a mesh in the scene
  97874. * @param ray Ray to use
  97875. * @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
  97876. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97877. * @returns an array of PickingInfo
  97878. */
  97879. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  97880. /**
  97881. * Force the value of meshUnderPointer
  97882. * @param mesh defines the mesh to use
  97883. */
  97884. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  97885. /**
  97886. * Gets the mesh under the pointer
  97887. * @returns a Mesh or null if no mesh is under the pointer
  97888. */
  97889. getPointerOverMesh(): Nullable<AbstractMesh>;
  97890. /** @hidden */
  97891. _rebuildGeometries(): void;
  97892. /** @hidden */
  97893. _rebuildTextures(): void;
  97894. private _getByTags;
  97895. /**
  97896. * Get a list of meshes by tags
  97897. * @param tagsQuery defines the tags query to use
  97898. * @param forEach defines a predicate used to filter results
  97899. * @returns an array of Mesh
  97900. */
  97901. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  97902. /**
  97903. * Get a list of cameras by tags
  97904. * @param tagsQuery defines the tags query to use
  97905. * @param forEach defines a predicate used to filter results
  97906. * @returns an array of Camera
  97907. */
  97908. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  97909. /**
  97910. * Get a list of lights by tags
  97911. * @param tagsQuery defines the tags query to use
  97912. * @param forEach defines a predicate used to filter results
  97913. * @returns an array of Light
  97914. */
  97915. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  97916. /**
  97917. * Get a list of materials by tags
  97918. * @param tagsQuery defines the tags query to use
  97919. * @param forEach defines a predicate used to filter results
  97920. * @returns an array of Material
  97921. */
  97922. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  97923. /**
  97924. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97925. * This allowed control for front to back rendering or reversly depending of the special needs.
  97926. *
  97927. * @param renderingGroupId The rendering group id corresponding to its index
  97928. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97929. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97930. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97931. */
  97932. 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;
  97933. /**
  97934. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97935. *
  97936. * @param renderingGroupId The rendering group id corresponding to its index
  97937. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97938. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97939. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97940. */
  97941. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97942. /**
  97943. * Gets the current auto clear configuration for one rendering group of the rendering
  97944. * manager.
  97945. * @param index the rendering group index to get the information for
  97946. * @returns The auto clear setup for the requested rendering group
  97947. */
  97948. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97949. private _blockMaterialDirtyMechanism;
  97950. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  97951. blockMaterialDirtyMechanism: boolean;
  97952. /**
  97953. * Will flag all materials as dirty to trigger new shader compilation
  97954. * @param flag defines the flag used to specify which material part must be marked as dirty
  97955. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  97956. */
  97957. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97958. /** @hidden */
  97959. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  97960. /** @hidden */
  97961. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97962. }
  97963. }
  97964. declare module BABYLON {
  97965. /**
  97966. * Set of assets to keep when moving a scene into an asset container.
  97967. */
  97968. export class KeepAssets extends AbstractScene {
  97969. }
  97970. /**
  97971. * Container with a set of assets that can be added or removed from a scene.
  97972. */
  97973. export class AssetContainer extends AbstractScene {
  97974. /**
  97975. * The scene the AssetContainer belongs to.
  97976. */
  97977. scene: Scene;
  97978. /**
  97979. * Instantiates an AssetContainer.
  97980. * @param scene The scene the AssetContainer belongs to.
  97981. */
  97982. constructor(scene: Scene);
  97983. /**
  97984. * Adds all the assets from the container to the scene.
  97985. */
  97986. addAllToScene(): void;
  97987. /**
  97988. * Removes all the assets in the container from the scene
  97989. */
  97990. removeAllFromScene(): void;
  97991. /**
  97992. * Disposes all the assets in the container
  97993. */
  97994. dispose(): void;
  97995. private _moveAssets;
  97996. /**
  97997. * Removes all the assets contained in the scene and adds them to the container.
  97998. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  97999. */
  98000. moveAllFromScene(keepAssets?: KeepAssets): void;
  98001. /**
  98002. * 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.
  98003. * @returns the root mesh
  98004. */
  98005. createRootMesh(): Mesh;
  98006. }
  98007. }
  98008. declare module BABYLON {
  98009. /**
  98010. * Defines how the parser contract is defined.
  98011. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  98012. */
  98013. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  98014. /**
  98015. * Defines how the individual parser contract is defined.
  98016. * These parser can parse an individual asset
  98017. */
  98018. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  98019. /**
  98020. * Base class of the scene acting as a container for the different elements composing a scene.
  98021. * This class is dynamically extended by the different components of the scene increasing
  98022. * flexibility and reducing coupling
  98023. */
  98024. export abstract class AbstractScene {
  98025. /**
  98026. * Stores the list of available parsers in the application.
  98027. */
  98028. private static _BabylonFileParsers;
  98029. /**
  98030. * Stores the list of available individual parsers in the application.
  98031. */
  98032. private static _IndividualBabylonFileParsers;
  98033. /**
  98034. * Adds a parser in the list of available ones
  98035. * @param name Defines the name of the parser
  98036. * @param parser Defines the parser to add
  98037. */
  98038. static AddParser(name: string, parser: BabylonFileParser): void;
  98039. /**
  98040. * Gets a general parser from the list of avaialble ones
  98041. * @param name Defines the name of the parser
  98042. * @returns the requested parser or null
  98043. */
  98044. static GetParser(name: string): Nullable<BabylonFileParser>;
  98045. /**
  98046. * Adds n individual parser in the list of available ones
  98047. * @param name Defines the name of the parser
  98048. * @param parser Defines the parser to add
  98049. */
  98050. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  98051. /**
  98052. * Gets an individual parser from the list of avaialble ones
  98053. * @param name Defines the name of the parser
  98054. * @returns the requested parser or null
  98055. */
  98056. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  98057. /**
  98058. * Parser json data and populate both a scene and its associated container object
  98059. * @param jsonData Defines the data to parse
  98060. * @param scene Defines the scene to parse the data for
  98061. * @param container Defines the container attached to the parsing sequence
  98062. * @param rootUrl Defines the root url of the data
  98063. */
  98064. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  98065. /**
  98066. * Gets the list of root nodes (ie. nodes with no parent)
  98067. */
  98068. rootNodes: Node[];
  98069. /** All of the cameras added to this scene
  98070. * @see http://doc.babylonjs.com/babylon101/cameras
  98071. */
  98072. cameras: Camera[];
  98073. /**
  98074. * All of the lights added to this scene
  98075. * @see http://doc.babylonjs.com/babylon101/lights
  98076. */
  98077. lights: Light[];
  98078. /**
  98079. * All of the (abstract) meshes added to this scene
  98080. */
  98081. meshes: AbstractMesh[];
  98082. /**
  98083. * The list of skeletons added to the scene
  98084. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98085. */
  98086. skeletons: Skeleton[];
  98087. /**
  98088. * All of the particle systems added to this scene
  98089. * @see http://doc.babylonjs.com/babylon101/particles
  98090. */
  98091. particleSystems: IParticleSystem[];
  98092. /**
  98093. * Gets a list of Animations associated with the scene
  98094. */
  98095. animations: Animation[];
  98096. /**
  98097. * All of the animation groups added to this scene
  98098. * @see http://doc.babylonjs.com/how_to/group
  98099. */
  98100. animationGroups: AnimationGroup[];
  98101. /**
  98102. * All of the multi-materials added to this scene
  98103. * @see http://doc.babylonjs.com/how_to/multi_materials
  98104. */
  98105. multiMaterials: MultiMaterial[];
  98106. /**
  98107. * All of the materials added to this scene
  98108. * In the context of a Scene, it is not supposed to be modified manually.
  98109. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  98110. * Note also that the order of the Material wihin the array is not significant and might change.
  98111. * @see http://doc.babylonjs.com/babylon101/materials
  98112. */
  98113. materials: Material[];
  98114. /**
  98115. * The list of morph target managers added to the scene
  98116. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  98117. */
  98118. morphTargetManagers: MorphTargetManager[];
  98119. /**
  98120. * The list of geometries used in the scene.
  98121. */
  98122. geometries: Geometry[];
  98123. /**
  98124. * All of the tranform nodes added to this scene
  98125. * In the context of a Scene, it is not supposed to be modified manually.
  98126. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  98127. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  98128. * @see http://doc.babylonjs.com/how_to/transformnode
  98129. */
  98130. transformNodes: TransformNode[];
  98131. /**
  98132. * ActionManagers available on the scene.
  98133. */
  98134. actionManagers: AbstractActionManager[];
  98135. /**
  98136. * Textures to keep.
  98137. */
  98138. textures: BaseTexture[];
  98139. /**
  98140. * Environment texture for the scene
  98141. */
  98142. environmentTexture: Nullable<BaseTexture>;
  98143. }
  98144. }
  98145. declare module BABYLON {
  98146. /**
  98147. * Interface used to define options for Sound class
  98148. */
  98149. export interface ISoundOptions {
  98150. /**
  98151. * Does the sound autoplay once loaded.
  98152. */
  98153. autoplay?: boolean;
  98154. /**
  98155. * Does the sound loop after it finishes playing once.
  98156. */
  98157. loop?: boolean;
  98158. /**
  98159. * Sound's volume
  98160. */
  98161. volume?: number;
  98162. /**
  98163. * Is it a spatial sound?
  98164. */
  98165. spatialSound?: boolean;
  98166. /**
  98167. * Maximum distance to hear that sound
  98168. */
  98169. maxDistance?: number;
  98170. /**
  98171. * Uses user defined attenuation function
  98172. */
  98173. useCustomAttenuation?: boolean;
  98174. /**
  98175. * Define the roll off factor of spatial sounds.
  98176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98177. */
  98178. rolloffFactor?: number;
  98179. /**
  98180. * Define the reference distance the sound should be heard perfectly.
  98181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98182. */
  98183. refDistance?: number;
  98184. /**
  98185. * Define the distance attenuation model the sound will follow.
  98186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98187. */
  98188. distanceModel?: string;
  98189. /**
  98190. * Defines the playback speed (1 by default)
  98191. */
  98192. playbackRate?: number;
  98193. /**
  98194. * Defines if the sound is from a streaming source
  98195. */
  98196. streaming?: boolean;
  98197. /**
  98198. * Defines an optional length (in seconds) inside the sound file
  98199. */
  98200. length?: number;
  98201. /**
  98202. * Defines an optional offset (in seconds) inside the sound file
  98203. */
  98204. offset?: number;
  98205. /**
  98206. * If true, URLs will not be required to state the audio file codec to use.
  98207. */
  98208. skipCodecCheck?: boolean;
  98209. }
  98210. /**
  98211. * Defines a sound that can be played in the application.
  98212. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  98213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98214. */
  98215. export class Sound {
  98216. /**
  98217. * The name of the sound in the scene.
  98218. */
  98219. name: string;
  98220. /**
  98221. * Does the sound autoplay once loaded.
  98222. */
  98223. autoplay: boolean;
  98224. /**
  98225. * Does the sound loop after it finishes playing once.
  98226. */
  98227. loop: boolean;
  98228. /**
  98229. * Does the sound use a custom attenuation curve to simulate the falloff
  98230. * happening when the source gets further away from the camera.
  98231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98232. */
  98233. useCustomAttenuation: boolean;
  98234. /**
  98235. * The sound track id this sound belongs to.
  98236. */
  98237. soundTrackId: number;
  98238. /**
  98239. * Is this sound currently played.
  98240. */
  98241. isPlaying: boolean;
  98242. /**
  98243. * Is this sound currently paused.
  98244. */
  98245. isPaused: boolean;
  98246. /**
  98247. * Does this sound enables spatial sound.
  98248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98249. */
  98250. spatialSound: boolean;
  98251. /**
  98252. * Define the reference distance the sound should be heard perfectly.
  98253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98254. */
  98255. refDistance: number;
  98256. /**
  98257. * Define the roll off factor of spatial sounds.
  98258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98259. */
  98260. rolloffFactor: number;
  98261. /**
  98262. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  98263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98264. */
  98265. maxDistance: number;
  98266. /**
  98267. * Define the distance attenuation model the sound will follow.
  98268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98269. */
  98270. distanceModel: string;
  98271. /**
  98272. * @hidden
  98273. * Back Compat
  98274. **/
  98275. onended: () => any;
  98276. /**
  98277. * Observable event when the current playing sound finishes.
  98278. */
  98279. onEndedObservable: Observable<Sound>;
  98280. private _panningModel;
  98281. private _playbackRate;
  98282. private _streaming;
  98283. private _startTime;
  98284. private _startOffset;
  98285. private _position;
  98286. /** @hidden */
  98287. _positionInEmitterSpace: boolean;
  98288. private _localDirection;
  98289. private _volume;
  98290. private _isReadyToPlay;
  98291. private _isDirectional;
  98292. private _readyToPlayCallback;
  98293. private _audioBuffer;
  98294. private _soundSource;
  98295. private _streamingSource;
  98296. private _soundPanner;
  98297. private _soundGain;
  98298. private _inputAudioNode;
  98299. private _outputAudioNode;
  98300. private _coneInnerAngle;
  98301. private _coneOuterAngle;
  98302. private _coneOuterGain;
  98303. private _scene;
  98304. private _connectedTransformNode;
  98305. private _customAttenuationFunction;
  98306. private _registerFunc;
  98307. private _isOutputConnected;
  98308. private _htmlAudioElement;
  98309. private _urlType;
  98310. private _length?;
  98311. private _offset?;
  98312. /** @hidden */
  98313. static _SceneComponentInitialization: (scene: Scene) => void;
  98314. /**
  98315. * Create a sound and attach it to a scene
  98316. * @param name Name of your sound
  98317. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  98318. * @param scene defines the scene the sound belongs to
  98319. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  98320. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  98321. */
  98322. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  98323. /**
  98324. * Release the sound and its associated resources
  98325. */
  98326. dispose(): void;
  98327. /**
  98328. * Gets if the sounds is ready to be played or not.
  98329. * @returns true if ready, otherwise false
  98330. */
  98331. isReady(): boolean;
  98332. private _soundLoaded;
  98333. /**
  98334. * Sets the data of the sound from an audiobuffer
  98335. * @param audioBuffer The audioBuffer containing the data
  98336. */
  98337. setAudioBuffer(audioBuffer: AudioBuffer): void;
  98338. /**
  98339. * Updates the current sounds options such as maxdistance, loop...
  98340. * @param options A JSON object containing values named as the object properties
  98341. */
  98342. updateOptions(options: ISoundOptions): void;
  98343. private _createSpatialParameters;
  98344. private _updateSpatialParameters;
  98345. /**
  98346. * Switch the panning model to HRTF:
  98347. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98349. */
  98350. switchPanningModelToHRTF(): void;
  98351. /**
  98352. * Switch the panning model to Equal Power:
  98353. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98355. */
  98356. switchPanningModelToEqualPower(): void;
  98357. private _switchPanningModel;
  98358. /**
  98359. * Connect this sound to a sound track audio node like gain...
  98360. * @param soundTrackAudioNode the sound track audio node to connect to
  98361. */
  98362. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  98363. /**
  98364. * Transform this sound into a directional source
  98365. * @param coneInnerAngle Size of the inner cone in degree
  98366. * @param coneOuterAngle Size of the outer cone in degree
  98367. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  98368. */
  98369. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  98370. /**
  98371. * Gets or sets the inner angle for the directional cone.
  98372. */
  98373. /**
  98374. * Gets or sets the inner angle for the directional cone.
  98375. */
  98376. directionalConeInnerAngle: number;
  98377. /**
  98378. * Gets or sets the outer angle for the directional cone.
  98379. */
  98380. /**
  98381. * Gets or sets the outer angle for the directional cone.
  98382. */
  98383. directionalConeOuterAngle: number;
  98384. /**
  98385. * Sets the position of the emitter if spatial sound is enabled
  98386. * @param newPosition Defines the new posisiton
  98387. */
  98388. setPosition(newPosition: Vector3): void;
  98389. /**
  98390. * Sets the local direction of the emitter if spatial sound is enabled
  98391. * @param newLocalDirection Defines the new local direction
  98392. */
  98393. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  98394. private _updateDirection;
  98395. /** @hidden */
  98396. updateDistanceFromListener(): void;
  98397. /**
  98398. * Sets a new custom attenuation function for the sound.
  98399. * @param callback Defines the function used for the attenuation
  98400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98401. */
  98402. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  98403. /**
  98404. * Play the sound
  98405. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  98406. * @param offset (optional) Start the sound at a specific time in seconds
  98407. * @param length (optional) Sound duration (in seconds)
  98408. */
  98409. play(time?: number, offset?: number, length?: number): void;
  98410. private _onended;
  98411. /**
  98412. * Stop the sound
  98413. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  98414. */
  98415. stop(time?: number): void;
  98416. /**
  98417. * Put the sound in pause
  98418. */
  98419. pause(): void;
  98420. /**
  98421. * Sets a dedicated volume for this sounds
  98422. * @param newVolume Define the new volume of the sound
  98423. * @param time Define time for gradual change to new volume
  98424. */
  98425. setVolume(newVolume: number, time?: number): void;
  98426. /**
  98427. * Set the sound play back rate
  98428. * @param newPlaybackRate Define the playback rate the sound should be played at
  98429. */
  98430. setPlaybackRate(newPlaybackRate: number): void;
  98431. /**
  98432. * Gets the volume of the sound.
  98433. * @returns the volume of the sound
  98434. */
  98435. getVolume(): number;
  98436. /**
  98437. * Attach the sound to a dedicated mesh
  98438. * @param transformNode The transform node to connect the sound with
  98439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98440. */
  98441. attachToMesh(transformNode: TransformNode): void;
  98442. /**
  98443. * Detach the sound from the previously attached mesh
  98444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98445. */
  98446. detachFromMesh(): void;
  98447. private _onRegisterAfterWorldMatrixUpdate;
  98448. /**
  98449. * Clone the current sound in the scene.
  98450. * @returns the new sound clone
  98451. */
  98452. clone(): Nullable<Sound>;
  98453. /**
  98454. * Gets the current underlying audio buffer containing the data
  98455. * @returns the audio buffer
  98456. */
  98457. getAudioBuffer(): Nullable<AudioBuffer>;
  98458. /**
  98459. * Serializes the Sound in a JSON representation
  98460. * @returns the JSON representation of the sound
  98461. */
  98462. serialize(): any;
  98463. /**
  98464. * Parse a JSON representation of a sound to innstantiate in a given scene
  98465. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  98466. * @param scene Define the scene the new parsed sound should be created in
  98467. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  98468. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  98469. * @returns the newly parsed sound
  98470. */
  98471. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  98472. }
  98473. }
  98474. declare module BABYLON {
  98475. /**
  98476. * This defines an action helpful to play a defined sound on a triggered action.
  98477. */
  98478. export class PlaySoundAction extends Action {
  98479. private _sound;
  98480. /**
  98481. * Instantiate the action
  98482. * @param triggerOptions defines the trigger options
  98483. * @param sound defines the sound to play
  98484. * @param condition defines the trigger related conditions
  98485. */
  98486. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98487. /** @hidden */
  98488. _prepare(): void;
  98489. /**
  98490. * Execute the action and play the sound.
  98491. */
  98492. execute(): void;
  98493. /**
  98494. * Serializes the actions and its related information.
  98495. * @param parent defines the object to serialize in
  98496. * @returns the serialized object
  98497. */
  98498. serialize(parent: any): any;
  98499. }
  98500. /**
  98501. * This defines an action helpful to stop a defined sound on a triggered action.
  98502. */
  98503. export class StopSoundAction extends Action {
  98504. private _sound;
  98505. /**
  98506. * Instantiate the action
  98507. * @param triggerOptions defines the trigger options
  98508. * @param sound defines the sound to stop
  98509. * @param condition defines the trigger related conditions
  98510. */
  98511. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98512. /** @hidden */
  98513. _prepare(): void;
  98514. /**
  98515. * Execute the action and stop the sound.
  98516. */
  98517. execute(): void;
  98518. /**
  98519. * Serializes the actions and its related information.
  98520. * @param parent defines the object to serialize in
  98521. * @returns the serialized object
  98522. */
  98523. serialize(parent: any): any;
  98524. }
  98525. }
  98526. declare module BABYLON {
  98527. /**
  98528. * This defines an action responsible to change the value of a property
  98529. * by interpolating between its current value and the newly set one once triggered.
  98530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98531. */
  98532. export class InterpolateValueAction extends Action {
  98533. /**
  98534. * Defines the path of the property where the value should be interpolated
  98535. */
  98536. propertyPath: string;
  98537. /**
  98538. * Defines the target value at the end of the interpolation.
  98539. */
  98540. value: any;
  98541. /**
  98542. * Defines the time it will take for the property to interpolate to the value.
  98543. */
  98544. duration: number;
  98545. /**
  98546. * Defines if the other scene animations should be stopped when the action has been triggered
  98547. */
  98548. stopOtherAnimations?: boolean;
  98549. /**
  98550. * Defines a callback raised once the interpolation animation has been done.
  98551. */
  98552. onInterpolationDone?: () => void;
  98553. /**
  98554. * Observable triggered once the interpolation animation has been done.
  98555. */
  98556. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  98557. private _target;
  98558. private _effectiveTarget;
  98559. private _property;
  98560. /**
  98561. * Instantiate the action
  98562. * @param triggerOptions defines the trigger options
  98563. * @param target defines the object containing the value to interpolate
  98564. * @param propertyPath defines the path to the property in the target object
  98565. * @param value defines the target value at the end of the interpolation
  98566. * @param duration deines the time it will take for the property to interpolate to the value.
  98567. * @param condition defines the trigger related conditions
  98568. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  98569. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  98570. */
  98571. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  98572. /** @hidden */
  98573. _prepare(): void;
  98574. /**
  98575. * Execute the action starts the value interpolation.
  98576. */
  98577. execute(): void;
  98578. /**
  98579. * Serializes the actions and its related information.
  98580. * @param parent defines the object to serialize in
  98581. * @returns the serialized object
  98582. */
  98583. serialize(parent: any): any;
  98584. }
  98585. }
  98586. declare module BABYLON {
  98587. /**
  98588. * Options allowed during the creation of a sound track.
  98589. */
  98590. export interface ISoundTrackOptions {
  98591. /**
  98592. * The volume the sound track should take during creation
  98593. */
  98594. volume?: number;
  98595. /**
  98596. * Define if the sound track is the main sound track of the scene
  98597. */
  98598. mainTrack?: boolean;
  98599. }
  98600. /**
  98601. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  98602. * It will be also used in a future release to apply effects on a specific track.
  98603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98604. */
  98605. export class SoundTrack {
  98606. /**
  98607. * The unique identifier of the sound track in the scene.
  98608. */
  98609. id: number;
  98610. /**
  98611. * The list of sounds included in the sound track.
  98612. */
  98613. soundCollection: Array<Sound>;
  98614. private _outputAudioNode;
  98615. private _scene;
  98616. private _isMainTrack;
  98617. private _connectedAnalyser;
  98618. private _options;
  98619. private _isInitialized;
  98620. /**
  98621. * Creates a new sound track.
  98622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98623. * @param scene Define the scene the sound track belongs to
  98624. * @param options
  98625. */
  98626. constructor(scene: Scene, options?: ISoundTrackOptions);
  98627. private _initializeSoundTrackAudioGraph;
  98628. /**
  98629. * Release the sound track and its associated resources
  98630. */
  98631. dispose(): void;
  98632. /**
  98633. * Adds a sound to this sound track
  98634. * @param sound define the cound to add
  98635. * @ignoreNaming
  98636. */
  98637. AddSound(sound: Sound): void;
  98638. /**
  98639. * Removes a sound to this sound track
  98640. * @param sound define the cound to remove
  98641. * @ignoreNaming
  98642. */
  98643. RemoveSound(sound: Sound): void;
  98644. /**
  98645. * Set a global volume for the full sound track.
  98646. * @param newVolume Define the new volume of the sound track
  98647. */
  98648. setVolume(newVolume: number): void;
  98649. /**
  98650. * Switch the panning model to HRTF:
  98651. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98653. */
  98654. switchPanningModelToHRTF(): void;
  98655. /**
  98656. * Switch the panning model to Equal Power:
  98657. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98659. */
  98660. switchPanningModelToEqualPower(): void;
  98661. /**
  98662. * Connect the sound track to an audio analyser allowing some amazing
  98663. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98665. * @param analyser The analyser to connect to the engine
  98666. */
  98667. connectToAnalyser(analyser: Analyser): void;
  98668. }
  98669. }
  98670. declare module BABYLON {
  98671. interface AbstractScene {
  98672. /**
  98673. * The list of sounds used in the scene.
  98674. */
  98675. sounds: Nullable<Array<Sound>>;
  98676. }
  98677. interface Scene {
  98678. /**
  98679. * @hidden
  98680. * Backing field
  98681. */
  98682. _mainSoundTrack: SoundTrack;
  98683. /**
  98684. * The main sound track played by the scene.
  98685. * It cotains your primary collection of sounds.
  98686. */
  98687. mainSoundTrack: SoundTrack;
  98688. /**
  98689. * The list of sound tracks added to the scene
  98690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98691. */
  98692. soundTracks: Nullable<Array<SoundTrack>>;
  98693. /**
  98694. * Gets a sound using a given name
  98695. * @param name defines the name to search for
  98696. * @return the found sound or null if not found at all.
  98697. */
  98698. getSoundByName(name: string): Nullable<Sound>;
  98699. /**
  98700. * Gets or sets if audio support is enabled
  98701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98702. */
  98703. audioEnabled: boolean;
  98704. /**
  98705. * Gets or sets if audio will be output to headphones
  98706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98707. */
  98708. headphone: boolean;
  98709. }
  98710. /**
  98711. * Defines the sound scene component responsible to manage any sounds
  98712. * in a given scene.
  98713. */
  98714. export class AudioSceneComponent implements ISceneSerializableComponent {
  98715. /**
  98716. * The component name helpfull to identify the component in the list of scene components.
  98717. */
  98718. readonly name: string;
  98719. /**
  98720. * The scene the component belongs to.
  98721. */
  98722. scene: Scene;
  98723. private _audioEnabled;
  98724. /**
  98725. * Gets whether audio is enabled or not.
  98726. * Please use related enable/disable method to switch state.
  98727. */
  98728. readonly audioEnabled: boolean;
  98729. private _headphone;
  98730. /**
  98731. * Gets whether audio is outputing to headphone or not.
  98732. * Please use the according Switch methods to change output.
  98733. */
  98734. readonly headphone: boolean;
  98735. /**
  98736. * Creates a new instance of the component for the given scene
  98737. * @param scene Defines the scene to register the component in
  98738. */
  98739. constructor(scene: Scene);
  98740. /**
  98741. * Registers the component in a given scene
  98742. */
  98743. register(): void;
  98744. /**
  98745. * Rebuilds the elements related to this component in case of
  98746. * context lost for instance.
  98747. */
  98748. rebuild(): void;
  98749. /**
  98750. * Serializes the component data to the specified json object
  98751. * @param serializationObject The object to serialize to
  98752. */
  98753. serialize(serializationObject: any): void;
  98754. /**
  98755. * Adds all the elements from the container to the scene
  98756. * @param container the container holding the elements
  98757. */
  98758. addFromContainer(container: AbstractScene): void;
  98759. /**
  98760. * Removes all the elements in the container from the scene
  98761. * @param container contains the elements to remove
  98762. * @param dispose if the removed element should be disposed (default: false)
  98763. */
  98764. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  98765. /**
  98766. * Disposes the component and the associated ressources.
  98767. */
  98768. dispose(): void;
  98769. /**
  98770. * Disables audio in the associated scene.
  98771. */
  98772. disableAudio(): void;
  98773. /**
  98774. * Enables audio in the associated scene.
  98775. */
  98776. enableAudio(): void;
  98777. /**
  98778. * Switch audio to headphone output.
  98779. */
  98780. switchAudioModeForHeadphones(): void;
  98781. /**
  98782. * Switch audio to normal speakers.
  98783. */
  98784. switchAudioModeForNormalSpeakers(): void;
  98785. private _afterRender;
  98786. }
  98787. }
  98788. declare module BABYLON {
  98789. /**
  98790. * Wraps one or more Sound objects and selects one with random weight for playback.
  98791. */
  98792. export class WeightedSound {
  98793. /** When true a Sound will be selected and played when the current playing Sound completes. */
  98794. loop: boolean;
  98795. private _coneInnerAngle;
  98796. private _coneOuterAngle;
  98797. private _volume;
  98798. /** A Sound is currently playing. */
  98799. isPlaying: boolean;
  98800. /** A Sound is currently paused. */
  98801. isPaused: boolean;
  98802. private _sounds;
  98803. private _weights;
  98804. private _currentIndex?;
  98805. /**
  98806. * Creates a new WeightedSound from the list of sounds given.
  98807. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  98808. * @param sounds Array of Sounds that will be selected from.
  98809. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  98810. */
  98811. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  98812. /**
  98813. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  98814. */
  98815. /**
  98816. * The size of cone in degress for a directional sound in which there will be no attenuation.
  98817. */
  98818. directionalConeInnerAngle: number;
  98819. /**
  98820. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  98821. * Listener angles between innerAngle and outerAngle will falloff linearly.
  98822. */
  98823. /**
  98824. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  98825. * Listener angles between innerAngle and outerAngle will falloff linearly.
  98826. */
  98827. directionalConeOuterAngle: number;
  98828. /**
  98829. * Playback volume.
  98830. */
  98831. /**
  98832. * Playback volume.
  98833. */
  98834. volume: number;
  98835. private _onended;
  98836. /**
  98837. * Suspend playback
  98838. */
  98839. pause(): void;
  98840. /**
  98841. * Stop playback
  98842. */
  98843. stop(): void;
  98844. /**
  98845. * Start playback.
  98846. * @param startOffset Position the clip head at a specific time in seconds.
  98847. */
  98848. play(startOffset?: number): void;
  98849. }
  98850. }
  98851. declare module BABYLON {
  98852. /**
  98853. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  98854. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98855. */
  98856. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  98857. /**
  98858. * Gets the name of the behavior.
  98859. */
  98860. readonly name: string;
  98861. /**
  98862. * The easing function used by animations
  98863. */
  98864. static EasingFunction: BackEase;
  98865. /**
  98866. * The easing mode used by animations
  98867. */
  98868. static EasingMode: number;
  98869. /**
  98870. * The duration of the animation, in milliseconds
  98871. */
  98872. transitionDuration: number;
  98873. /**
  98874. * Length of the distance animated by the transition when lower radius is reached
  98875. */
  98876. lowerRadiusTransitionRange: number;
  98877. /**
  98878. * Length of the distance animated by the transition when upper radius is reached
  98879. */
  98880. upperRadiusTransitionRange: number;
  98881. private _autoTransitionRange;
  98882. /**
  98883. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  98884. */
  98885. /**
  98886. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  98887. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  98888. */
  98889. autoTransitionRange: boolean;
  98890. private _attachedCamera;
  98891. private _onAfterCheckInputsObserver;
  98892. private _onMeshTargetChangedObserver;
  98893. /**
  98894. * Initializes the behavior.
  98895. */
  98896. init(): void;
  98897. /**
  98898. * Attaches the behavior to its arc rotate camera.
  98899. * @param camera Defines the camera to attach the behavior to
  98900. */
  98901. attach(camera: ArcRotateCamera): void;
  98902. /**
  98903. * Detaches the behavior from its current arc rotate camera.
  98904. */
  98905. detach(): void;
  98906. private _radiusIsAnimating;
  98907. private _radiusBounceTransition;
  98908. private _animatables;
  98909. private _cachedWheelPrecision;
  98910. /**
  98911. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  98912. * @param radiusLimit The limit to check against.
  98913. * @return Bool to indicate if at limit.
  98914. */
  98915. private _isRadiusAtLimit;
  98916. /**
  98917. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  98918. * @param radiusDelta The delta by which to animate to. Can be negative.
  98919. */
  98920. private _applyBoundRadiusAnimation;
  98921. /**
  98922. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  98923. */
  98924. protected _clearAnimationLocks(): void;
  98925. /**
  98926. * Stops and removes all animations that have been applied to the camera
  98927. */
  98928. stopAllAnimations(): void;
  98929. }
  98930. }
  98931. declare module BABYLON {
  98932. /**
  98933. * 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.
  98934. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98935. */
  98936. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  98937. /**
  98938. * Gets the name of the behavior.
  98939. */
  98940. readonly name: string;
  98941. private _mode;
  98942. private _radiusScale;
  98943. private _positionScale;
  98944. private _defaultElevation;
  98945. private _elevationReturnTime;
  98946. private _elevationReturnWaitTime;
  98947. private _zoomStopsAnimation;
  98948. private _framingTime;
  98949. /**
  98950. * The easing function used by animations
  98951. */
  98952. static EasingFunction: ExponentialEase;
  98953. /**
  98954. * The easing mode used by animations
  98955. */
  98956. static EasingMode: number;
  98957. /**
  98958. * Sets the current mode used by the behavior
  98959. */
  98960. /**
  98961. * Gets current mode used by the behavior.
  98962. */
  98963. mode: number;
  98964. /**
  98965. * Sets the scale applied to the radius (1 by default)
  98966. */
  98967. /**
  98968. * Gets the scale applied to the radius
  98969. */
  98970. radiusScale: number;
  98971. /**
  98972. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  98973. */
  98974. /**
  98975. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  98976. */
  98977. positionScale: number;
  98978. /**
  98979. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98980. * behaviour is triggered, in radians.
  98981. */
  98982. /**
  98983. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98984. * behaviour is triggered, in radians.
  98985. */
  98986. defaultElevation: number;
  98987. /**
  98988. * Sets the time (in milliseconds) taken to return to the default beta position.
  98989. * Negative value indicates camera should not return to default.
  98990. */
  98991. /**
  98992. * Gets the time (in milliseconds) taken to return to the default beta position.
  98993. * Negative value indicates camera should not return to default.
  98994. */
  98995. elevationReturnTime: number;
  98996. /**
  98997. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98998. */
  98999. /**
  99000. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99001. */
  99002. elevationReturnWaitTime: number;
  99003. /**
  99004. * Sets the flag that indicates if user zooming should stop animation.
  99005. */
  99006. /**
  99007. * Gets the flag that indicates if user zooming should stop animation.
  99008. */
  99009. zoomStopsAnimation: boolean;
  99010. /**
  99011. * Sets the transition time when framing the mesh, in milliseconds
  99012. */
  99013. /**
  99014. * Gets the transition time when framing the mesh, in milliseconds
  99015. */
  99016. framingTime: number;
  99017. /**
  99018. * Define if the behavior should automatically change the configured
  99019. * camera limits and sensibilities.
  99020. */
  99021. autoCorrectCameraLimitsAndSensibility: boolean;
  99022. private _onPrePointerObservableObserver;
  99023. private _onAfterCheckInputsObserver;
  99024. private _onMeshTargetChangedObserver;
  99025. private _attachedCamera;
  99026. private _isPointerDown;
  99027. private _lastInteractionTime;
  99028. /**
  99029. * Initializes the behavior.
  99030. */
  99031. init(): void;
  99032. /**
  99033. * Attaches the behavior to its arc rotate camera.
  99034. * @param camera Defines the camera to attach the behavior to
  99035. */
  99036. attach(camera: ArcRotateCamera): void;
  99037. /**
  99038. * Detaches the behavior from its current arc rotate camera.
  99039. */
  99040. detach(): void;
  99041. private _animatables;
  99042. private _betaIsAnimating;
  99043. private _betaTransition;
  99044. private _radiusTransition;
  99045. private _vectorTransition;
  99046. /**
  99047. * Targets the given mesh and updates zoom level accordingly.
  99048. * @param mesh The mesh to target.
  99049. * @param radius Optional. If a cached radius position already exists, overrides default.
  99050. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99051. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99052. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99053. */
  99054. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99055. /**
  99056. * Targets the given mesh with its children and updates zoom level accordingly.
  99057. * @param mesh The mesh to target.
  99058. * @param radius Optional. If a cached radius position already exists, overrides default.
  99059. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99060. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99061. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99062. */
  99063. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99064. /**
  99065. * Targets the given meshes with their children and updates zoom level accordingly.
  99066. * @param meshes The mesh to target.
  99067. * @param radius Optional. If a cached radius position already exists, overrides default.
  99068. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99069. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99070. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99071. */
  99072. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99073. /**
  99074. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  99075. * @param minimumWorld Determines the smaller position of the bounding box extend
  99076. * @param maximumWorld Determines the bigger position of the bounding box extend
  99077. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99078. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99079. */
  99080. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99081. /**
  99082. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  99083. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  99084. * frustum width.
  99085. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  99086. * to fully enclose the mesh in the viewing frustum.
  99087. */
  99088. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  99089. /**
  99090. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  99091. * is automatically returned to its default position (expected to be above ground plane).
  99092. */
  99093. private _maintainCameraAboveGround;
  99094. /**
  99095. * Returns the frustum slope based on the canvas ratio and camera FOV
  99096. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  99097. */
  99098. private _getFrustumSlope;
  99099. /**
  99100. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  99101. */
  99102. private _clearAnimationLocks;
  99103. /**
  99104. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99105. */
  99106. private _applyUserInteraction;
  99107. /**
  99108. * Stops and removes all animations that have been applied to the camera
  99109. */
  99110. stopAllAnimations(): void;
  99111. /**
  99112. * Gets a value indicating if the user is moving the camera
  99113. */
  99114. readonly isUserIsMoving: boolean;
  99115. /**
  99116. * The camera can move all the way towards the mesh.
  99117. */
  99118. static IgnoreBoundsSizeMode: number;
  99119. /**
  99120. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  99121. */
  99122. static FitFrustumSidesMode: number;
  99123. }
  99124. }
  99125. declare module BABYLON {
  99126. /**
  99127. * Base class for Camera Pointer Inputs.
  99128. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  99129. * for example usage.
  99130. */
  99131. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  99132. /**
  99133. * Defines the camera the input is attached to.
  99134. */
  99135. abstract camera: Camera;
  99136. /**
  99137. * Whether keyboard modifier keys are pressed at time of last mouse event.
  99138. */
  99139. protected _altKey: boolean;
  99140. protected _ctrlKey: boolean;
  99141. protected _metaKey: boolean;
  99142. protected _shiftKey: boolean;
  99143. /**
  99144. * Which mouse buttons were pressed at time of last mouse event.
  99145. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  99146. */
  99147. protected _buttonsPressed: number;
  99148. /**
  99149. * Defines the buttons associated with the input to handle camera move.
  99150. */
  99151. buttons: number[];
  99152. /**
  99153. * Attach the input controls to a specific dom element to get the input from.
  99154. * @param element Defines the element the controls should be listened from
  99155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99156. */
  99157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99158. /**
  99159. * Detach the current controls from the specified dom element.
  99160. * @param element Defines the element to stop listening the inputs from
  99161. */
  99162. detachControl(element: Nullable<HTMLElement>): void;
  99163. /**
  99164. * Gets the class name of the current input.
  99165. * @returns the class name
  99166. */
  99167. getClassName(): string;
  99168. /**
  99169. * Get the friendly name associated with the input class.
  99170. * @returns the input friendly name
  99171. */
  99172. getSimpleName(): string;
  99173. /**
  99174. * Called on pointer POINTERDOUBLETAP event.
  99175. * Override this method to provide functionality on POINTERDOUBLETAP event.
  99176. */
  99177. protected onDoubleTap(type: string): void;
  99178. /**
  99179. * Called on pointer POINTERMOVE event if only a single touch is active.
  99180. * Override this method to provide functionality.
  99181. */
  99182. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99183. /**
  99184. * Called on pointer POINTERMOVE event if multiple touches are active.
  99185. * Override this method to provide functionality.
  99186. */
  99187. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99188. /**
  99189. * Called on JS contextmenu event.
  99190. * Override this method to provide functionality.
  99191. */
  99192. protected onContextMenu(evt: PointerEvent): void;
  99193. /**
  99194. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99195. * press.
  99196. * Override this method to provide functionality.
  99197. */
  99198. protected onButtonDown(evt: PointerEvent): void;
  99199. /**
  99200. * Called each time a new POINTERUP event occurs. Ie, for each button
  99201. * release.
  99202. * Override this method to provide functionality.
  99203. */
  99204. protected onButtonUp(evt: PointerEvent): void;
  99205. /**
  99206. * Called when window becomes inactive.
  99207. * Override this method to provide functionality.
  99208. */
  99209. protected onLostFocus(): void;
  99210. private _pointerInput;
  99211. private _observer;
  99212. private _onLostFocus;
  99213. private pointA;
  99214. private pointB;
  99215. }
  99216. }
  99217. declare module BABYLON {
  99218. /**
  99219. * Manage the pointers inputs to control an arc rotate camera.
  99220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99221. */
  99222. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  99223. /**
  99224. * Defines the camera the input is attached to.
  99225. */
  99226. camera: ArcRotateCamera;
  99227. /**
  99228. * Gets the class name of the current input.
  99229. * @returns the class name
  99230. */
  99231. getClassName(): string;
  99232. /**
  99233. * Defines the buttons associated with the input to handle camera move.
  99234. */
  99235. buttons: number[];
  99236. /**
  99237. * Defines the pointer angular sensibility along the X axis or how fast is
  99238. * the camera rotating.
  99239. */
  99240. angularSensibilityX: number;
  99241. /**
  99242. * Defines the pointer angular sensibility along the Y axis or how fast is
  99243. * the camera rotating.
  99244. */
  99245. angularSensibilityY: number;
  99246. /**
  99247. * Defines the pointer pinch precision or how fast is the camera zooming.
  99248. */
  99249. pinchPrecision: number;
  99250. /**
  99251. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99252. * from 0.
  99253. * It defines the percentage of current camera.radius to use as delta when
  99254. * pinch zoom is used.
  99255. */
  99256. pinchDeltaPercentage: number;
  99257. /**
  99258. * Defines the pointer panning sensibility or how fast is the camera moving.
  99259. */
  99260. panningSensibility: number;
  99261. /**
  99262. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  99263. */
  99264. multiTouchPanning: boolean;
  99265. /**
  99266. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  99267. * zoom (pinch) through multitouch.
  99268. */
  99269. multiTouchPanAndZoom: boolean;
  99270. /**
  99271. * Revers pinch action direction.
  99272. */
  99273. pinchInwards: boolean;
  99274. private _isPanClick;
  99275. private _twoFingerActivityCount;
  99276. private _isPinching;
  99277. /**
  99278. * Called on pointer POINTERMOVE event if only a single touch is active.
  99279. */
  99280. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99281. /**
  99282. * Called on pointer POINTERDOUBLETAP event.
  99283. */
  99284. protected onDoubleTap(type: string): void;
  99285. /**
  99286. * Called on pointer POINTERMOVE event if multiple touches are active.
  99287. */
  99288. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99289. /**
  99290. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99291. * press.
  99292. */
  99293. protected onButtonDown(evt: PointerEvent): void;
  99294. /**
  99295. * Called each time a new POINTERUP event occurs. Ie, for each button
  99296. * release.
  99297. */
  99298. protected onButtonUp(evt: PointerEvent): void;
  99299. /**
  99300. * Called when window becomes inactive.
  99301. */
  99302. protected onLostFocus(): void;
  99303. }
  99304. }
  99305. declare module BABYLON {
  99306. /**
  99307. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  99308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99309. */
  99310. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  99311. /**
  99312. * Defines the camera the input is attached to.
  99313. */
  99314. camera: ArcRotateCamera;
  99315. /**
  99316. * Defines the list of key codes associated with the up action (increase alpha)
  99317. */
  99318. keysUp: number[];
  99319. /**
  99320. * Defines the list of key codes associated with the down action (decrease alpha)
  99321. */
  99322. keysDown: number[];
  99323. /**
  99324. * Defines the list of key codes associated with the left action (increase beta)
  99325. */
  99326. keysLeft: number[];
  99327. /**
  99328. * Defines the list of key codes associated with the right action (decrease beta)
  99329. */
  99330. keysRight: number[];
  99331. /**
  99332. * Defines the list of key codes associated with the reset action.
  99333. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  99334. */
  99335. keysReset: number[];
  99336. /**
  99337. * Defines the panning sensibility of the inputs.
  99338. * (How fast is the camera paning)
  99339. */
  99340. panningSensibility: number;
  99341. /**
  99342. * Defines the zooming sensibility of the inputs.
  99343. * (How fast is the camera zooming)
  99344. */
  99345. zoomingSensibility: number;
  99346. /**
  99347. * Defines wether maintaining the alt key down switch the movement mode from
  99348. * orientation to zoom.
  99349. */
  99350. useAltToZoom: boolean;
  99351. /**
  99352. * Rotation speed of the camera
  99353. */
  99354. angularSpeed: number;
  99355. private _keys;
  99356. private _ctrlPressed;
  99357. private _altPressed;
  99358. private _onCanvasBlurObserver;
  99359. private _onKeyboardObserver;
  99360. private _engine;
  99361. private _scene;
  99362. /**
  99363. * Attach the input controls to a specific dom element to get the input from.
  99364. * @param element Defines the element the controls should be listened from
  99365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99366. */
  99367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99368. /**
  99369. * Detach the current controls from the specified dom element.
  99370. * @param element Defines the element to stop listening the inputs from
  99371. */
  99372. detachControl(element: Nullable<HTMLElement>): void;
  99373. /**
  99374. * Update the current camera state depending on the inputs that have been used this frame.
  99375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99376. */
  99377. checkInputs(): void;
  99378. /**
  99379. * Gets the class name of the current intput.
  99380. * @returns the class name
  99381. */
  99382. getClassName(): string;
  99383. /**
  99384. * Get the friendly name associated with the input class.
  99385. * @returns the input friendly name
  99386. */
  99387. getSimpleName(): string;
  99388. }
  99389. }
  99390. declare module BABYLON {
  99391. /**
  99392. * Manage the mouse wheel inputs to control an arc rotate camera.
  99393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99394. */
  99395. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  99396. /**
  99397. * Defines the camera the input is attached to.
  99398. */
  99399. camera: ArcRotateCamera;
  99400. /**
  99401. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99402. */
  99403. wheelPrecision: number;
  99404. /**
  99405. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99406. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99407. */
  99408. wheelDeltaPercentage: number;
  99409. private _wheel;
  99410. private _observer;
  99411. private computeDeltaFromMouseWheelLegacyEvent;
  99412. /**
  99413. * Attach the input controls to a specific dom element to get the input from.
  99414. * @param element Defines the element the controls should be listened from
  99415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99416. */
  99417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99418. /**
  99419. * Detach the current controls from the specified dom element.
  99420. * @param element Defines the element to stop listening the inputs from
  99421. */
  99422. detachControl(element: Nullable<HTMLElement>): void;
  99423. /**
  99424. * Gets the class name of the current intput.
  99425. * @returns the class name
  99426. */
  99427. getClassName(): string;
  99428. /**
  99429. * Get the friendly name associated with the input class.
  99430. * @returns the input friendly name
  99431. */
  99432. getSimpleName(): string;
  99433. }
  99434. }
  99435. declare module BABYLON {
  99436. /**
  99437. * Default Inputs manager for the ArcRotateCamera.
  99438. * It groups all the default supported inputs for ease of use.
  99439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99440. */
  99441. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  99442. /**
  99443. * Instantiates a new ArcRotateCameraInputsManager.
  99444. * @param camera Defines the camera the inputs belong to
  99445. */
  99446. constructor(camera: ArcRotateCamera);
  99447. /**
  99448. * Add mouse wheel input support to the input manager.
  99449. * @returns the current input manager
  99450. */
  99451. addMouseWheel(): ArcRotateCameraInputsManager;
  99452. /**
  99453. * Add pointers input support to the input manager.
  99454. * @returns the current input manager
  99455. */
  99456. addPointers(): ArcRotateCameraInputsManager;
  99457. /**
  99458. * Add keyboard input support to the input manager.
  99459. * @returns the current input manager
  99460. */
  99461. addKeyboard(): ArcRotateCameraInputsManager;
  99462. }
  99463. }
  99464. declare module BABYLON {
  99465. /**
  99466. * This represents an orbital type of camera.
  99467. *
  99468. * 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.
  99469. * 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.
  99470. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  99471. */
  99472. export class ArcRotateCamera extends TargetCamera {
  99473. /**
  99474. * Defines the rotation angle of the camera along the longitudinal axis.
  99475. */
  99476. alpha: number;
  99477. /**
  99478. * Defines the rotation angle of the camera along the latitudinal axis.
  99479. */
  99480. beta: number;
  99481. /**
  99482. * Defines the radius of the camera from it s target point.
  99483. */
  99484. radius: number;
  99485. protected _target: Vector3;
  99486. protected _targetHost: Nullable<AbstractMesh>;
  99487. /**
  99488. * Defines the target point of the camera.
  99489. * The camera looks towards it form the radius distance.
  99490. */
  99491. target: Vector3;
  99492. /**
  99493. * Define the current local position of the camera in the scene
  99494. */
  99495. position: Vector3;
  99496. protected _upVector: Vector3;
  99497. protected _upToYMatrix: Matrix;
  99498. protected _YToUpMatrix: Matrix;
  99499. /**
  99500. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  99501. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  99502. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  99503. */
  99504. upVector: Vector3;
  99505. /**
  99506. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  99507. */
  99508. setMatUp(): void;
  99509. /**
  99510. * Current inertia value on the longitudinal axis.
  99511. * The bigger this number the longer it will take for the camera to stop.
  99512. */
  99513. inertialAlphaOffset: number;
  99514. /**
  99515. * Current inertia value on the latitudinal axis.
  99516. * The bigger this number the longer it will take for the camera to stop.
  99517. */
  99518. inertialBetaOffset: number;
  99519. /**
  99520. * Current inertia value on the radius axis.
  99521. * The bigger this number the longer it will take for the camera to stop.
  99522. */
  99523. inertialRadiusOffset: number;
  99524. /**
  99525. * Minimum allowed angle on the longitudinal axis.
  99526. * This can help limiting how the Camera is able to move in the scene.
  99527. */
  99528. lowerAlphaLimit: Nullable<number>;
  99529. /**
  99530. * Maximum allowed angle on the longitudinal axis.
  99531. * This can help limiting how the Camera is able to move in the scene.
  99532. */
  99533. upperAlphaLimit: Nullable<number>;
  99534. /**
  99535. * Minimum allowed angle on the latitudinal axis.
  99536. * This can help limiting how the Camera is able to move in the scene.
  99537. */
  99538. lowerBetaLimit: number;
  99539. /**
  99540. * Maximum allowed angle on the latitudinal axis.
  99541. * This can help limiting how the Camera is able to move in the scene.
  99542. */
  99543. upperBetaLimit: number;
  99544. /**
  99545. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  99546. * This can help limiting how the Camera is able to move in the scene.
  99547. */
  99548. lowerRadiusLimit: Nullable<number>;
  99549. /**
  99550. * Maximum allowed distance of the camera to the target (The camera can not get further).
  99551. * This can help limiting how the Camera is able to move in the scene.
  99552. */
  99553. upperRadiusLimit: Nullable<number>;
  99554. /**
  99555. * Defines the current inertia value used during panning of the camera along the X axis.
  99556. */
  99557. inertialPanningX: number;
  99558. /**
  99559. * Defines the current inertia value used during panning of the camera along the Y axis.
  99560. */
  99561. inertialPanningY: number;
  99562. /**
  99563. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  99564. * Basically if your fingers moves away from more than this distance you will be considered
  99565. * in pinch mode.
  99566. */
  99567. pinchToPanMaxDistance: number;
  99568. /**
  99569. * Defines the maximum distance the camera can pan.
  99570. * This could help keeping the cammera always in your scene.
  99571. */
  99572. panningDistanceLimit: Nullable<number>;
  99573. /**
  99574. * Defines the target of the camera before paning.
  99575. */
  99576. panningOriginTarget: Vector3;
  99577. /**
  99578. * Defines the value of the inertia used during panning.
  99579. * 0 would mean stop inertia and one would mean no decelleration at all.
  99580. */
  99581. panningInertia: number;
  99582. /**
  99583. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  99584. */
  99585. angularSensibilityX: number;
  99586. /**
  99587. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  99588. */
  99589. angularSensibilityY: number;
  99590. /**
  99591. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  99592. */
  99593. pinchPrecision: number;
  99594. /**
  99595. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  99596. * It will be used instead of pinchDeltaPrecision if different from 0.
  99597. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99598. */
  99599. pinchDeltaPercentage: number;
  99600. /**
  99601. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  99602. */
  99603. panningSensibility: number;
  99604. /**
  99605. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  99606. */
  99607. keysUp: number[];
  99608. /**
  99609. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  99610. */
  99611. keysDown: number[];
  99612. /**
  99613. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  99614. */
  99615. keysLeft: number[];
  99616. /**
  99617. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  99618. */
  99619. keysRight: number[];
  99620. /**
  99621. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99622. */
  99623. wheelPrecision: number;
  99624. /**
  99625. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  99626. * It will be used instead of pinchDeltaPrecision if different from 0.
  99627. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99628. */
  99629. wheelDeltaPercentage: number;
  99630. /**
  99631. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  99632. */
  99633. zoomOnFactor: number;
  99634. /**
  99635. * Defines a screen offset for the camera position.
  99636. */
  99637. targetScreenOffset: Vector2;
  99638. /**
  99639. * Allows the camera to be completely reversed.
  99640. * If false the camera can not arrive upside down.
  99641. */
  99642. allowUpsideDown: boolean;
  99643. /**
  99644. * Define if double tap/click is used to restore the previously saved state of the camera.
  99645. */
  99646. useInputToRestoreState: boolean;
  99647. /** @hidden */
  99648. _viewMatrix: Matrix;
  99649. /** @hidden */
  99650. _useCtrlForPanning: boolean;
  99651. /** @hidden */
  99652. _panningMouseButton: number;
  99653. /**
  99654. * Defines the input associated to the camera.
  99655. */
  99656. inputs: ArcRotateCameraInputsManager;
  99657. /** @hidden */
  99658. _reset: () => void;
  99659. /**
  99660. * Defines the allowed panning axis.
  99661. */
  99662. panningAxis: Vector3;
  99663. protected _localDirection: Vector3;
  99664. protected _transformedDirection: Vector3;
  99665. private _bouncingBehavior;
  99666. /**
  99667. * Gets the bouncing behavior of the camera if it has been enabled.
  99668. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99669. */
  99670. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  99671. /**
  99672. * Defines if the bouncing behavior of the camera is enabled on the camera.
  99673. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99674. */
  99675. useBouncingBehavior: boolean;
  99676. private _framingBehavior;
  99677. /**
  99678. * Gets the framing behavior of the camera if it has been enabled.
  99679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99680. */
  99681. readonly framingBehavior: Nullable<FramingBehavior>;
  99682. /**
  99683. * Defines if the framing behavior of the camera is enabled on the camera.
  99684. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99685. */
  99686. useFramingBehavior: boolean;
  99687. private _autoRotationBehavior;
  99688. /**
  99689. * Gets the auto rotation behavior of the camera if it has been enabled.
  99690. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99691. */
  99692. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  99693. /**
  99694. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  99695. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99696. */
  99697. useAutoRotationBehavior: boolean;
  99698. /**
  99699. * Observable triggered when the mesh target has been changed on the camera.
  99700. */
  99701. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  99702. /**
  99703. * Event raised when the camera is colliding with a mesh.
  99704. */
  99705. onCollide: (collidedMesh: AbstractMesh) => void;
  99706. /**
  99707. * Defines whether the camera should check collision with the objects oh the scene.
  99708. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  99709. */
  99710. checkCollisions: boolean;
  99711. /**
  99712. * Defines the collision radius of the camera.
  99713. * This simulates a sphere around the camera.
  99714. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99715. */
  99716. collisionRadius: Vector3;
  99717. protected _collider: Collider;
  99718. protected _previousPosition: Vector3;
  99719. protected _collisionVelocity: Vector3;
  99720. protected _newPosition: Vector3;
  99721. protected _previousAlpha: number;
  99722. protected _previousBeta: number;
  99723. protected _previousRadius: number;
  99724. protected _collisionTriggered: boolean;
  99725. protected _targetBoundingCenter: Nullable<Vector3>;
  99726. private _computationVector;
  99727. /**
  99728. * Instantiates a new ArcRotateCamera in a given scene
  99729. * @param name Defines the name of the camera
  99730. * @param alpha Defines the camera rotation along the logitudinal axis
  99731. * @param beta Defines the camera rotation along the latitudinal axis
  99732. * @param radius Defines the camera distance from its target
  99733. * @param target Defines the camera target
  99734. * @param scene Defines the scene the camera belongs to
  99735. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99736. */
  99737. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99738. /** @hidden */
  99739. _initCache(): void;
  99740. /** @hidden */
  99741. _updateCache(ignoreParentClass?: boolean): void;
  99742. protected _getTargetPosition(): Vector3;
  99743. private _storedAlpha;
  99744. private _storedBeta;
  99745. private _storedRadius;
  99746. private _storedTarget;
  99747. /**
  99748. * Stores the current state of the camera (alpha, beta, radius and target)
  99749. * @returns the camera itself
  99750. */
  99751. storeState(): Camera;
  99752. /**
  99753. * @hidden
  99754. * Restored camera state. You must call storeState() first
  99755. */
  99756. _restoreStateValues(): boolean;
  99757. /** @hidden */
  99758. _isSynchronizedViewMatrix(): boolean;
  99759. /**
  99760. * Attached controls to the current camera.
  99761. * @param element Defines the element the controls should be listened from
  99762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99763. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  99764. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  99765. */
  99766. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  99767. /**
  99768. * Detach the current controls from the camera.
  99769. * The camera will stop reacting to inputs.
  99770. * @param element Defines the element to stop listening the inputs from
  99771. */
  99772. detachControl(element: HTMLElement): void;
  99773. /** @hidden */
  99774. _checkInputs(): void;
  99775. protected _checkLimits(): void;
  99776. /**
  99777. * Rebuilds angles (alpha, beta) and radius from the give position and target
  99778. */
  99779. rebuildAnglesAndRadius(): void;
  99780. /**
  99781. * Use a position to define the current camera related information like aplha, beta and radius
  99782. * @param position Defines the position to set the camera at
  99783. */
  99784. setPosition(position: Vector3): void;
  99785. /**
  99786. * Defines the target the camera should look at.
  99787. * This will automatically adapt alpha beta and radius to fit within the new target.
  99788. * @param target Defines the new target as a Vector or a mesh
  99789. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  99790. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  99791. */
  99792. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  99793. /** @hidden */
  99794. _getViewMatrix(): Matrix;
  99795. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  99796. /**
  99797. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  99798. * @param meshes Defines the mesh to zoom on
  99799. * @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)
  99800. */
  99801. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  99802. /**
  99803. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  99804. * The target will be changed but the radius
  99805. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  99806. * @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)
  99807. */
  99808. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  99809. min: Vector3;
  99810. max: Vector3;
  99811. distance: number;
  99812. }, doNotUpdateMaxZ?: boolean): void;
  99813. /**
  99814. * @override
  99815. * Override Camera.createRigCamera
  99816. */
  99817. createRigCamera(name: string, cameraIndex: number): Camera;
  99818. /**
  99819. * @hidden
  99820. * @override
  99821. * Override Camera._updateRigCameras
  99822. */
  99823. _updateRigCameras(): void;
  99824. /**
  99825. * Destroy the camera and release the current resources hold by it.
  99826. */
  99827. dispose(): void;
  99828. /**
  99829. * Gets the current object class name.
  99830. * @return the class name
  99831. */
  99832. getClassName(): string;
  99833. }
  99834. }
  99835. declare module BABYLON {
  99836. /**
  99837. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  99838. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99839. */
  99840. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  99841. /**
  99842. * Gets the name of the behavior.
  99843. */
  99844. readonly name: string;
  99845. private _zoomStopsAnimation;
  99846. private _idleRotationSpeed;
  99847. private _idleRotationWaitTime;
  99848. private _idleRotationSpinupTime;
  99849. /**
  99850. * Sets the flag that indicates if user zooming should stop animation.
  99851. */
  99852. /**
  99853. * Gets the flag that indicates if user zooming should stop animation.
  99854. */
  99855. zoomStopsAnimation: boolean;
  99856. /**
  99857. * Sets the default speed at which the camera rotates around the model.
  99858. */
  99859. /**
  99860. * Gets the default speed at which the camera rotates around the model.
  99861. */
  99862. idleRotationSpeed: number;
  99863. /**
  99864. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  99865. */
  99866. /**
  99867. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  99868. */
  99869. idleRotationWaitTime: number;
  99870. /**
  99871. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  99872. */
  99873. /**
  99874. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  99875. */
  99876. idleRotationSpinupTime: number;
  99877. /**
  99878. * Gets a value indicating if the camera is currently rotating because of this behavior
  99879. */
  99880. readonly rotationInProgress: boolean;
  99881. private _onPrePointerObservableObserver;
  99882. private _onAfterCheckInputsObserver;
  99883. private _attachedCamera;
  99884. private _isPointerDown;
  99885. private _lastFrameTime;
  99886. private _lastInteractionTime;
  99887. private _cameraRotationSpeed;
  99888. /**
  99889. * Initializes the behavior.
  99890. */
  99891. init(): void;
  99892. /**
  99893. * Attaches the behavior to its arc rotate camera.
  99894. * @param camera Defines the camera to attach the behavior to
  99895. */
  99896. attach(camera: ArcRotateCamera): void;
  99897. /**
  99898. * Detaches the behavior from its current arc rotate camera.
  99899. */
  99900. detach(): void;
  99901. /**
  99902. * Returns true if user is scrolling.
  99903. * @return true if user is scrolling.
  99904. */
  99905. private _userIsZooming;
  99906. private _lastFrameRadius;
  99907. private _shouldAnimationStopForInteraction;
  99908. /**
  99909. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99910. */
  99911. private _applyUserInteraction;
  99912. private _userIsMoving;
  99913. }
  99914. }
  99915. declare module BABYLON {
  99916. /**
  99917. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  99918. */
  99919. export class AttachToBoxBehavior implements Behavior<Mesh> {
  99920. private ui;
  99921. /**
  99922. * The name of the behavior
  99923. */
  99924. name: string;
  99925. /**
  99926. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  99927. */
  99928. distanceAwayFromFace: number;
  99929. /**
  99930. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  99931. */
  99932. distanceAwayFromBottomOfFace: number;
  99933. private _faceVectors;
  99934. private _target;
  99935. private _scene;
  99936. private _onRenderObserver;
  99937. private _tmpMatrix;
  99938. private _tmpVector;
  99939. /**
  99940. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  99941. * @param ui The transform node that should be attched to the mesh
  99942. */
  99943. constructor(ui: TransformNode);
  99944. /**
  99945. * Initializes the behavior
  99946. */
  99947. init(): void;
  99948. private _closestFace;
  99949. private _zeroVector;
  99950. private _lookAtTmpMatrix;
  99951. private _lookAtToRef;
  99952. /**
  99953. * Attaches the AttachToBoxBehavior to the passed in mesh
  99954. * @param target The mesh that the specified node will be attached to
  99955. */
  99956. attach(target: Mesh): void;
  99957. /**
  99958. * Detaches the behavior from the mesh
  99959. */
  99960. detach(): void;
  99961. }
  99962. }
  99963. declare module BABYLON {
  99964. /**
  99965. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  99966. */
  99967. export class FadeInOutBehavior implements Behavior<Mesh> {
  99968. /**
  99969. * Time in milliseconds to delay before fading in (Default: 0)
  99970. */
  99971. delay: number;
  99972. /**
  99973. * Time in milliseconds for the mesh to fade in (Default: 300)
  99974. */
  99975. fadeInTime: number;
  99976. private _millisecondsPerFrame;
  99977. private _hovered;
  99978. private _hoverValue;
  99979. private _ownerNode;
  99980. /**
  99981. * Instatiates the FadeInOutBehavior
  99982. */
  99983. constructor();
  99984. /**
  99985. * The name of the behavior
  99986. */
  99987. readonly name: string;
  99988. /**
  99989. * Initializes the behavior
  99990. */
  99991. init(): void;
  99992. /**
  99993. * Attaches the fade behavior on the passed in mesh
  99994. * @param ownerNode The mesh that will be faded in/out once attached
  99995. */
  99996. attach(ownerNode: Mesh): void;
  99997. /**
  99998. * Detaches the behavior from the mesh
  99999. */
  100000. detach(): void;
  100001. /**
  100002. * Triggers the mesh to begin fading in or out
  100003. * @param value if the object should fade in or out (true to fade in)
  100004. */
  100005. fadeIn(value: boolean): void;
  100006. private _update;
  100007. private _setAllVisibility;
  100008. }
  100009. }
  100010. declare module BABYLON {
  100011. /**
  100012. * Class containing a set of static utilities functions for managing Pivots
  100013. * @hidden
  100014. */
  100015. export class PivotTools {
  100016. private static _PivotCached;
  100017. private static _OldPivotPoint;
  100018. private static _PivotTranslation;
  100019. private static _PivotTmpVector;
  100020. /** @hidden */
  100021. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  100022. /** @hidden */
  100023. static _RestorePivotPoint(mesh: AbstractMesh): void;
  100024. }
  100025. }
  100026. declare module BABYLON {
  100027. /**
  100028. * Class containing static functions to help procedurally build meshes
  100029. */
  100030. export class PlaneBuilder {
  100031. /**
  100032. * Creates a plane mesh
  100033. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  100034. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  100035. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  100036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100039. * @param name defines the name of the mesh
  100040. * @param options defines the options used to create the mesh
  100041. * @param scene defines the hosting scene
  100042. * @returns the plane mesh
  100043. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  100044. */
  100045. static CreatePlane(name: string, options: {
  100046. size?: number;
  100047. width?: number;
  100048. height?: number;
  100049. sideOrientation?: number;
  100050. frontUVs?: Vector4;
  100051. backUVs?: Vector4;
  100052. updatable?: boolean;
  100053. sourcePlane?: Plane;
  100054. }, scene?: Nullable<Scene>): Mesh;
  100055. }
  100056. }
  100057. declare module BABYLON {
  100058. /**
  100059. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  100060. */
  100061. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  100062. private static _AnyMouseID;
  100063. /**
  100064. * Abstract mesh the behavior is set on
  100065. */
  100066. attachedNode: AbstractMesh;
  100067. private _dragPlane;
  100068. private _scene;
  100069. private _pointerObserver;
  100070. private _beforeRenderObserver;
  100071. private static _planeScene;
  100072. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  100073. /**
  100074. * 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)
  100075. */
  100076. maxDragAngle: number;
  100077. /**
  100078. * @hidden
  100079. */
  100080. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  100081. /**
  100082. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100083. */
  100084. currentDraggingPointerID: number;
  100085. /**
  100086. * The last position where the pointer hit the drag plane in world space
  100087. */
  100088. lastDragPosition: Vector3;
  100089. /**
  100090. * If the behavior is currently in a dragging state
  100091. */
  100092. dragging: boolean;
  100093. /**
  100094. * 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)
  100095. */
  100096. dragDeltaRatio: number;
  100097. /**
  100098. * If the drag plane orientation should be updated during the dragging (Default: true)
  100099. */
  100100. updateDragPlane: boolean;
  100101. private _debugMode;
  100102. private _moving;
  100103. /**
  100104. * Fires each time the attached mesh is dragged with the pointer
  100105. * * delta between last drag position and current drag position in world space
  100106. * * dragDistance along the drag axis
  100107. * * dragPlaneNormal normal of the current drag plane used during the drag
  100108. * * dragPlanePoint in world space where the drag intersects the drag plane
  100109. */
  100110. onDragObservable: Observable<{
  100111. delta: Vector3;
  100112. dragPlanePoint: Vector3;
  100113. dragPlaneNormal: Vector3;
  100114. dragDistance: number;
  100115. pointerId: number;
  100116. }>;
  100117. /**
  100118. * Fires each time a drag begins (eg. mouse down on mesh)
  100119. */
  100120. onDragStartObservable: Observable<{
  100121. dragPlanePoint: Vector3;
  100122. pointerId: number;
  100123. }>;
  100124. /**
  100125. * Fires each time a drag ends (eg. mouse release after drag)
  100126. */
  100127. onDragEndObservable: Observable<{
  100128. dragPlanePoint: Vector3;
  100129. pointerId: number;
  100130. }>;
  100131. /**
  100132. * If the attached mesh should be moved when dragged
  100133. */
  100134. moveAttached: boolean;
  100135. /**
  100136. * If the drag behavior will react to drag events (Default: true)
  100137. */
  100138. enabled: boolean;
  100139. /**
  100140. * If pointer events should start and release the drag (Default: true)
  100141. */
  100142. startAndReleaseDragOnPointerEvents: boolean;
  100143. /**
  100144. * If camera controls should be detached during the drag
  100145. */
  100146. detachCameraControls: boolean;
  100147. /**
  100148. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  100149. */
  100150. useObjectOrienationForDragging: boolean;
  100151. private _options;
  100152. /**
  100153. * Creates a pointer drag behavior that can be attached to a mesh
  100154. * @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)
  100155. */
  100156. constructor(options?: {
  100157. dragAxis?: Vector3;
  100158. dragPlaneNormal?: Vector3;
  100159. });
  100160. /**
  100161. * Predicate to determine if it is valid to move the object to a new position when it is moved
  100162. */
  100163. validateDrag: (targetPosition: Vector3) => boolean;
  100164. /**
  100165. * The name of the behavior
  100166. */
  100167. readonly name: string;
  100168. /**
  100169. * Initializes the behavior
  100170. */
  100171. init(): void;
  100172. private _tmpVector;
  100173. private _alternatePickedPoint;
  100174. private _worldDragAxis;
  100175. private _targetPosition;
  100176. private _attachedElement;
  100177. /**
  100178. * Attaches the drag behavior the passed in mesh
  100179. * @param ownerNode The mesh that will be dragged around once attached
  100180. */
  100181. attach(ownerNode: AbstractMesh): void;
  100182. /**
  100183. * Force relase the drag action by code.
  100184. */
  100185. releaseDrag(): void;
  100186. private _startDragRay;
  100187. private _lastPointerRay;
  100188. /**
  100189. * Simulates the start of a pointer drag event on the behavior
  100190. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  100191. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  100192. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  100193. */
  100194. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  100195. private _startDrag;
  100196. private _dragDelta;
  100197. private _moveDrag;
  100198. private _pickWithRayOnDragPlane;
  100199. private _pointA;
  100200. private _pointB;
  100201. private _pointC;
  100202. private _lineA;
  100203. private _lineB;
  100204. private _localAxis;
  100205. private _lookAt;
  100206. private _updateDragPlanePosition;
  100207. /**
  100208. * Detaches the behavior from the mesh
  100209. */
  100210. detach(): void;
  100211. }
  100212. }
  100213. declare module BABYLON {
  100214. /**
  100215. * A behavior that when attached to a mesh will allow the mesh to be scaled
  100216. */
  100217. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  100218. private _dragBehaviorA;
  100219. private _dragBehaviorB;
  100220. private _startDistance;
  100221. private _initialScale;
  100222. private _targetScale;
  100223. private _ownerNode;
  100224. private _sceneRenderObserver;
  100225. /**
  100226. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  100227. */
  100228. constructor();
  100229. /**
  100230. * The name of the behavior
  100231. */
  100232. readonly name: string;
  100233. /**
  100234. * Initializes the behavior
  100235. */
  100236. init(): void;
  100237. private _getCurrentDistance;
  100238. /**
  100239. * Attaches the scale behavior the passed in mesh
  100240. * @param ownerNode The mesh that will be scaled around once attached
  100241. */
  100242. attach(ownerNode: Mesh): void;
  100243. /**
  100244. * Detaches the behavior from the mesh
  100245. */
  100246. detach(): void;
  100247. }
  100248. }
  100249. declare module BABYLON {
  100250. /**
  100251. * 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
  100252. */
  100253. export class SixDofDragBehavior implements Behavior<Mesh> {
  100254. private static _virtualScene;
  100255. private _ownerNode;
  100256. private _sceneRenderObserver;
  100257. private _scene;
  100258. private _targetPosition;
  100259. private _virtualOriginMesh;
  100260. private _virtualDragMesh;
  100261. private _pointerObserver;
  100262. private _moving;
  100263. private _startingOrientation;
  100264. /**
  100265. * 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)
  100266. */
  100267. private zDragFactor;
  100268. /**
  100269. * If the object should rotate to face the drag origin
  100270. */
  100271. rotateDraggedObject: boolean;
  100272. /**
  100273. * If the behavior is currently in a dragging state
  100274. */
  100275. dragging: boolean;
  100276. /**
  100277. * 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)
  100278. */
  100279. dragDeltaRatio: number;
  100280. /**
  100281. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100282. */
  100283. currentDraggingPointerID: number;
  100284. /**
  100285. * If camera controls should be detached during the drag
  100286. */
  100287. detachCameraControls: boolean;
  100288. /**
  100289. * Fires each time a drag starts
  100290. */
  100291. onDragStartObservable: Observable<{}>;
  100292. /**
  100293. * Fires each time a drag ends (eg. mouse release after drag)
  100294. */
  100295. onDragEndObservable: Observable<{}>;
  100296. /**
  100297. * 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
  100298. */
  100299. constructor();
  100300. /**
  100301. * The name of the behavior
  100302. */
  100303. readonly name: string;
  100304. /**
  100305. * Initializes the behavior
  100306. */
  100307. init(): void;
  100308. /**
  100309. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  100310. */
  100311. private readonly _pointerCamera;
  100312. /**
  100313. * Attaches the scale behavior the passed in mesh
  100314. * @param ownerNode The mesh that will be scaled around once attached
  100315. */
  100316. attach(ownerNode: Mesh): void;
  100317. /**
  100318. * Detaches the behavior from the mesh
  100319. */
  100320. detach(): void;
  100321. }
  100322. }
  100323. declare module BABYLON {
  100324. /**
  100325. * Class used to apply inverse kinematics to bones
  100326. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  100327. */
  100328. export class BoneIKController {
  100329. private static _tmpVecs;
  100330. private static _tmpQuat;
  100331. private static _tmpMats;
  100332. /**
  100333. * Gets or sets the target mesh
  100334. */
  100335. targetMesh: AbstractMesh;
  100336. /** Gets or sets the mesh used as pole */
  100337. poleTargetMesh: AbstractMesh;
  100338. /**
  100339. * Gets or sets the bone used as pole
  100340. */
  100341. poleTargetBone: Nullable<Bone>;
  100342. /**
  100343. * Gets or sets the target position
  100344. */
  100345. targetPosition: Vector3;
  100346. /**
  100347. * Gets or sets the pole target position
  100348. */
  100349. poleTargetPosition: Vector3;
  100350. /**
  100351. * Gets or sets the pole target local offset
  100352. */
  100353. poleTargetLocalOffset: Vector3;
  100354. /**
  100355. * Gets or sets the pole angle
  100356. */
  100357. poleAngle: number;
  100358. /**
  100359. * Gets or sets the mesh associated with the controller
  100360. */
  100361. mesh: AbstractMesh;
  100362. /**
  100363. * 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)
  100364. */
  100365. slerpAmount: number;
  100366. private _bone1Quat;
  100367. private _bone1Mat;
  100368. private _bone2Ang;
  100369. private _bone1;
  100370. private _bone2;
  100371. private _bone1Length;
  100372. private _bone2Length;
  100373. private _maxAngle;
  100374. private _maxReach;
  100375. private _rightHandedSystem;
  100376. private _bendAxis;
  100377. private _slerping;
  100378. private _adjustRoll;
  100379. /**
  100380. * Gets or sets maximum allowed angle
  100381. */
  100382. maxAngle: number;
  100383. /**
  100384. * Creates a new BoneIKController
  100385. * @param mesh defines the mesh to control
  100386. * @param bone defines the bone to control
  100387. * @param options defines options to set up the controller
  100388. */
  100389. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  100390. targetMesh?: AbstractMesh;
  100391. poleTargetMesh?: AbstractMesh;
  100392. poleTargetBone?: Bone;
  100393. poleTargetLocalOffset?: Vector3;
  100394. poleAngle?: number;
  100395. bendAxis?: Vector3;
  100396. maxAngle?: number;
  100397. slerpAmount?: number;
  100398. });
  100399. private _setMaxAngle;
  100400. /**
  100401. * Force the controller to update the bones
  100402. */
  100403. update(): void;
  100404. }
  100405. }
  100406. declare module BABYLON {
  100407. /**
  100408. * Class used to make a bone look toward a point in space
  100409. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  100410. */
  100411. export class BoneLookController {
  100412. private static _tmpVecs;
  100413. private static _tmpQuat;
  100414. private static _tmpMats;
  100415. /**
  100416. * The target Vector3 that the bone will look at
  100417. */
  100418. target: Vector3;
  100419. /**
  100420. * The mesh that the bone is attached to
  100421. */
  100422. mesh: AbstractMesh;
  100423. /**
  100424. * The bone that will be looking to the target
  100425. */
  100426. bone: Bone;
  100427. /**
  100428. * The up axis of the coordinate system that is used when the bone is rotated
  100429. */
  100430. upAxis: Vector3;
  100431. /**
  100432. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  100433. */
  100434. upAxisSpace: Space;
  100435. /**
  100436. * Used to make an adjustment to the yaw of the bone
  100437. */
  100438. adjustYaw: number;
  100439. /**
  100440. * Used to make an adjustment to the pitch of the bone
  100441. */
  100442. adjustPitch: number;
  100443. /**
  100444. * Used to make an adjustment to the roll of the bone
  100445. */
  100446. adjustRoll: number;
  100447. /**
  100448. * 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)
  100449. */
  100450. slerpAmount: number;
  100451. private _minYaw;
  100452. private _maxYaw;
  100453. private _minPitch;
  100454. private _maxPitch;
  100455. private _minYawSin;
  100456. private _minYawCos;
  100457. private _maxYawSin;
  100458. private _maxYawCos;
  100459. private _midYawConstraint;
  100460. private _minPitchTan;
  100461. private _maxPitchTan;
  100462. private _boneQuat;
  100463. private _slerping;
  100464. private _transformYawPitch;
  100465. private _transformYawPitchInv;
  100466. private _firstFrameSkipped;
  100467. private _yawRange;
  100468. private _fowardAxis;
  100469. /**
  100470. * Gets or sets the minimum yaw angle that the bone can look to
  100471. */
  100472. minYaw: number;
  100473. /**
  100474. * Gets or sets the maximum yaw angle that the bone can look to
  100475. */
  100476. maxYaw: number;
  100477. /**
  100478. * Gets or sets the minimum pitch angle that the bone can look to
  100479. */
  100480. minPitch: number;
  100481. /**
  100482. * Gets or sets the maximum pitch angle that the bone can look to
  100483. */
  100484. maxPitch: number;
  100485. /**
  100486. * Create a BoneLookController
  100487. * @param mesh the mesh that the bone belongs to
  100488. * @param bone the bone that will be looking to the target
  100489. * @param target the target Vector3 to look at
  100490. * @param options optional settings:
  100491. * * maxYaw: the maximum angle the bone will yaw to
  100492. * * minYaw: the minimum angle the bone will yaw to
  100493. * * maxPitch: the maximum angle the bone will pitch to
  100494. * * minPitch: the minimum angle the bone will yaw to
  100495. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  100496. * * upAxis: the up axis of the coordinate system
  100497. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  100498. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  100499. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  100500. * * adjustYaw: used to make an adjustment to the yaw of the bone
  100501. * * adjustPitch: used to make an adjustment to the pitch of the bone
  100502. * * adjustRoll: used to make an adjustment to the roll of the bone
  100503. **/
  100504. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  100505. maxYaw?: number;
  100506. minYaw?: number;
  100507. maxPitch?: number;
  100508. minPitch?: number;
  100509. slerpAmount?: number;
  100510. upAxis?: Vector3;
  100511. upAxisSpace?: Space;
  100512. yawAxis?: Vector3;
  100513. pitchAxis?: Vector3;
  100514. adjustYaw?: number;
  100515. adjustPitch?: number;
  100516. adjustRoll?: number;
  100517. });
  100518. /**
  100519. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  100520. */
  100521. update(): void;
  100522. private _getAngleDiff;
  100523. private _getAngleBetween;
  100524. private _isAngleBetween;
  100525. }
  100526. }
  100527. declare module BABYLON {
  100528. /**
  100529. * Manage the gamepad inputs to control an arc rotate camera.
  100530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100531. */
  100532. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  100533. /**
  100534. * Defines the camera the input is attached to.
  100535. */
  100536. camera: ArcRotateCamera;
  100537. /**
  100538. * Defines the gamepad the input is gathering event from.
  100539. */
  100540. gamepad: Nullable<Gamepad>;
  100541. /**
  100542. * Defines the gamepad rotation sensiblity.
  100543. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100544. */
  100545. gamepadRotationSensibility: number;
  100546. /**
  100547. * Defines the gamepad move sensiblity.
  100548. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100549. */
  100550. gamepadMoveSensibility: number;
  100551. private _onGamepadConnectedObserver;
  100552. private _onGamepadDisconnectedObserver;
  100553. /**
  100554. * Attach the input controls to a specific dom element to get the input from.
  100555. * @param element Defines the element the controls should be listened from
  100556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100557. */
  100558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100559. /**
  100560. * Detach the current controls from the specified dom element.
  100561. * @param element Defines the element to stop listening the inputs from
  100562. */
  100563. detachControl(element: Nullable<HTMLElement>): void;
  100564. /**
  100565. * Update the current camera state depending on the inputs that have been used this frame.
  100566. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100567. */
  100568. checkInputs(): void;
  100569. /**
  100570. * Gets the class name of the current intput.
  100571. * @returns the class name
  100572. */
  100573. getClassName(): string;
  100574. /**
  100575. * Get the friendly name associated with the input class.
  100576. * @returns the input friendly name
  100577. */
  100578. getSimpleName(): string;
  100579. }
  100580. }
  100581. declare module BABYLON {
  100582. interface ArcRotateCameraInputsManager {
  100583. /**
  100584. * Add orientation input support to the input manager.
  100585. * @returns the current input manager
  100586. */
  100587. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  100588. }
  100589. /**
  100590. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  100591. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100592. */
  100593. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  100594. /**
  100595. * Defines the camera the input is attached to.
  100596. */
  100597. camera: ArcRotateCamera;
  100598. /**
  100599. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  100600. */
  100601. alphaCorrection: number;
  100602. /**
  100603. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  100604. */
  100605. gammaCorrection: number;
  100606. private _alpha;
  100607. private _gamma;
  100608. private _dirty;
  100609. private _deviceOrientationHandler;
  100610. /**
  100611. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  100612. */
  100613. constructor();
  100614. /**
  100615. * Attach the input controls to a specific dom element to get the input from.
  100616. * @param element Defines the element the controls should be listened from
  100617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100618. */
  100619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100620. /** @hidden */
  100621. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  100622. /**
  100623. * Update the current camera state depending on the inputs that have been used this frame.
  100624. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100625. */
  100626. checkInputs(): void;
  100627. /**
  100628. * Detach the current controls from the specified dom element.
  100629. * @param element Defines the element to stop listening the inputs from
  100630. */
  100631. detachControl(element: Nullable<HTMLElement>): void;
  100632. /**
  100633. * Gets the class name of the current intput.
  100634. * @returns the class name
  100635. */
  100636. getClassName(): string;
  100637. /**
  100638. * Get the friendly name associated with the input class.
  100639. * @returns the input friendly name
  100640. */
  100641. getSimpleName(): string;
  100642. }
  100643. }
  100644. declare module BABYLON {
  100645. /**
  100646. * Listen to mouse events to control the camera.
  100647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100648. */
  100649. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  100650. /**
  100651. * Defines the camera the input is attached to.
  100652. */
  100653. camera: FlyCamera;
  100654. /**
  100655. * Defines if touch is enabled. (Default is true.)
  100656. */
  100657. touchEnabled: boolean;
  100658. /**
  100659. * Defines the buttons associated with the input to handle camera rotation.
  100660. */
  100661. buttons: number[];
  100662. /**
  100663. * Assign buttons for Yaw control.
  100664. */
  100665. buttonsYaw: number[];
  100666. /**
  100667. * Assign buttons for Pitch control.
  100668. */
  100669. buttonsPitch: number[];
  100670. /**
  100671. * Assign buttons for Roll control.
  100672. */
  100673. buttonsRoll: number[];
  100674. /**
  100675. * Detect if any button is being pressed while mouse is moved.
  100676. * -1 = Mouse locked.
  100677. * 0 = Left button.
  100678. * 1 = Middle Button.
  100679. * 2 = Right Button.
  100680. */
  100681. activeButton: number;
  100682. /**
  100683. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  100684. * Higher values reduce its sensitivity.
  100685. */
  100686. angularSensibility: number;
  100687. private _mousemoveCallback;
  100688. private _observer;
  100689. private _rollObserver;
  100690. private previousPosition;
  100691. private noPreventDefault;
  100692. private element;
  100693. /**
  100694. * Listen to mouse events to control the camera.
  100695. * @param touchEnabled Define if touch is enabled. (Default is true.)
  100696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100697. */
  100698. constructor(touchEnabled?: boolean);
  100699. /**
  100700. * Attach the mouse control to the HTML DOM element.
  100701. * @param element Defines the element that listens to the input events.
  100702. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  100703. */
  100704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100705. /**
  100706. * Detach the current controls from the specified dom element.
  100707. * @param element Defines the element to stop listening the inputs from
  100708. */
  100709. detachControl(element: Nullable<HTMLElement>): void;
  100710. /**
  100711. * Gets the class name of the current input.
  100712. * @returns the class name.
  100713. */
  100714. getClassName(): string;
  100715. /**
  100716. * Get the friendly name associated with the input class.
  100717. * @returns the input's friendly name.
  100718. */
  100719. getSimpleName(): string;
  100720. private _pointerInput;
  100721. private _onMouseMove;
  100722. /**
  100723. * Rotate camera by mouse offset.
  100724. */
  100725. private rotateCamera;
  100726. }
  100727. }
  100728. declare module BABYLON {
  100729. /**
  100730. * Default Inputs manager for the FlyCamera.
  100731. * It groups all the default supported inputs for ease of use.
  100732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100733. */
  100734. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  100735. /**
  100736. * Instantiates a new FlyCameraInputsManager.
  100737. * @param camera Defines the camera the inputs belong to.
  100738. */
  100739. constructor(camera: FlyCamera);
  100740. /**
  100741. * Add keyboard input support to the input manager.
  100742. * @returns the new FlyCameraKeyboardMoveInput().
  100743. */
  100744. addKeyboard(): FlyCameraInputsManager;
  100745. /**
  100746. * Add mouse input support to the input manager.
  100747. * @param touchEnabled Enable touch screen support.
  100748. * @returns the new FlyCameraMouseInput().
  100749. */
  100750. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  100751. }
  100752. }
  100753. declare module BABYLON {
  100754. /**
  100755. * This is a flying camera, designed for 3D movement and rotation in all directions,
  100756. * such as in a 3D Space Shooter or a Flight Simulator.
  100757. */
  100758. export class FlyCamera extends TargetCamera {
  100759. /**
  100760. * Define the collision ellipsoid of the camera.
  100761. * This is helpful for simulating a camera body, like a player's body.
  100762. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100763. */
  100764. ellipsoid: Vector3;
  100765. /**
  100766. * Define an offset for the position of the ellipsoid around the camera.
  100767. * This can be helpful if the camera is attached away from the player's body center,
  100768. * such as at its head.
  100769. */
  100770. ellipsoidOffset: Vector3;
  100771. /**
  100772. * Enable or disable collisions of the camera with the rest of the scene objects.
  100773. */
  100774. checkCollisions: boolean;
  100775. /**
  100776. * Enable or disable gravity on the camera.
  100777. */
  100778. applyGravity: boolean;
  100779. /**
  100780. * Define the current direction the camera is moving to.
  100781. */
  100782. cameraDirection: Vector3;
  100783. /**
  100784. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  100785. * This overrides and empties cameraRotation.
  100786. */
  100787. rotationQuaternion: Quaternion;
  100788. /**
  100789. * Track Roll to maintain the wanted Rolling when looking around.
  100790. */
  100791. _trackRoll: number;
  100792. /**
  100793. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  100794. */
  100795. rollCorrect: number;
  100796. /**
  100797. * Mimic a banked turn, Rolling the camera when Yawing.
  100798. * It's recommended to use rollCorrect = 10 for faster banking correction.
  100799. */
  100800. bankedTurn: boolean;
  100801. /**
  100802. * Limit in radians for how much Roll banking will add. (Default: 90°)
  100803. */
  100804. bankedTurnLimit: number;
  100805. /**
  100806. * Value of 0 disables the banked Roll.
  100807. * Value of 1 is equal to the Yaw angle in radians.
  100808. */
  100809. bankedTurnMultiplier: number;
  100810. /**
  100811. * The inputs manager loads all the input sources, such as keyboard and mouse.
  100812. */
  100813. inputs: FlyCameraInputsManager;
  100814. /**
  100815. * Gets the input sensibility for mouse input.
  100816. * Higher values reduce sensitivity.
  100817. */
  100818. /**
  100819. * Sets the input sensibility for a mouse input.
  100820. * Higher values reduce sensitivity.
  100821. */
  100822. angularSensibility: number;
  100823. /**
  100824. * Get the keys for camera movement forward.
  100825. */
  100826. /**
  100827. * Set the keys for camera movement forward.
  100828. */
  100829. keysForward: number[];
  100830. /**
  100831. * Get the keys for camera movement backward.
  100832. */
  100833. keysBackward: number[];
  100834. /**
  100835. * Get the keys for camera movement up.
  100836. */
  100837. /**
  100838. * Set the keys for camera movement up.
  100839. */
  100840. keysUp: number[];
  100841. /**
  100842. * Get the keys for camera movement down.
  100843. */
  100844. /**
  100845. * Set the keys for camera movement down.
  100846. */
  100847. keysDown: number[];
  100848. /**
  100849. * Get the keys for camera movement left.
  100850. */
  100851. /**
  100852. * Set the keys for camera movement left.
  100853. */
  100854. keysLeft: number[];
  100855. /**
  100856. * Set the keys for camera movement right.
  100857. */
  100858. /**
  100859. * Set the keys for camera movement right.
  100860. */
  100861. keysRight: number[];
  100862. /**
  100863. * Event raised when the camera collides with a mesh in the scene.
  100864. */
  100865. onCollide: (collidedMesh: AbstractMesh) => void;
  100866. private _collider;
  100867. private _needMoveForGravity;
  100868. private _oldPosition;
  100869. private _diffPosition;
  100870. private _newPosition;
  100871. /** @hidden */
  100872. _localDirection: Vector3;
  100873. /** @hidden */
  100874. _transformedDirection: Vector3;
  100875. /**
  100876. * Instantiates a FlyCamera.
  100877. * This is a flying camera, designed for 3D movement and rotation in all directions,
  100878. * such as in a 3D Space Shooter or a Flight Simulator.
  100879. * @param name Define the name of the camera in the scene.
  100880. * @param position Define the starting position of the camera in the scene.
  100881. * @param scene Define the scene the camera belongs to.
  100882. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  100883. */
  100884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100885. /**
  100886. * Attach a control to the HTML DOM element.
  100887. * @param element Defines the element that listens to the input events.
  100888. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  100889. */
  100890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100891. /**
  100892. * Detach a control from the HTML DOM element.
  100893. * The camera will stop reacting to that input.
  100894. * @param element Defines the element that listens to the input events.
  100895. */
  100896. detachControl(element: HTMLElement): void;
  100897. private _collisionMask;
  100898. /**
  100899. * Get the mask that the camera ignores in collision events.
  100900. */
  100901. /**
  100902. * Set the mask that the camera ignores in collision events.
  100903. */
  100904. collisionMask: number;
  100905. /** @hidden */
  100906. _collideWithWorld(displacement: Vector3): void;
  100907. /** @hidden */
  100908. private _onCollisionPositionChange;
  100909. /** @hidden */
  100910. _checkInputs(): void;
  100911. /** @hidden */
  100912. _decideIfNeedsToMove(): boolean;
  100913. /** @hidden */
  100914. _updatePosition(): void;
  100915. /**
  100916. * Restore the Roll to its target value at the rate specified.
  100917. * @param rate - Higher means slower restoring.
  100918. * @hidden
  100919. */
  100920. restoreRoll(rate: number): void;
  100921. /**
  100922. * Destroy the camera and release the current resources held by it.
  100923. */
  100924. dispose(): void;
  100925. /**
  100926. * Get the current object class name.
  100927. * @returns the class name.
  100928. */
  100929. getClassName(): string;
  100930. }
  100931. }
  100932. declare module BABYLON {
  100933. /**
  100934. * Listen to keyboard events to control the camera.
  100935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100936. */
  100937. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  100938. /**
  100939. * Defines the camera the input is attached to.
  100940. */
  100941. camera: FlyCamera;
  100942. /**
  100943. * The list of keyboard keys used to control the forward move of the camera.
  100944. */
  100945. keysForward: number[];
  100946. /**
  100947. * The list of keyboard keys used to control the backward move of the camera.
  100948. */
  100949. keysBackward: number[];
  100950. /**
  100951. * The list of keyboard keys used to control the forward move of the camera.
  100952. */
  100953. keysUp: number[];
  100954. /**
  100955. * The list of keyboard keys used to control the backward move of the camera.
  100956. */
  100957. keysDown: number[];
  100958. /**
  100959. * The list of keyboard keys used to control the right strafe move of the camera.
  100960. */
  100961. keysRight: number[];
  100962. /**
  100963. * The list of keyboard keys used to control the left strafe move of the camera.
  100964. */
  100965. keysLeft: number[];
  100966. private _keys;
  100967. private _onCanvasBlurObserver;
  100968. private _onKeyboardObserver;
  100969. private _engine;
  100970. private _scene;
  100971. /**
  100972. * Attach the input controls to a specific dom element to get the input from.
  100973. * @param element Defines the element the controls should be listened from
  100974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100975. */
  100976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100977. /**
  100978. * Detach the current controls from the specified dom element.
  100979. * @param element Defines the element to stop listening the inputs from
  100980. */
  100981. detachControl(element: Nullable<HTMLElement>): void;
  100982. /**
  100983. * Gets the class name of the current intput.
  100984. * @returns the class name
  100985. */
  100986. getClassName(): string;
  100987. /** @hidden */
  100988. _onLostFocus(e: FocusEvent): void;
  100989. /**
  100990. * Get the friendly name associated with the input class.
  100991. * @returns the input friendly name
  100992. */
  100993. getSimpleName(): string;
  100994. /**
  100995. * Update the current camera state depending on the inputs that have been used this frame.
  100996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100997. */
  100998. checkInputs(): void;
  100999. }
  101000. }
  101001. declare module BABYLON {
  101002. /**
  101003. * Manage the mouse wheel inputs to control a follow camera.
  101004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101005. */
  101006. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  101007. /**
  101008. * Defines the camera the input is attached to.
  101009. */
  101010. camera: FollowCamera;
  101011. /**
  101012. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  101013. */
  101014. axisControlRadius: boolean;
  101015. /**
  101016. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  101017. */
  101018. axisControlHeight: boolean;
  101019. /**
  101020. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  101021. */
  101022. axisControlRotation: boolean;
  101023. /**
  101024. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  101025. * relation to mouseWheel events.
  101026. */
  101027. wheelPrecision: number;
  101028. /**
  101029. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101030. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101031. */
  101032. wheelDeltaPercentage: number;
  101033. private _wheel;
  101034. private _observer;
  101035. /**
  101036. * Attach the input controls to a specific dom element to get the input from.
  101037. * @param element Defines the element the controls should be listened from
  101038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101039. */
  101040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101041. /**
  101042. * Detach the current controls from the specified dom element.
  101043. * @param element Defines the element to stop listening the inputs from
  101044. */
  101045. detachControl(element: Nullable<HTMLElement>): void;
  101046. /**
  101047. * Gets the class name of the current intput.
  101048. * @returns the class name
  101049. */
  101050. getClassName(): string;
  101051. /**
  101052. * Get the friendly name associated with the input class.
  101053. * @returns the input friendly name
  101054. */
  101055. getSimpleName(): string;
  101056. }
  101057. }
  101058. declare module BABYLON {
  101059. /**
  101060. * Manage the pointers inputs to control an follow camera.
  101061. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101062. */
  101063. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  101064. /**
  101065. * Defines the camera the input is attached to.
  101066. */
  101067. camera: FollowCamera;
  101068. /**
  101069. * Gets the class name of the current input.
  101070. * @returns the class name
  101071. */
  101072. getClassName(): string;
  101073. /**
  101074. * Defines the pointer angular sensibility along the X axis or how fast is
  101075. * the camera rotating.
  101076. * A negative number will reverse the axis direction.
  101077. */
  101078. angularSensibilityX: number;
  101079. /**
  101080. * Defines the pointer angular sensibility along the Y axis or how fast is
  101081. * the camera rotating.
  101082. * A negative number will reverse the axis direction.
  101083. */
  101084. angularSensibilityY: number;
  101085. /**
  101086. * Defines the pointer pinch precision or how fast is the camera zooming.
  101087. * A negative number will reverse the axis direction.
  101088. */
  101089. pinchPrecision: number;
  101090. /**
  101091. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101092. * from 0.
  101093. * It defines the percentage of current camera.radius to use as delta when
  101094. * pinch zoom is used.
  101095. */
  101096. pinchDeltaPercentage: number;
  101097. /**
  101098. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  101099. */
  101100. axisXControlRadius: boolean;
  101101. /**
  101102. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  101103. */
  101104. axisXControlHeight: boolean;
  101105. /**
  101106. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  101107. */
  101108. axisXControlRotation: boolean;
  101109. /**
  101110. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  101111. */
  101112. axisYControlRadius: boolean;
  101113. /**
  101114. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  101115. */
  101116. axisYControlHeight: boolean;
  101117. /**
  101118. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  101119. */
  101120. axisYControlRotation: boolean;
  101121. /**
  101122. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  101123. */
  101124. axisPinchControlRadius: boolean;
  101125. /**
  101126. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  101127. */
  101128. axisPinchControlHeight: boolean;
  101129. /**
  101130. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  101131. */
  101132. axisPinchControlRotation: boolean;
  101133. /**
  101134. * Log error messages if basic misconfiguration has occurred.
  101135. */
  101136. warningEnable: boolean;
  101137. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101138. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101139. private _warningCounter;
  101140. private _warning;
  101141. }
  101142. }
  101143. declare module BABYLON {
  101144. /**
  101145. * Default Inputs manager for the FollowCamera.
  101146. * It groups all the default supported inputs for ease of use.
  101147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101148. */
  101149. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  101150. /**
  101151. * Instantiates a new FollowCameraInputsManager.
  101152. * @param camera Defines the camera the inputs belong to
  101153. */
  101154. constructor(camera: FollowCamera);
  101155. /**
  101156. * Add keyboard input support to the input manager.
  101157. * @returns the current input manager
  101158. */
  101159. addKeyboard(): FollowCameraInputsManager;
  101160. /**
  101161. * Add mouse wheel input support to the input manager.
  101162. * @returns the current input manager
  101163. */
  101164. addMouseWheel(): FollowCameraInputsManager;
  101165. /**
  101166. * Add pointers input support to the input manager.
  101167. * @returns the current input manager
  101168. */
  101169. addPointers(): FollowCameraInputsManager;
  101170. /**
  101171. * Add orientation input support to the input manager.
  101172. * @returns the current input manager
  101173. */
  101174. addVRDeviceOrientation(): FollowCameraInputsManager;
  101175. }
  101176. }
  101177. declare module BABYLON {
  101178. /**
  101179. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  101180. * an arc rotate version arcFollowCamera are available.
  101181. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101182. */
  101183. export class FollowCamera extends TargetCamera {
  101184. /**
  101185. * Distance the follow camera should follow an object at
  101186. */
  101187. radius: number;
  101188. /**
  101189. * Minimum allowed distance of the camera to the axis of rotation
  101190. * (The camera can not get closer).
  101191. * This can help limiting how the Camera is able to move in the scene.
  101192. */
  101193. lowerRadiusLimit: Nullable<number>;
  101194. /**
  101195. * Maximum allowed distance of the camera to the axis of rotation
  101196. * (The camera can not get further).
  101197. * This can help limiting how the Camera is able to move in the scene.
  101198. */
  101199. upperRadiusLimit: Nullable<number>;
  101200. /**
  101201. * Define a rotation offset between the camera and the object it follows
  101202. */
  101203. rotationOffset: number;
  101204. /**
  101205. * Minimum allowed angle to camera position relative to target object.
  101206. * This can help limiting how the Camera is able to move in the scene.
  101207. */
  101208. lowerRotationOffsetLimit: Nullable<number>;
  101209. /**
  101210. * Maximum allowed angle to camera position relative to target object.
  101211. * This can help limiting how the Camera is able to move in the scene.
  101212. */
  101213. upperRotationOffsetLimit: Nullable<number>;
  101214. /**
  101215. * Define a height offset between the camera and the object it follows.
  101216. * It can help following an object from the top (like a car chaing a plane)
  101217. */
  101218. heightOffset: number;
  101219. /**
  101220. * Minimum allowed height of camera position relative to target object.
  101221. * This can help limiting how the Camera is able to move in the scene.
  101222. */
  101223. lowerHeightOffsetLimit: Nullable<number>;
  101224. /**
  101225. * Maximum allowed height of camera position relative to target object.
  101226. * This can help limiting how the Camera is able to move in the scene.
  101227. */
  101228. upperHeightOffsetLimit: Nullable<number>;
  101229. /**
  101230. * Define how fast the camera can accelerate to follow it s target.
  101231. */
  101232. cameraAcceleration: number;
  101233. /**
  101234. * Define the speed limit of the camera following an object.
  101235. */
  101236. maxCameraSpeed: number;
  101237. /**
  101238. * Define the target of the camera.
  101239. */
  101240. lockedTarget: Nullable<AbstractMesh>;
  101241. /**
  101242. * Defines the input associated with the camera.
  101243. */
  101244. inputs: FollowCameraInputsManager;
  101245. /**
  101246. * Instantiates the follow camera.
  101247. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101248. * @param name Define the name of the camera in the scene
  101249. * @param position Define the position of the camera
  101250. * @param scene Define the scene the camera belong to
  101251. * @param lockedTarget Define the target of the camera
  101252. */
  101253. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  101254. private _follow;
  101255. /**
  101256. * Attached controls to the current camera.
  101257. * @param element Defines the element the controls should be listened from
  101258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101259. */
  101260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101261. /**
  101262. * Detach the current controls from the camera.
  101263. * The camera will stop reacting to inputs.
  101264. * @param element Defines the element to stop listening the inputs from
  101265. */
  101266. detachControl(element: HTMLElement): void;
  101267. /** @hidden */
  101268. _checkInputs(): void;
  101269. private _checkLimits;
  101270. /**
  101271. * Gets the camera class name.
  101272. * @returns the class name
  101273. */
  101274. getClassName(): string;
  101275. }
  101276. /**
  101277. * Arc Rotate version of the follow camera.
  101278. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  101279. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101280. */
  101281. export class ArcFollowCamera extends TargetCamera {
  101282. /** The longitudinal angle of the camera */
  101283. alpha: number;
  101284. /** The latitudinal angle of the camera */
  101285. beta: number;
  101286. /** The radius of the camera from its target */
  101287. radius: number;
  101288. /** Define the camera target (the messh it should follow) */
  101289. target: Nullable<AbstractMesh>;
  101290. private _cartesianCoordinates;
  101291. /**
  101292. * Instantiates a new ArcFollowCamera
  101293. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101294. * @param name Define the name of the camera
  101295. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  101296. * @param beta Define the rotation angle of the camera around the elevation axis
  101297. * @param radius Define the radius of the camera from its target point
  101298. * @param target Define the target of the camera
  101299. * @param scene Define the scene the camera belongs to
  101300. */
  101301. constructor(name: string,
  101302. /** The longitudinal angle of the camera */
  101303. alpha: number,
  101304. /** The latitudinal angle of the camera */
  101305. beta: number,
  101306. /** The radius of the camera from its target */
  101307. radius: number,
  101308. /** Define the camera target (the messh it should follow) */
  101309. target: Nullable<AbstractMesh>, scene: Scene);
  101310. private _follow;
  101311. /** @hidden */
  101312. _checkInputs(): void;
  101313. /**
  101314. * Returns the class name of the object.
  101315. * It is mostly used internally for serialization purposes.
  101316. */
  101317. getClassName(): string;
  101318. }
  101319. }
  101320. declare module BABYLON {
  101321. /**
  101322. * Manage the keyboard inputs to control the movement of a follow camera.
  101323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101324. */
  101325. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  101326. /**
  101327. * Defines the camera the input is attached to.
  101328. */
  101329. camera: FollowCamera;
  101330. /**
  101331. * Defines the list of key codes associated with the up action (increase heightOffset)
  101332. */
  101333. keysHeightOffsetIncr: number[];
  101334. /**
  101335. * Defines the list of key codes associated with the down action (decrease heightOffset)
  101336. */
  101337. keysHeightOffsetDecr: number[];
  101338. /**
  101339. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  101340. */
  101341. keysHeightOffsetModifierAlt: boolean;
  101342. /**
  101343. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  101344. */
  101345. keysHeightOffsetModifierCtrl: boolean;
  101346. /**
  101347. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  101348. */
  101349. keysHeightOffsetModifierShift: boolean;
  101350. /**
  101351. * Defines the list of key codes associated with the left action (increase rotationOffset)
  101352. */
  101353. keysRotationOffsetIncr: number[];
  101354. /**
  101355. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  101356. */
  101357. keysRotationOffsetDecr: number[];
  101358. /**
  101359. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  101360. */
  101361. keysRotationOffsetModifierAlt: boolean;
  101362. /**
  101363. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  101364. */
  101365. keysRotationOffsetModifierCtrl: boolean;
  101366. /**
  101367. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  101368. */
  101369. keysRotationOffsetModifierShift: boolean;
  101370. /**
  101371. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  101372. */
  101373. keysRadiusIncr: number[];
  101374. /**
  101375. * Defines the list of key codes associated with the zoom-out action (increase radius)
  101376. */
  101377. keysRadiusDecr: number[];
  101378. /**
  101379. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  101380. */
  101381. keysRadiusModifierAlt: boolean;
  101382. /**
  101383. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  101384. */
  101385. keysRadiusModifierCtrl: boolean;
  101386. /**
  101387. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  101388. */
  101389. keysRadiusModifierShift: boolean;
  101390. /**
  101391. * Defines the rate of change of heightOffset.
  101392. */
  101393. heightSensibility: number;
  101394. /**
  101395. * Defines the rate of change of rotationOffset.
  101396. */
  101397. rotationSensibility: number;
  101398. /**
  101399. * Defines the rate of change of radius.
  101400. */
  101401. radiusSensibility: number;
  101402. private _keys;
  101403. private _ctrlPressed;
  101404. private _altPressed;
  101405. private _shiftPressed;
  101406. private _onCanvasBlurObserver;
  101407. private _onKeyboardObserver;
  101408. private _engine;
  101409. private _scene;
  101410. /**
  101411. * Attach the input controls to a specific dom element to get the input from.
  101412. * @param element Defines the element the controls should be listened from
  101413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101414. */
  101415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101416. /**
  101417. * Detach the current controls from the specified dom element.
  101418. * @param element Defines the element to stop listening the inputs from
  101419. */
  101420. detachControl(element: Nullable<HTMLElement>): void;
  101421. /**
  101422. * Update the current camera state depending on the inputs that have been used this frame.
  101423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101424. */
  101425. checkInputs(): void;
  101426. /**
  101427. * Gets the class name of the current input.
  101428. * @returns the class name
  101429. */
  101430. getClassName(): string;
  101431. /**
  101432. * Get the friendly name associated with the input class.
  101433. * @returns the input friendly name
  101434. */
  101435. getSimpleName(): string;
  101436. /**
  101437. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101438. * allow modification of the heightOffset value.
  101439. */
  101440. private _modifierHeightOffset;
  101441. /**
  101442. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101443. * allow modification of the rotationOffset value.
  101444. */
  101445. private _modifierRotationOffset;
  101446. /**
  101447. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101448. * allow modification of the radius value.
  101449. */
  101450. private _modifierRadius;
  101451. }
  101452. }
  101453. declare module BABYLON {
  101454. interface FreeCameraInputsManager {
  101455. /**
  101456. * @hidden
  101457. */
  101458. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  101459. /**
  101460. * Add orientation input support to the input manager.
  101461. * @returns the current input manager
  101462. */
  101463. addDeviceOrientation(): FreeCameraInputsManager;
  101464. }
  101465. /**
  101466. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  101467. * Screen rotation is taken into account.
  101468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101469. */
  101470. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  101471. private _camera;
  101472. private _screenOrientationAngle;
  101473. private _constantTranform;
  101474. private _screenQuaternion;
  101475. private _alpha;
  101476. private _beta;
  101477. private _gamma;
  101478. /**
  101479. * Can be used to detect if a device orientation sensor is availible on a device
  101480. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  101481. * @returns a promise that will resolve on orientation change
  101482. */
  101483. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  101484. /**
  101485. * @hidden
  101486. */
  101487. _onDeviceOrientationChangedObservable: Observable<void>;
  101488. /**
  101489. * Instantiates a new input
  101490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101491. */
  101492. constructor();
  101493. /**
  101494. * Define the camera controlled by the input.
  101495. */
  101496. camera: FreeCamera;
  101497. /**
  101498. * Attach the input controls to a specific dom element to get the input from.
  101499. * @param element Defines the element the controls should be listened from
  101500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101501. */
  101502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101503. private _orientationChanged;
  101504. private _deviceOrientation;
  101505. /**
  101506. * Detach the current controls from the specified dom element.
  101507. * @param element Defines the element to stop listening the inputs from
  101508. */
  101509. detachControl(element: Nullable<HTMLElement>): void;
  101510. /**
  101511. * Update the current camera state depending on the inputs that have been used this frame.
  101512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101513. */
  101514. checkInputs(): void;
  101515. /**
  101516. * Gets the class name of the current intput.
  101517. * @returns the class name
  101518. */
  101519. getClassName(): string;
  101520. /**
  101521. * Get the friendly name associated with the input class.
  101522. * @returns the input friendly name
  101523. */
  101524. getSimpleName(): string;
  101525. }
  101526. }
  101527. declare module BABYLON {
  101528. /**
  101529. * Manage the gamepad inputs to control a free camera.
  101530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101531. */
  101532. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  101533. /**
  101534. * Define the camera the input is attached to.
  101535. */
  101536. camera: FreeCamera;
  101537. /**
  101538. * Define the Gamepad controlling the input
  101539. */
  101540. gamepad: Nullable<Gamepad>;
  101541. /**
  101542. * Defines the gamepad rotation sensiblity.
  101543. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101544. */
  101545. gamepadAngularSensibility: number;
  101546. /**
  101547. * Defines the gamepad move sensiblity.
  101548. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101549. */
  101550. gamepadMoveSensibility: number;
  101551. private _onGamepadConnectedObserver;
  101552. private _onGamepadDisconnectedObserver;
  101553. private _cameraTransform;
  101554. private _deltaTransform;
  101555. private _vector3;
  101556. private _vector2;
  101557. /**
  101558. * Attach the input controls to a specific dom element to get the input from.
  101559. * @param element Defines the element the controls should be listened from
  101560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101561. */
  101562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101563. /**
  101564. * Detach the current controls from the specified dom element.
  101565. * @param element Defines the element to stop listening the inputs from
  101566. */
  101567. detachControl(element: Nullable<HTMLElement>): void;
  101568. /**
  101569. * Update the current camera state depending on the inputs that have been used this frame.
  101570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101571. */
  101572. checkInputs(): void;
  101573. /**
  101574. * Gets the class name of the current intput.
  101575. * @returns the class name
  101576. */
  101577. getClassName(): string;
  101578. /**
  101579. * Get the friendly name associated with the input class.
  101580. * @returns the input friendly name
  101581. */
  101582. getSimpleName(): string;
  101583. }
  101584. }
  101585. declare module BABYLON {
  101586. /**
  101587. * Defines the potential axis of a Joystick
  101588. */
  101589. export enum JoystickAxis {
  101590. /** X axis */
  101591. X = 0,
  101592. /** Y axis */
  101593. Y = 1,
  101594. /** Z axis */
  101595. Z = 2
  101596. }
  101597. /**
  101598. * Class used to define virtual joystick (used in touch mode)
  101599. */
  101600. export class VirtualJoystick {
  101601. /**
  101602. * Gets or sets a boolean indicating that left and right values must be inverted
  101603. */
  101604. reverseLeftRight: boolean;
  101605. /**
  101606. * Gets or sets a boolean indicating that up and down values must be inverted
  101607. */
  101608. reverseUpDown: boolean;
  101609. /**
  101610. * Gets the offset value for the position (ie. the change of the position value)
  101611. */
  101612. deltaPosition: Vector3;
  101613. /**
  101614. * Gets a boolean indicating if the virtual joystick was pressed
  101615. */
  101616. pressed: boolean;
  101617. /**
  101618. * Canvas the virtual joystick will render onto, default z-index of this is 5
  101619. */
  101620. static Canvas: Nullable<HTMLCanvasElement>;
  101621. private static _globalJoystickIndex;
  101622. private static vjCanvasContext;
  101623. private static vjCanvasWidth;
  101624. private static vjCanvasHeight;
  101625. private static halfWidth;
  101626. private _action;
  101627. private _axisTargetedByLeftAndRight;
  101628. private _axisTargetedByUpAndDown;
  101629. private _joystickSensibility;
  101630. private _inversedSensibility;
  101631. private _joystickPointerID;
  101632. private _joystickColor;
  101633. private _joystickPointerPos;
  101634. private _joystickPreviousPointerPos;
  101635. private _joystickPointerStartPos;
  101636. private _deltaJoystickVector;
  101637. private _leftJoystick;
  101638. private _touches;
  101639. private _onPointerDownHandlerRef;
  101640. private _onPointerMoveHandlerRef;
  101641. private _onPointerUpHandlerRef;
  101642. private _onResize;
  101643. /**
  101644. * Creates a new virtual joystick
  101645. * @param leftJoystick defines that the joystick is for left hand (false by default)
  101646. */
  101647. constructor(leftJoystick?: boolean);
  101648. /**
  101649. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  101650. * @param newJoystickSensibility defines the new sensibility
  101651. */
  101652. setJoystickSensibility(newJoystickSensibility: number): void;
  101653. private _onPointerDown;
  101654. private _onPointerMove;
  101655. private _onPointerUp;
  101656. /**
  101657. * Change the color of the virtual joystick
  101658. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  101659. */
  101660. setJoystickColor(newColor: string): void;
  101661. /**
  101662. * Defines a callback to call when the joystick is touched
  101663. * @param action defines the callback
  101664. */
  101665. setActionOnTouch(action: () => any): void;
  101666. /**
  101667. * Defines which axis you'd like to control for left & right
  101668. * @param axis defines the axis to use
  101669. */
  101670. setAxisForLeftRight(axis: JoystickAxis): void;
  101671. /**
  101672. * Defines which axis you'd like to control for up & down
  101673. * @param axis defines the axis to use
  101674. */
  101675. setAxisForUpDown(axis: JoystickAxis): void;
  101676. private _drawVirtualJoystick;
  101677. /**
  101678. * Release internal HTML canvas
  101679. */
  101680. releaseCanvas(): void;
  101681. }
  101682. }
  101683. declare module BABYLON {
  101684. interface FreeCameraInputsManager {
  101685. /**
  101686. * Add virtual joystick input support to the input manager.
  101687. * @returns the current input manager
  101688. */
  101689. addVirtualJoystick(): FreeCameraInputsManager;
  101690. }
  101691. /**
  101692. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  101693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101694. */
  101695. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  101696. /**
  101697. * Defines the camera the input is attached to.
  101698. */
  101699. camera: FreeCamera;
  101700. private _leftjoystick;
  101701. private _rightjoystick;
  101702. /**
  101703. * Gets the left stick of the virtual joystick.
  101704. * @returns The virtual Joystick
  101705. */
  101706. getLeftJoystick(): VirtualJoystick;
  101707. /**
  101708. * Gets the right stick of the virtual joystick.
  101709. * @returns The virtual Joystick
  101710. */
  101711. getRightJoystick(): VirtualJoystick;
  101712. /**
  101713. * Update the current camera state depending on the inputs that have been used this frame.
  101714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101715. */
  101716. checkInputs(): void;
  101717. /**
  101718. * Attach the input controls to a specific dom element to get the input from.
  101719. * @param element Defines the element the controls should be listened from
  101720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101721. */
  101722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101723. /**
  101724. * Detach the current controls from the specified dom element.
  101725. * @param element Defines the element to stop listening the inputs from
  101726. */
  101727. detachControl(element: Nullable<HTMLElement>): void;
  101728. /**
  101729. * Gets the class name of the current intput.
  101730. * @returns the class name
  101731. */
  101732. getClassName(): string;
  101733. /**
  101734. * Get the friendly name associated with the input class.
  101735. * @returns the input friendly name
  101736. */
  101737. getSimpleName(): string;
  101738. }
  101739. }
  101740. declare module BABYLON {
  101741. /**
  101742. * This represents a FPS type of camera controlled by touch.
  101743. * This is like a universal camera minus the Gamepad controls.
  101744. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101745. */
  101746. export class TouchCamera extends FreeCamera {
  101747. /**
  101748. * Defines the touch sensibility for rotation.
  101749. * The higher the faster.
  101750. */
  101751. touchAngularSensibility: number;
  101752. /**
  101753. * Defines the touch sensibility for move.
  101754. * The higher the faster.
  101755. */
  101756. touchMoveSensibility: number;
  101757. /**
  101758. * Instantiates a new touch camera.
  101759. * This represents a FPS type of camera controlled by touch.
  101760. * This is like a universal camera minus the Gamepad controls.
  101761. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101762. * @param name Define the name of the camera in the scene
  101763. * @param position Define the start position of the camera in the scene
  101764. * @param scene Define the scene the camera belongs to
  101765. */
  101766. constructor(name: string, position: Vector3, scene: Scene);
  101767. /**
  101768. * Gets the current object class name.
  101769. * @return the class name
  101770. */
  101771. getClassName(): string;
  101772. /** @hidden */
  101773. _setupInputs(): void;
  101774. }
  101775. }
  101776. declare module BABYLON {
  101777. /**
  101778. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  101779. * being tilted forward or back and left or right.
  101780. */
  101781. export class DeviceOrientationCamera extends FreeCamera {
  101782. private _initialQuaternion;
  101783. private _quaternionCache;
  101784. private _tmpDragQuaternion;
  101785. /**
  101786. * Creates a new device orientation camera
  101787. * @param name The name of the camera
  101788. * @param position The start position camera
  101789. * @param scene The scene the camera belongs to
  101790. */
  101791. constructor(name: string, position: Vector3, scene: Scene);
  101792. /**
  101793. * @hidden
  101794. * Disabled pointer input on first orientation sensor update (Default: true)
  101795. */
  101796. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  101797. private _dragFactor;
  101798. /**
  101799. * Enabled turning on the y axis when the orientation sensor is active
  101800. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  101801. */
  101802. enableHorizontalDragging(dragFactor?: number): void;
  101803. /**
  101804. * Gets the current instance class name ("DeviceOrientationCamera").
  101805. * This helps avoiding instanceof at run time.
  101806. * @returns the class name
  101807. */
  101808. getClassName(): string;
  101809. /**
  101810. * @hidden
  101811. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  101812. */
  101813. _checkInputs(): void;
  101814. /**
  101815. * Reset the camera to its default orientation on the specified axis only.
  101816. * @param axis The axis to reset
  101817. */
  101818. resetToCurrentRotation(axis?: Axis): void;
  101819. }
  101820. }
  101821. declare module BABYLON {
  101822. /**
  101823. * Defines supported buttons for XBox360 compatible gamepads
  101824. */
  101825. export enum Xbox360Button {
  101826. /** A */
  101827. A = 0,
  101828. /** B */
  101829. B = 1,
  101830. /** X */
  101831. X = 2,
  101832. /** Y */
  101833. Y = 3,
  101834. /** Start */
  101835. Start = 4,
  101836. /** Back */
  101837. Back = 5,
  101838. /** Left button */
  101839. LB = 6,
  101840. /** Right button */
  101841. RB = 7,
  101842. /** Left stick */
  101843. LeftStick = 8,
  101844. /** Right stick */
  101845. RightStick = 9
  101846. }
  101847. /** Defines values for XBox360 DPad */
  101848. export enum Xbox360Dpad {
  101849. /** Up */
  101850. Up = 0,
  101851. /** Down */
  101852. Down = 1,
  101853. /** Left */
  101854. Left = 2,
  101855. /** Right */
  101856. Right = 3
  101857. }
  101858. /**
  101859. * Defines a XBox360 gamepad
  101860. */
  101861. export class Xbox360Pad extends Gamepad {
  101862. private _leftTrigger;
  101863. private _rightTrigger;
  101864. private _onlefttriggerchanged;
  101865. private _onrighttriggerchanged;
  101866. private _onbuttondown;
  101867. private _onbuttonup;
  101868. private _ondpaddown;
  101869. private _ondpadup;
  101870. /** Observable raised when a button is pressed */
  101871. onButtonDownObservable: Observable<Xbox360Button>;
  101872. /** Observable raised when a button is released */
  101873. onButtonUpObservable: Observable<Xbox360Button>;
  101874. /** Observable raised when a pad is pressed */
  101875. onPadDownObservable: Observable<Xbox360Dpad>;
  101876. /** Observable raised when a pad is released */
  101877. onPadUpObservable: Observable<Xbox360Dpad>;
  101878. private _buttonA;
  101879. private _buttonB;
  101880. private _buttonX;
  101881. private _buttonY;
  101882. private _buttonBack;
  101883. private _buttonStart;
  101884. private _buttonLB;
  101885. private _buttonRB;
  101886. private _buttonLeftStick;
  101887. private _buttonRightStick;
  101888. private _dPadUp;
  101889. private _dPadDown;
  101890. private _dPadLeft;
  101891. private _dPadRight;
  101892. private _isXboxOnePad;
  101893. /**
  101894. * Creates a new XBox360 gamepad object
  101895. * @param id defines the id of this gamepad
  101896. * @param index defines its index
  101897. * @param gamepad defines the internal HTML gamepad object
  101898. * @param xboxOne defines if it is a XBox One gamepad
  101899. */
  101900. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  101901. /**
  101902. * Defines the callback to call when left trigger is pressed
  101903. * @param callback defines the callback to use
  101904. */
  101905. onlefttriggerchanged(callback: (value: number) => void): void;
  101906. /**
  101907. * Defines the callback to call when right trigger is pressed
  101908. * @param callback defines the callback to use
  101909. */
  101910. onrighttriggerchanged(callback: (value: number) => void): void;
  101911. /**
  101912. * Gets the left trigger value
  101913. */
  101914. /**
  101915. * Sets the left trigger value
  101916. */
  101917. leftTrigger: number;
  101918. /**
  101919. * Gets the right trigger value
  101920. */
  101921. /**
  101922. * Sets the right trigger value
  101923. */
  101924. rightTrigger: number;
  101925. /**
  101926. * Defines the callback to call when a button is pressed
  101927. * @param callback defines the callback to use
  101928. */
  101929. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  101930. /**
  101931. * Defines the callback to call when a button is released
  101932. * @param callback defines the callback to use
  101933. */
  101934. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  101935. /**
  101936. * Defines the callback to call when a pad is pressed
  101937. * @param callback defines the callback to use
  101938. */
  101939. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  101940. /**
  101941. * Defines the callback to call when a pad is released
  101942. * @param callback defines the callback to use
  101943. */
  101944. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  101945. private _setButtonValue;
  101946. private _setDPadValue;
  101947. /**
  101948. * Gets the value of the `A` button
  101949. */
  101950. /**
  101951. * Sets the value of the `A` button
  101952. */
  101953. buttonA: number;
  101954. /**
  101955. * Gets the value of the `B` button
  101956. */
  101957. /**
  101958. * Sets the value of the `B` button
  101959. */
  101960. buttonB: number;
  101961. /**
  101962. * Gets the value of the `X` button
  101963. */
  101964. /**
  101965. * Sets the value of the `X` button
  101966. */
  101967. buttonX: number;
  101968. /**
  101969. * Gets the value of the `Y` button
  101970. */
  101971. /**
  101972. * Sets the value of the `Y` button
  101973. */
  101974. buttonY: number;
  101975. /**
  101976. * Gets the value of the `Start` button
  101977. */
  101978. /**
  101979. * Sets the value of the `Start` button
  101980. */
  101981. buttonStart: number;
  101982. /**
  101983. * Gets the value of the `Back` button
  101984. */
  101985. /**
  101986. * Sets the value of the `Back` button
  101987. */
  101988. buttonBack: number;
  101989. /**
  101990. * Gets the value of the `Left` button
  101991. */
  101992. /**
  101993. * Sets the value of the `Left` button
  101994. */
  101995. buttonLB: number;
  101996. /**
  101997. * Gets the value of the `Right` button
  101998. */
  101999. /**
  102000. * Sets the value of the `Right` button
  102001. */
  102002. buttonRB: number;
  102003. /**
  102004. * Gets the value of the Left joystick
  102005. */
  102006. /**
  102007. * Sets the value of the Left joystick
  102008. */
  102009. buttonLeftStick: number;
  102010. /**
  102011. * Gets the value of the Right joystick
  102012. */
  102013. /**
  102014. * Sets the value of the Right joystick
  102015. */
  102016. buttonRightStick: number;
  102017. /**
  102018. * Gets the value of D-pad up
  102019. */
  102020. /**
  102021. * Sets the value of D-pad up
  102022. */
  102023. dPadUp: number;
  102024. /**
  102025. * Gets the value of D-pad down
  102026. */
  102027. /**
  102028. * Sets the value of D-pad down
  102029. */
  102030. dPadDown: number;
  102031. /**
  102032. * Gets the value of D-pad left
  102033. */
  102034. /**
  102035. * Sets the value of D-pad left
  102036. */
  102037. dPadLeft: number;
  102038. /**
  102039. * Gets the value of D-pad right
  102040. */
  102041. /**
  102042. * Sets the value of D-pad right
  102043. */
  102044. dPadRight: number;
  102045. /**
  102046. * Force the gamepad to synchronize with device values
  102047. */
  102048. update(): void;
  102049. /**
  102050. * Disposes the gamepad
  102051. */
  102052. dispose(): void;
  102053. }
  102054. }
  102055. declare module BABYLON {
  102056. /**
  102057. * Manager for handling gamepads
  102058. */
  102059. export class GamepadManager {
  102060. private _scene?;
  102061. private _babylonGamepads;
  102062. private _oneGamepadConnected;
  102063. /** @hidden */
  102064. _isMonitoring: boolean;
  102065. private _gamepadEventSupported;
  102066. private _gamepadSupport;
  102067. /**
  102068. * observable to be triggered when the gamepad controller has been connected
  102069. */
  102070. onGamepadConnectedObservable: Observable<Gamepad>;
  102071. /**
  102072. * observable to be triggered when the gamepad controller has been disconnected
  102073. */
  102074. onGamepadDisconnectedObservable: Observable<Gamepad>;
  102075. private _onGamepadConnectedEvent;
  102076. private _onGamepadDisconnectedEvent;
  102077. /**
  102078. * Initializes the gamepad manager
  102079. * @param _scene BabylonJS scene
  102080. */
  102081. constructor(_scene?: Scene | undefined);
  102082. /**
  102083. * The gamepads in the game pad manager
  102084. */
  102085. readonly gamepads: Gamepad[];
  102086. /**
  102087. * Get the gamepad controllers based on type
  102088. * @param type The type of gamepad controller
  102089. * @returns Nullable gamepad
  102090. */
  102091. getGamepadByType(type?: number): Nullable<Gamepad>;
  102092. /**
  102093. * Disposes the gamepad manager
  102094. */
  102095. dispose(): void;
  102096. private _addNewGamepad;
  102097. private _startMonitoringGamepads;
  102098. private _stopMonitoringGamepads;
  102099. /** @hidden */
  102100. _checkGamepadsStatus(): void;
  102101. private _updateGamepadObjects;
  102102. }
  102103. }
  102104. declare module BABYLON {
  102105. interface Scene {
  102106. /** @hidden */
  102107. _gamepadManager: Nullable<GamepadManager>;
  102108. /**
  102109. * Gets the gamepad manager associated with the scene
  102110. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  102111. */
  102112. gamepadManager: GamepadManager;
  102113. }
  102114. /**
  102115. * Interface representing a free camera inputs manager
  102116. */
  102117. interface FreeCameraInputsManager {
  102118. /**
  102119. * Adds gamepad input support to the FreeCameraInputsManager.
  102120. * @returns the FreeCameraInputsManager
  102121. */
  102122. addGamepad(): FreeCameraInputsManager;
  102123. }
  102124. /**
  102125. * Interface representing an arc rotate camera inputs manager
  102126. */
  102127. interface ArcRotateCameraInputsManager {
  102128. /**
  102129. * Adds gamepad input support to the ArcRotateCamera InputManager.
  102130. * @returns the camera inputs manager
  102131. */
  102132. addGamepad(): ArcRotateCameraInputsManager;
  102133. }
  102134. /**
  102135. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  102136. */
  102137. export class GamepadSystemSceneComponent implements ISceneComponent {
  102138. /**
  102139. * The component name helpfull to identify the component in the list of scene components.
  102140. */
  102141. readonly name: string;
  102142. /**
  102143. * The scene the component belongs to.
  102144. */
  102145. scene: Scene;
  102146. /**
  102147. * Creates a new instance of the component for the given scene
  102148. * @param scene Defines the scene to register the component in
  102149. */
  102150. constructor(scene: Scene);
  102151. /**
  102152. * Registers the component in a given scene
  102153. */
  102154. register(): void;
  102155. /**
  102156. * Rebuilds the elements related to this component in case of
  102157. * context lost for instance.
  102158. */
  102159. rebuild(): void;
  102160. /**
  102161. * Disposes the component and the associated ressources
  102162. */
  102163. dispose(): void;
  102164. private _beforeCameraUpdate;
  102165. }
  102166. }
  102167. declare module BABYLON {
  102168. /**
  102169. * 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,
  102170. * which still works and will still be found in many Playgrounds.
  102171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102172. */
  102173. export class UniversalCamera extends TouchCamera {
  102174. /**
  102175. * Defines the gamepad rotation sensiblity.
  102176. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102177. */
  102178. gamepadAngularSensibility: number;
  102179. /**
  102180. * Defines the gamepad move sensiblity.
  102181. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102182. */
  102183. gamepadMoveSensibility: number;
  102184. /**
  102185. * 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,
  102186. * which still works and will still be found in many Playgrounds.
  102187. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102188. * @param name Define the name of the camera in the scene
  102189. * @param position Define the start position of the camera in the scene
  102190. * @param scene Define the scene the camera belongs to
  102191. */
  102192. constructor(name: string, position: Vector3, scene: Scene);
  102193. /**
  102194. * Gets the current object class name.
  102195. * @return the class name
  102196. */
  102197. getClassName(): string;
  102198. }
  102199. }
  102200. declare module BABYLON {
  102201. /**
  102202. * This represents a FPS type of camera. This is only here for back compat purpose.
  102203. * Please use the UniversalCamera instead as both are identical.
  102204. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102205. */
  102206. export class GamepadCamera extends UniversalCamera {
  102207. /**
  102208. * Instantiates a new Gamepad Camera
  102209. * This represents a FPS type of camera. This is only here for back compat purpose.
  102210. * Please use the UniversalCamera instead as both are identical.
  102211. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102212. * @param name Define the name of the camera in the scene
  102213. * @param position Define the start position of the camera in the scene
  102214. * @param scene Define the scene the camera belongs to
  102215. */
  102216. constructor(name: string, position: Vector3, scene: Scene);
  102217. /**
  102218. * Gets the current object class name.
  102219. * @return the class name
  102220. */
  102221. getClassName(): string;
  102222. }
  102223. }
  102224. declare module BABYLON {
  102225. /** @hidden */
  102226. export var passPixelShader: {
  102227. name: string;
  102228. shader: string;
  102229. };
  102230. }
  102231. declare module BABYLON {
  102232. /** @hidden */
  102233. export var passCubePixelShader: {
  102234. name: string;
  102235. shader: string;
  102236. };
  102237. }
  102238. declare module BABYLON {
  102239. /**
  102240. * PassPostProcess which produces an output the same as it's input
  102241. */
  102242. export class PassPostProcess extends PostProcess {
  102243. /**
  102244. * Creates the PassPostProcess
  102245. * @param name The name of the effect.
  102246. * @param options The required width/height ratio to downsize to before computing the render pass.
  102247. * @param camera The camera to apply the render pass to.
  102248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102249. * @param engine The engine which the post process will be applied. (default: current engine)
  102250. * @param reusable If the post process can be reused on the same frame. (default: false)
  102251. * @param textureType The type of texture to be used when performing the post processing.
  102252. * @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)
  102253. */
  102254. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102255. }
  102256. /**
  102257. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  102258. */
  102259. export class PassCubePostProcess extends PostProcess {
  102260. private _face;
  102261. /**
  102262. * Gets or sets the cube face to display.
  102263. * * 0 is +X
  102264. * * 1 is -X
  102265. * * 2 is +Y
  102266. * * 3 is -Y
  102267. * * 4 is +Z
  102268. * * 5 is -Z
  102269. */
  102270. face: number;
  102271. /**
  102272. * Creates the PassCubePostProcess
  102273. * @param name The name of the effect.
  102274. * @param options The required width/height ratio to downsize to before computing the render pass.
  102275. * @param camera The camera to apply the render pass to.
  102276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102277. * @param engine The engine which the post process will be applied. (default: current engine)
  102278. * @param reusable If the post process can be reused on the same frame. (default: false)
  102279. * @param textureType The type of texture to be used when performing the post processing.
  102280. * @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)
  102281. */
  102282. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102283. }
  102284. }
  102285. declare module BABYLON {
  102286. /** @hidden */
  102287. export var anaglyphPixelShader: {
  102288. name: string;
  102289. shader: string;
  102290. };
  102291. }
  102292. declare module BABYLON {
  102293. /**
  102294. * Postprocess used to generate anaglyphic rendering
  102295. */
  102296. export class AnaglyphPostProcess extends PostProcess {
  102297. private _passedProcess;
  102298. /**
  102299. * Creates a new AnaglyphPostProcess
  102300. * @param name defines postprocess name
  102301. * @param options defines creation options or target ratio scale
  102302. * @param rigCameras defines cameras using this postprocess
  102303. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  102304. * @param engine defines hosting engine
  102305. * @param reusable defines if the postprocess will be reused multiple times per frame
  102306. */
  102307. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  102308. }
  102309. }
  102310. declare module BABYLON {
  102311. /**
  102312. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  102313. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102314. */
  102315. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  102316. /**
  102317. * Creates a new AnaglyphArcRotateCamera
  102318. * @param name defines camera name
  102319. * @param alpha defines alpha angle (in radians)
  102320. * @param beta defines beta angle (in radians)
  102321. * @param radius defines radius
  102322. * @param target defines camera target
  102323. * @param interaxialDistance defines distance between each color axis
  102324. * @param scene defines the hosting scene
  102325. */
  102326. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  102327. /**
  102328. * Gets camera class name
  102329. * @returns AnaglyphArcRotateCamera
  102330. */
  102331. getClassName(): string;
  102332. }
  102333. }
  102334. declare module BABYLON {
  102335. /**
  102336. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  102337. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102338. */
  102339. export class AnaglyphFreeCamera extends FreeCamera {
  102340. /**
  102341. * Creates a new AnaglyphFreeCamera
  102342. * @param name defines camera name
  102343. * @param position defines initial position
  102344. * @param interaxialDistance defines distance between each color axis
  102345. * @param scene defines the hosting scene
  102346. */
  102347. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102348. /**
  102349. * Gets camera class name
  102350. * @returns AnaglyphFreeCamera
  102351. */
  102352. getClassName(): string;
  102353. }
  102354. }
  102355. declare module BABYLON {
  102356. /**
  102357. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  102358. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102359. */
  102360. export class AnaglyphGamepadCamera extends GamepadCamera {
  102361. /**
  102362. * Creates a new AnaglyphGamepadCamera
  102363. * @param name defines camera name
  102364. * @param position defines initial position
  102365. * @param interaxialDistance defines distance between each color axis
  102366. * @param scene defines the hosting scene
  102367. */
  102368. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102369. /**
  102370. * Gets camera class name
  102371. * @returns AnaglyphGamepadCamera
  102372. */
  102373. getClassName(): string;
  102374. }
  102375. }
  102376. declare module BABYLON {
  102377. /**
  102378. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  102379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102380. */
  102381. export class AnaglyphUniversalCamera extends UniversalCamera {
  102382. /**
  102383. * Creates a new AnaglyphUniversalCamera
  102384. * @param name defines camera name
  102385. * @param position defines initial position
  102386. * @param interaxialDistance defines distance between each color axis
  102387. * @param scene defines the hosting scene
  102388. */
  102389. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102390. /**
  102391. * Gets camera class name
  102392. * @returns AnaglyphUniversalCamera
  102393. */
  102394. getClassName(): string;
  102395. }
  102396. }
  102397. declare module BABYLON {
  102398. /** @hidden */
  102399. export var stereoscopicInterlacePixelShader: {
  102400. name: string;
  102401. shader: string;
  102402. };
  102403. }
  102404. declare module BABYLON {
  102405. /**
  102406. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  102407. */
  102408. export class StereoscopicInterlacePostProcess extends PostProcess {
  102409. private _stepSize;
  102410. private _passedProcess;
  102411. /**
  102412. * Initializes a StereoscopicInterlacePostProcess
  102413. * @param name The name of the effect.
  102414. * @param rigCameras The rig cameras to be appled to the post process
  102415. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  102416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102417. * @param engine The engine which the post process will be applied. (default: current engine)
  102418. * @param reusable If the post process can be reused on the same frame. (default: false)
  102419. */
  102420. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  102421. }
  102422. }
  102423. declare module BABYLON {
  102424. /**
  102425. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  102426. * @see http://doc.babylonjs.com/features/cameras
  102427. */
  102428. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  102429. /**
  102430. * Creates a new StereoscopicArcRotateCamera
  102431. * @param name defines camera name
  102432. * @param alpha defines alpha angle (in radians)
  102433. * @param beta defines beta angle (in radians)
  102434. * @param radius defines radius
  102435. * @param target defines camera target
  102436. * @param interaxialDistance defines distance between each color axis
  102437. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102438. * @param scene defines the hosting scene
  102439. */
  102440. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102441. /**
  102442. * Gets camera class name
  102443. * @returns StereoscopicArcRotateCamera
  102444. */
  102445. getClassName(): string;
  102446. }
  102447. }
  102448. declare module BABYLON {
  102449. /**
  102450. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  102451. * @see http://doc.babylonjs.com/features/cameras
  102452. */
  102453. export class StereoscopicFreeCamera extends FreeCamera {
  102454. /**
  102455. * Creates a new StereoscopicFreeCamera
  102456. * @param name defines camera name
  102457. * @param position defines initial position
  102458. * @param interaxialDistance defines distance between each color axis
  102459. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102460. * @param scene defines the hosting scene
  102461. */
  102462. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102463. /**
  102464. * Gets camera class name
  102465. * @returns StereoscopicFreeCamera
  102466. */
  102467. getClassName(): string;
  102468. }
  102469. }
  102470. declare module BABYLON {
  102471. /**
  102472. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  102473. * @see http://doc.babylonjs.com/features/cameras
  102474. */
  102475. export class StereoscopicGamepadCamera extends GamepadCamera {
  102476. /**
  102477. * Creates a new StereoscopicGamepadCamera
  102478. * @param name defines camera name
  102479. * @param position defines initial position
  102480. * @param interaxialDistance defines distance between each color axis
  102481. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102482. * @param scene defines the hosting scene
  102483. */
  102484. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102485. /**
  102486. * Gets camera class name
  102487. * @returns StereoscopicGamepadCamera
  102488. */
  102489. getClassName(): string;
  102490. }
  102491. }
  102492. declare module BABYLON {
  102493. /**
  102494. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  102495. * @see http://doc.babylonjs.com/features/cameras
  102496. */
  102497. export class StereoscopicUniversalCamera extends UniversalCamera {
  102498. /**
  102499. * Creates a new StereoscopicUniversalCamera
  102500. * @param name defines camera name
  102501. * @param position defines initial position
  102502. * @param interaxialDistance defines distance between each color axis
  102503. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102504. * @param scene defines the hosting scene
  102505. */
  102506. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102507. /**
  102508. * Gets camera class name
  102509. * @returns StereoscopicUniversalCamera
  102510. */
  102511. getClassName(): string;
  102512. }
  102513. }
  102514. declare module BABYLON {
  102515. /**
  102516. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  102517. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102518. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102519. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102520. */
  102521. export class VirtualJoysticksCamera extends FreeCamera {
  102522. /**
  102523. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  102524. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102525. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102526. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102527. * @param name Define the name of the camera in the scene
  102528. * @param position Define the start position of the camera in the scene
  102529. * @param scene Define the scene the camera belongs to
  102530. */
  102531. constructor(name: string, position: Vector3, scene: Scene);
  102532. /**
  102533. * Gets the current object class name.
  102534. * @return the class name
  102535. */
  102536. getClassName(): string;
  102537. }
  102538. }
  102539. declare module BABYLON {
  102540. /**
  102541. * This represents all the required metrics to create a VR camera.
  102542. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  102543. */
  102544. export class VRCameraMetrics {
  102545. /**
  102546. * Define the horizontal resolution off the screen.
  102547. */
  102548. hResolution: number;
  102549. /**
  102550. * Define the vertical resolution off the screen.
  102551. */
  102552. vResolution: number;
  102553. /**
  102554. * Define the horizontal screen size.
  102555. */
  102556. hScreenSize: number;
  102557. /**
  102558. * Define the vertical screen size.
  102559. */
  102560. vScreenSize: number;
  102561. /**
  102562. * Define the vertical screen center position.
  102563. */
  102564. vScreenCenter: number;
  102565. /**
  102566. * Define the distance of the eyes to the screen.
  102567. */
  102568. eyeToScreenDistance: number;
  102569. /**
  102570. * Define the distance between both lenses
  102571. */
  102572. lensSeparationDistance: number;
  102573. /**
  102574. * Define the distance between both viewer's eyes.
  102575. */
  102576. interpupillaryDistance: number;
  102577. /**
  102578. * Define the distortion factor of the VR postprocess.
  102579. * Please, touch with care.
  102580. */
  102581. distortionK: number[];
  102582. /**
  102583. * Define the chromatic aberration correction factors for the VR post process.
  102584. */
  102585. chromaAbCorrection: number[];
  102586. /**
  102587. * Define the scale factor of the post process.
  102588. * The smaller the better but the slower.
  102589. */
  102590. postProcessScaleFactor: number;
  102591. /**
  102592. * Define an offset for the lens center.
  102593. */
  102594. lensCenterOffset: number;
  102595. /**
  102596. * Define if the current vr camera should compensate the distortion of the lense or not.
  102597. */
  102598. compensateDistortion: boolean;
  102599. /**
  102600. * Defines if multiview should be enabled when rendering (Default: false)
  102601. */
  102602. multiviewEnabled: boolean;
  102603. /**
  102604. * Gets the rendering aspect ratio based on the provided resolutions.
  102605. */
  102606. readonly aspectRatio: number;
  102607. /**
  102608. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  102609. */
  102610. readonly aspectRatioFov: number;
  102611. /**
  102612. * @hidden
  102613. */
  102614. readonly leftHMatrix: Matrix;
  102615. /**
  102616. * @hidden
  102617. */
  102618. readonly rightHMatrix: Matrix;
  102619. /**
  102620. * @hidden
  102621. */
  102622. readonly leftPreViewMatrix: Matrix;
  102623. /**
  102624. * @hidden
  102625. */
  102626. readonly rightPreViewMatrix: Matrix;
  102627. /**
  102628. * Get the default VRMetrics based on the most generic setup.
  102629. * @returns the default vr metrics
  102630. */
  102631. static GetDefault(): VRCameraMetrics;
  102632. }
  102633. }
  102634. declare module BABYLON {
  102635. /** @hidden */
  102636. export var vrDistortionCorrectionPixelShader: {
  102637. name: string;
  102638. shader: string;
  102639. };
  102640. }
  102641. declare module BABYLON {
  102642. /**
  102643. * VRDistortionCorrectionPostProcess used for mobile VR
  102644. */
  102645. export class VRDistortionCorrectionPostProcess extends PostProcess {
  102646. private _isRightEye;
  102647. private _distortionFactors;
  102648. private _postProcessScaleFactor;
  102649. private _lensCenterOffset;
  102650. private _scaleIn;
  102651. private _scaleFactor;
  102652. private _lensCenter;
  102653. /**
  102654. * Initializes the VRDistortionCorrectionPostProcess
  102655. * @param name The name of the effect.
  102656. * @param camera The camera to apply the render pass to.
  102657. * @param isRightEye If this is for the right eye distortion
  102658. * @param vrMetrics All the required metrics for the VR camera
  102659. */
  102660. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  102661. }
  102662. }
  102663. declare module BABYLON {
  102664. /**
  102665. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  102666. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102667. */
  102668. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  102669. /**
  102670. * Creates a new VRDeviceOrientationArcRotateCamera
  102671. * @param name defines camera name
  102672. * @param alpha defines the camera rotation along the logitudinal axis
  102673. * @param beta defines the camera rotation along the latitudinal axis
  102674. * @param radius defines the camera distance from its target
  102675. * @param target defines the camera target
  102676. * @param scene defines the scene the camera belongs to
  102677. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102678. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102679. */
  102680. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102681. /**
  102682. * Gets camera class name
  102683. * @returns VRDeviceOrientationArcRotateCamera
  102684. */
  102685. getClassName(): string;
  102686. }
  102687. }
  102688. declare module BABYLON {
  102689. /**
  102690. * Camera used to simulate VR rendering (based on FreeCamera)
  102691. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102692. */
  102693. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  102694. /**
  102695. * Creates a new VRDeviceOrientationFreeCamera
  102696. * @param name defines camera name
  102697. * @param position defines the start position of the camera
  102698. * @param scene defines the scene the camera belongs to
  102699. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102700. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102701. */
  102702. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102703. /**
  102704. * Gets camera class name
  102705. * @returns VRDeviceOrientationFreeCamera
  102706. */
  102707. getClassName(): string;
  102708. }
  102709. }
  102710. declare module BABYLON {
  102711. /**
  102712. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  102713. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102714. */
  102715. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  102716. /**
  102717. * Creates a new VRDeviceOrientationGamepadCamera
  102718. * @param name defines camera name
  102719. * @param position defines the start position of the camera
  102720. * @param scene defines the scene the camera belongs to
  102721. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102722. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102723. */
  102724. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102725. /**
  102726. * Gets camera class name
  102727. * @returns VRDeviceOrientationGamepadCamera
  102728. */
  102729. getClassName(): string;
  102730. }
  102731. }
  102732. declare module BABYLON {
  102733. /**
  102734. * Base class of materials working in push mode in babylon JS
  102735. * @hidden
  102736. */
  102737. export class PushMaterial extends Material {
  102738. protected _activeEffect: Effect;
  102739. protected _normalMatrix: Matrix;
  102740. /**
  102741. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102742. * This means that the material can keep using a previous shader while a new one is being compiled.
  102743. * This is mostly used when shader parallel compilation is supported (true by default)
  102744. */
  102745. allowShaderHotSwapping: boolean;
  102746. constructor(name: string, scene: Scene);
  102747. getEffect(): Effect;
  102748. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102749. /**
  102750. * Binds the given world matrix to the active effect
  102751. *
  102752. * @param world the matrix to bind
  102753. */
  102754. bindOnlyWorldMatrix(world: Matrix): void;
  102755. /**
  102756. * Binds the given normal matrix to the active effect
  102757. *
  102758. * @param normalMatrix the matrix to bind
  102759. */
  102760. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102761. bind(world: Matrix, mesh?: Mesh): void;
  102762. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102763. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102764. }
  102765. }
  102766. declare module BABYLON {
  102767. /**
  102768. * This groups all the flags used to control the materials channel.
  102769. */
  102770. export class MaterialFlags {
  102771. private static _DiffuseTextureEnabled;
  102772. /**
  102773. * Are diffuse textures enabled in the application.
  102774. */
  102775. static DiffuseTextureEnabled: boolean;
  102776. private static _AmbientTextureEnabled;
  102777. /**
  102778. * Are ambient textures enabled in the application.
  102779. */
  102780. static AmbientTextureEnabled: boolean;
  102781. private static _OpacityTextureEnabled;
  102782. /**
  102783. * Are opacity textures enabled in the application.
  102784. */
  102785. static OpacityTextureEnabled: boolean;
  102786. private static _ReflectionTextureEnabled;
  102787. /**
  102788. * Are reflection textures enabled in the application.
  102789. */
  102790. static ReflectionTextureEnabled: boolean;
  102791. private static _EmissiveTextureEnabled;
  102792. /**
  102793. * Are emissive textures enabled in the application.
  102794. */
  102795. static EmissiveTextureEnabled: boolean;
  102796. private static _SpecularTextureEnabled;
  102797. /**
  102798. * Are specular textures enabled in the application.
  102799. */
  102800. static SpecularTextureEnabled: boolean;
  102801. private static _BumpTextureEnabled;
  102802. /**
  102803. * Are bump textures enabled in the application.
  102804. */
  102805. static BumpTextureEnabled: boolean;
  102806. private static _LightmapTextureEnabled;
  102807. /**
  102808. * Are lightmap textures enabled in the application.
  102809. */
  102810. static LightmapTextureEnabled: boolean;
  102811. private static _RefractionTextureEnabled;
  102812. /**
  102813. * Are refraction textures enabled in the application.
  102814. */
  102815. static RefractionTextureEnabled: boolean;
  102816. private static _ColorGradingTextureEnabled;
  102817. /**
  102818. * Are color grading textures enabled in the application.
  102819. */
  102820. static ColorGradingTextureEnabled: boolean;
  102821. private static _FresnelEnabled;
  102822. /**
  102823. * Are fresnels enabled in the application.
  102824. */
  102825. static FresnelEnabled: boolean;
  102826. private static _ClearCoatTextureEnabled;
  102827. /**
  102828. * Are clear coat textures enabled in the application.
  102829. */
  102830. static ClearCoatTextureEnabled: boolean;
  102831. private static _ClearCoatBumpTextureEnabled;
  102832. /**
  102833. * Are clear coat bump textures enabled in the application.
  102834. */
  102835. static ClearCoatBumpTextureEnabled: boolean;
  102836. private static _ClearCoatTintTextureEnabled;
  102837. /**
  102838. * Are clear coat tint textures enabled in the application.
  102839. */
  102840. static ClearCoatTintTextureEnabled: boolean;
  102841. private static _SheenTextureEnabled;
  102842. /**
  102843. * Are sheen textures enabled in the application.
  102844. */
  102845. static SheenTextureEnabled: boolean;
  102846. private static _AnisotropicTextureEnabled;
  102847. /**
  102848. * Are anisotropic textures enabled in the application.
  102849. */
  102850. static AnisotropicTextureEnabled: boolean;
  102851. private static _ThicknessTextureEnabled;
  102852. /**
  102853. * Are thickness textures enabled in the application.
  102854. */
  102855. static ThicknessTextureEnabled: boolean;
  102856. }
  102857. }
  102858. declare module BABYLON {
  102859. /** @hidden */
  102860. export var defaultFragmentDeclaration: {
  102861. name: string;
  102862. shader: string;
  102863. };
  102864. }
  102865. declare module BABYLON {
  102866. /** @hidden */
  102867. export var defaultUboDeclaration: {
  102868. name: string;
  102869. shader: string;
  102870. };
  102871. }
  102872. declare module BABYLON {
  102873. /** @hidden */
  102874. export var lightFragmentDeclaration: {
  102875. name: string;
  102876. shader: string;
  102877. };
  102878. }
  102879. declare module BABYLON {
  102880. /** @hidden */
  102881. export var lightUboDeclaration: {
  102882. name: string;
  102883. shader: string;
  102884. };
  102885. }
  102886. declare module BABYLON {
  102887. /** @hidden */
  102888. export var lightsFragmentFunctions: {
  102889. name: string;
  102890. shader: string;
  102891. };
  102892. }
  102893. declare module BABYLON {
  102894. /** @hidden */
  102895. export var shadowsFragmentFunctions: {
  102896. name: string;
  102897. shader: string;
  102898. };
  102899. }
  102900. declare module BABYLON {
  102901. /** @hidden */
  102902. export var fresnelFunction: {
  102903. name: string;
  102904. shader: string;
  102905. };
  102906. }
  102907. declare module BABYLON {
  102908. /** @hidden */
  102909. export var reflectionFunction: {
  102910. name: string;
  102911. shader: string;
  102912. };
  102913. }
  102914. declare module BABYLON {
  102915. /** @hidden */
  102916. export var bumpFragmentFunctions: {
  102917. name: string;
  102918. shader: string;
  102919. };
  102920. }
  102921. declare module BABYLON {
  102922. /** @hidden */
  102923. export var logDepthDeclaration: {
  102924. name: string;
  102925. shader: string;
  102926. };
  102927. }
  102928. declare module BABYLON {
  102929. /** @hidden */
  102930. export var bumpFragment: {
  102931. name: string;
  102932. shader: string;
  102933. };
  102934. }
  102935. declare module BABYLON {
  102936. /** @hidden */
  102937. export var depthPrePass: {
  102938. name: string;
  102939. shader: string;
  102940. };
  102941. }
  102942. declare module BABYLON {
  102943. /** @hidden */
  102944. export var lightFragment: {
  102945. name: string;
  102946. shader: string;
  102947. };
  102948. }
  102949. declare module BABYLON {
  102950. /** @hidden */
  102951. export var logDepthFragment: {
  102952. name: string;
  102953. shader: string;
  102954. };
  102955. }
  102956. declare module BABYLON {
  102957. /** @hidden */
  102958. export var defaultPixelShader: {
  102959. name: string;
  102960. shader: string;
  102961. };
  102962. }
  102963. declare module BABYLON {
  102964. /** @hidden */
  102965. export var defaultVertexDeclaration: {
  102966. name: string;
  102967. shader: string;
  102968. };
  102969. }
  102970. declare module BABYLON {
  102971. /** @hidden */
  102972. export var bumpVertexDeclaration: {
  102973. name: string;
  102974. shader: string;
  102975. };
  102976. }
  102977. declare module BABYLON {
  102978. /** @hidden */
  102979. export var bumpVertex: {
  102980. name: string;
  102981. shader: string;
  102982. };
  102983. }
  102984. declare module BABYLON {
  102985. /** @hidden */
  102986. export var fogVertex: {
  102987. name: string;
  102988. shader: string;
  102989. };
  102990. }
  102991. declare module BABYLON {
  102992. /** @hidden */
  102993. export var shadowsVertex: {
  102994. name: string;
  102995. shader: string;
  102996. };
  102997. }
  102998. declare module BABYLON {
  102999. /** @hidden */
  103000. export var pointCloudVertex: {
  103001. name: string;
  103002. shader: string;
  103003. };
  103004. }
  103005. declare module BABYLON {
  103006. /** @hidden */
  103007. export var logDepthVertex: {
  103008. name: string;
  103009. shader: string;
  103010. };
  103011. }
  103012. declare module BABYLON {
  103013. /** @hidden */
  103014. export var defaultVertexShader: {
  103015. name: string;
  103016. shader: string;
  103017. };
  103018. }
  103019. declare module BABYLON {
  103020. /** @hidden */
  103021. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103022. MAINUV1: boolean;
  103023. MAINUV2: boolean;
  103024. DIFFUSE: boolean;
  103025. DIFFUSEDIRECTUV: number;
  103026. AMBIENT: boolean;
  103027. AMBIENTDIRECTUV: number;
  103028. OPACITY: boolean;
  103029. OPACITYDIRECTUV: number;
  103030. OPACITYRGB: boolean;
  103031. REFLECTION: boolean;
  103032. EMISSIVE: boolean;
  103033. EMISSIVEDIRECTUV: number;
  103034. SPECULAR: boolean;
  103035. SPECULARDIRECTUV: number;
  103036. BUMP: boolean;
  103037. BUMPDIRECTUV: number;
  103038. PARALLAX: boolean;
  103039. PARALLAXOCCLUSION: boolean;
  103040. SPECULAROVERALPHA: boolean;
  103041. CLIPPLANE: boolean;
  103042. CLIPPLANE2: boolean;
  103043. CLIPPLANE3: boolean;
  103044. CLIPPLANE4: boolean;
  103045. ALPHATEST: boolean;
  103046. DEPTHPREPASS: boolean;
  103047. ALPHAFROMDIFFUSE: boolean;
  103048. POINTSIZE: boolean;
  103049. FOG: boolean;
  103050. SPECULARTERM: boolean;
  103051. DIFFUSEFRESNEL: boolean;
  103052. OPACITYFRESNEL: boolean;
  103053. REFLECTIONFRESNEL: boolean;
  103054. REFRACTIONFRESNEL: boolean;
  103055. EMISSIVEFRESNEL: boolean;
  103056. FRESNEL: boolean;
  103057. NORMAL: boolean;
  103058. UV1: boolean;
  103059. UV2: boolean;
  103060. VERTEXCOLOR: boolean;
  103061. VERTEXALPHA: boolean;
  103062. NUM_BONE_INFLUENCERS: number;
  103063. BonesPerMesh: number;
  103064. BONETEXTURE: boolean;
  103065. INSTANCES: boolean;
  103066. GLOSSINESS: boolean;
  103067. ROUGHNESS: boolean;
  103068. EMISSIVEASILLUMINATION: boolean;
  103069. LINKEMISSIVEWITHDIFFUSE: boolean;
  103070. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103071. LIGHTMAP: boolean;
  103072. LIGHTMAPDIRECTUV: number;
  103073. OBJECTSPACE_NORMALMAP: boolean;
  103074. USELIGHTMAPASSHADOWMAP: boolean;
  103075. REFLECTIONMAP_3D: boolean;
  103076. REFLECTIONMAP_SPHERICAL: boolean;
  103077. REFLECTIONMAP_PLANAR: boolean;
  103078. REFLECTIONMAP_CUBIC: boolean;
  103079. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103080. REFLECTIONMAP_PROJECTION: boolean;
  103081. REFLECTIONMAP_SKYBOX: boolean;
  103082. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103083. REFLECTIONMAP_EXPLICIT: boolean;
  103084. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103085. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103086. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103087. INVERTCUBICMAP: boolean;
  103088. LOGARITHMICDEPTH: boolean;
  103089. REFRACTION: boolean;
  103090. REFRACTIONMAP_3D: boolean;
  103091. REFLECTIONOVERALPHA: boolean;
  103092. TWOSIDEDLIGHTING: boolean;
  103093. SHADOWFLOAT: boolean;
  103094. MORPHTARGETS: boolean;
  103095. MORPHTARGETS_NORMAL: boolean;
  103096. MORPHTARGETS_TANGENT: boolean;
  103097. MORPHTARGETS_UV: boolean;
  103098. NUM_MORPH_INFLUENCERS: number;
  103099. NONUNIFORMSCALING: boolean;
  103100. PREMULTIPLYALPHA: boolean;
  103101. IMAGEPROCESSING: boolean;
  103102. VIGNETTE: boolean;
  103103. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103104. VIGNETTEBLENDMODEOPAQUE: boolean;
  103105. TONEMAPPING: boolean;
  103106. TONEMAPPING_ACES: boolean;
  103107. CONTRAST: boolean;
  103108. COLORCURVES: boolean;
  103109. COLORGRADING: boolean;
  103110. COLORGRADING3D: boolean;
  103111. SAMPLER3DGREENDEPTH: boolean;
  103112. SAMPLER3DBGRMAP: boolean;
  103113. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103114. MULTIVIEW: boolean;
  103115. /**
  103116. * If the reflection texture on this material is in linear color space
  103117. * @hidden
  103118. */
  103119. IS_REFLECTION_LINEAR: boolean;
  103120. /**
  103121. * If the refraction texture on this material is in linear color space
  103122. * @hidden
  103123. */
  103124. IS_REFRACTION_LINEAR: boolean;
  103125. EXPOSURE: boolean;
  103126. constructor();
  103127. setReflectionMode(modeToEnable: string): void;
  103128. }
  103129. /**
  103130. * This is the default material used in Babylon. It is the best trade off between quality
  103131. * and performances.
  103132. * @see http://doc.babylonjs.com/babylon101/materials
  103133. */
  103134. export class StandardMaterial extends PushMaterial {
  103135. private _diffuseTexture;
  103136. /**
  103137. * The basic texture of the material as viewed under a light.
  103138. */
  103139. diffuseTexture: Nullable<BaseTexture>;
  103140. private _ambientTexture;
  103141. /**
  103142. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  103143. */
  103144. ambientTexture: Nullable<BaseTexture>;
  103145. private _opacityTexture;
  103146. /**
  103147. * Define the transparency of the material from a texture.
  103148. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  103149. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  103150. */
  103151. opacityTexture: Nullable<BaseTexture>;
  103152. private _reflectionTexture;
  103153. /**
  103154. * Define the texture used to display the reflection.
  103155. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103156. */
  103157. reflectionTexture: Nullable<BaseTexture>;
  103158. private _emissiveTexture;
  103159. /**
  103160. * Define texture of the material as if self lit.
  103161. * This will be mixed in the final result even in the absence of light.
  103162. */
  103163. emissiveTexture: Nullable<BaseTexture>;
  103164. private _specularTexture;
  103165. /**
  103166. * Define how the color and intensity of the highlight given by the light in the material.
  103167. */
  103168. specularTexture: Nullable<BaseTexture>;
  103169. private _bumpTexture;
  103170. /**
  103171. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103172. * 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.
  103173. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  103174. */
  103175. bumpTexture: Nullable<BaseTexture>;
  103176. private _lightmapTexture;
  103177. /**
  103178. * Complex lighting can be computationally expensive to compute at runtime.
  103179. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103180. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  103181. */
  103182. lightmapTexture: Nullable<BaseTexture>;
  103183. private _refractionTexture;
  103184. /**
  103185. * Define the texture used to display the refraction.
  103186. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103187. */
  103188. refractionTexture: Nullable<BaseTexture>;
  103189. /**
  103190. * The color of the material lit by the environmental background lighting.
  103191. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103192. */
  103193. ambientColor: Color3;
  103194. /**
  103195. * The basic color of the material as viewed under a light.
  103196. */
  103197. diffuseColor: Color3;
  103198. /**
  103199. * Define how the color and intensity of the highlight given by the light in the material.
  103200. */
  103201. specularColor: Color3;
  103202. /**
  103203. * Define the color of the material as if self lit.
  103204. * This will be mixed in the final result even in the absence of light.
  103205. */
  103206. emissiveColor: Color3;
  103207. /**
  103208. * Defines how sharp are the highlights in the material.
  103209. * The bigger the value the sharper giving a more glossy feeling to the result.
  103210. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103211. */
  103212. specularPower: number;
  103213. private _useAlphaFromDiffuseTexture;
  103214. /**
  103215. * Does the transparency come from the diffuse texture alpha channel.
  103216. */
  103217. useAlphaFromDiffuseTexture: boolean;
  103218. private _useEmissiveAsIllumination;
  103219. /**
  103220. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103221. */
  103222. useEmissiveAsIllumination: boolean;
  103223. private _linkEmissiveWithDiffuse;
  103224. /**
  103225. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103226. * the emissive level when the final color is close to one.
  103227. */
  103228. linkEmissiveWithDiffuse: boolean;
  103229. private _useSpecularOverAlpha;
  103230. /**
  103231. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103232. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103233. */
  103234. useSpecularOverAlpha: boolean;
  103235. private _useReflectionOverAlpha;
  103236. /**
  103237. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103238. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103239. */
  103240. useReflectionOverAlpha: boolean;
  103241. private _disableLighting;
  103242. /**
  103243. * Does lights from the scene impacts this material.
  103244. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103245. */
  103246. disableLighting: boolean;
  103247. private _useObjectSpaceNormalMap;
  103248. /**
  103249. * Allows using an object space normal map (instead of tangent space).
  103250. */
  103251. useObjectSpaceNormalMap: boolean;
  103252. private _useParallax;
  103253. /**
  103254. * Is parallax enabled or not.
  103255. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103256. */
  103257. useParallax: boolean;
  103258. private _useParallaxOcclusion;
  103259. /**
  103260. * Is parallax occlusion enabled or not.
  103261. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103262. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103263. */
  103264. useParallaxOcclusion: boolean;
  103265. /**
  103266. * 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.
  103267. */
  103268. parallaxScaleBias: number;
  103269. private _roughness;
  103270. /**
  103271. * Helps to define how blurry the reflections should appears in the material.
  103272. */
  103273. roughness: number;
  103274. /**
  103275. * In case of refraction, define the value of the index of refraction.
  103276. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103277. */
  103278. indexOfRefraction: number;
  103279. /**
  103280. * Invert the refraction texture alongside the y axis.
  103281. * It can be useful with procedural textures or probe for instance.
  103282. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103283. */
  103284. invertRefractionY: boolean;
  103285. /**
  103286. * Defines the alpha limits in alpha test mode.
  103287. */
  103288. alphaCutOff: number;
  103289. private _useLightmapAsShadowmap;
  103290. /**
  103291. * In case of light mapping, define whether the map contains light or shadow informations.
  103292. */
  103293. useLightmapAsShadowmap: boolean;
  103294. private _diffuseFresnelParameters;
  103295. /**
  103296. * Define the diffuse fresnel parameters of the material.
  103297. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103298. */
  103299. diffuseFresnelParameters: FresnelParameters;
  103300. private _opacityFresnelParameters;
  103301. /**
  103302. * Define the opacity fresnel parameters of the material.
  103303. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103304. */
  103305. opacityFresnelParameters: FresnelParameters;
  103306. private _reflectionFresnelParameters;
  103307. /**
  103308. * Define the reflection fresnel parameters of the material.
  103309. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103310. */
  103311. reflectionFresnelParameters: FresnelParameters;
  103312. private _refractionFresnelParameters;
  103313. /**
  103314. * Define the refraction fresnel parameters of the material.
  103315. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103316. */
  103317. refractionFresnelParameters: FresnelParameters;
  103318. private _emissiveFresnelParameters;
  103319. /**
  103320. * Define the emissive fresnel parameters of the material.
  103321. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103322. */
  103323. emissiveFresnelParameters: FresnelParameters;
  103324. private _useReflectionFresnelFromSpecular;
  103325. /**
  103326. * If true automatically deducts the fresnels values from the material specularity.
  103327. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103328. */
  103329. useReflectionFresnelFromSpecular: boolean;
  103330. private _useGlossinessFromSpecularMapAlpha;
  103331. /**
  103332. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103333. */
  103334. useGlossinessFromSpecularMapAlpha: boolean;
  103335. private _maxSimultaneousLights;
  103336. /**
  103337. * Defines the maximum number of lights that can be used in the material
  103338. */
  103339. maxSimultaneousLights: number;
  103340. private _invertNormalMapX;
  103341. /**
  103342. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103343. */
  103344. invertNormalMapX: boolean;
  103345. private _invertNormalMapY;
  103346. /**
  103347. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103348. */
  103349. invertNormalMapY: boolean;
  103350. private _twoSidedLighting;
  103351. /**
  103352. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103353. */
  103354. twoSidedLighting: boolean;
  103355. /**
  103356. * Default configuration related to image processing available in the standard Material.
  103357. */
  103358. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103359. /**
  103360. * Gets the image processing configuration used either in this material.
  103361. */
  103362. /**
  103363. * Sets the Default image processing configuration used either in the this material.
  103364. *
  103365. * If sets to null, the scene one is in use.
  103366. */
  103367. imageProcessingConfiguration: ImageProcessingConfiguration;
  103368. /**
  103369. * Keep track of the image processing observer to allow dispose and replace.
  103370. */
  103371. private _imageProcessingObserver;
  103372. /**
  103373. * Attaches a new image processing configuration to the Standard Material.
  103374. * @param configuration
  103375. */
  103376. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103377. /**
  103378. * Gets wether the color curves effect is enabled.
  103379. */
  103380. /**
  103381. * Sets wether the color curves effect is enabled.
  103382. */
  103383. cameraColorCurvesEnabled: boolean;
  103384. /**
  103385. * Gets wether the color grading effect is enabled.
  103386. */
  103387. /**
  103388. * Gets wether the color grading effect is enabled.
  103389. */
  103390. cameraColorGradingEnabled: boolean;
  103391. /**
  103392. * Gets wether tonemapping is enabled or not.
  103393. */
  103394. /**
  103395. * Sets wether tonemapping is enabled or not
  103396. */
  103397. cameraToneMappingEnabled: boolean;
  103398. /**
  103399. * The camera exposure used on this material.
  103400. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103401. * This corresponds to a photographic exposure.
  103402. */
  103403. /**
  103404. * The camera exposure used on this material.
  103405. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103406. * This corresponds to a photographic exposure.
  103407. */
  103408. cameraExposure: number;
  103409. /**
  103410. * Gets The camera contrast used on this material.
  103411. */
  103412. /**
  103413. * Sets The camera contrast used on this material.
  103414. */
  103415. cameraContrast: number;
  103416. /**
  103417. * Gets the Color Grading 2D Lookup Texture.
  103418. */
  103419. /**
  103420. * Sets the Color Grading 2D Lookup Texture.
  103421. */
  103422. cameraColorGradingTexture: Nullable<BaseTexture>;
  103423. /**
  103424. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103425. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103426. * 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;
  103427. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103428. */
  103429. /**
  103430. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103431. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103432. * 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;
  103433. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103434. */
  103435. cameraColorCurves: Nullable<ColorCurves>;
  103436. /**
  103437. * Custom callback helping to override the default shader used in the material.
  103438. */
  103439. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  103440. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103441. protected _worldViewProjectionMatrix: Matrix;
  103442. protected _globalAmbientColor: Color3;
  103443. protected _useLogarithmicDepth: boolean;
  103444. /**
  103445. * Instantiates a new standard material.
  103446. * This is the default material used in Babylon. It is the best trade off between quality
  103447. * and performances.
  103448. * @see http://doc.babylonjs.com/babylon101/materials
  103449. * @param name Define the name of the material in the scene
  103450. * @param scene Define the scene the material belong to
  103451. */
  103452. constructor(name: string, scene: Scene);
  103453. /**
  103454. * Gets a boolean indicating that current material needs to register RTT
  103455. */
  103456. readonly hasRenderTargetTextures: boolean;
  103457. /**
  103458. * Gets the current class name of the material e.g. "StandardMaterial"
  103459. * Mainly use in serialization.
  103460. * @returns the class name
  103461. */
  103462. getClassName(): string;
  103463. /**
  103464. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103465. * You can try switching to logarithmic depth.
  103466. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103467. */
  103468. useLogarithmicDepth: boolean;
  103469. /**
  103470. * Specifies if the material will require alpha blending
  103471. * @returns a boolean specifying if alpha blending is needed
  103472. */
  103473. needAlphaBlending(): boolean;
  103474. /**
  103475. * Specifies if this material should be rendered in alpha test mode
  103476. * @returns a boolean specifying if an alpha test is needed.
  103477. */
  103478. needAlphaTesting(): boolean;
  103479. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103480. /**
  103481. * Get the texture used for alpha test purpose.
  103482. * @returns the diffuse texture in case of the standard material.
  103483. */
  103484. getAlphaTestTexture(): Nullable<BaseTexture>;
  103485. /**
  103486. * Get if the submesh is ready to be used and all its information available.
  103487. * Child classes can use it to update shaders
  103488. * @param mesh defines the mesh to check
  103489. * @param subMesh defines which submesh to check
  103490. * @param useInstances specifies that instances should be used
  103491. * @returns a boolean indicating that the submesh is ready or not
  103492. */
  103493. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103494. /**
  103495. * Builds the material UBO layouts.
  103496. * Used internally during the effect preparation.
  103497. */
  103498. buildUniformLayout(): void;
  103499. /**
  103500. * Unbinds the material from the mesh
  103501. */
  103502. unbind(): void;
  103503. /**
  103504. * Binds the submesh to this material by preparing the effect and shader to draw
  103505. * @param world defines the world transformation matrix
  103506. * @param mesh defines the mesh containing the submesh
  103507. * @param subMesh defines the submesh to bind the material to
  103508. */
  103509. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103510. /**
  103511. * Get the list of animatables in the material.
  103512. * @returns the list of animatables object used in the material
  103513. */
  103514. getAnimatables(): IAnimatable[];
  103515. /**
  103516. * Gets the active textures from the material
  103517. * @returns an array of textures
  103518. */
  103519. getActiveTextures(): BaseTexture[];
  103520. /**
  103521. * Specifies if the material uses a texture
  103522. * @param texture defines the texture to check against the material
  103523. * @returns a boolean specifying if the material uses the texture
  103524. */
  103525. hasTexture(texture: BaseTexture): boolean;
  103526. /**
  103527. * Disposes the material
  103528. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103529. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103530. */
  103531. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103532. /**
  103533. * Makes a duplicate of the material, and gives it a new name
  103534. * @param name defines the new name for the duplicated material
  103535. * @returns the cloned material
  103536. */
  103537. clone(name: string): StandardMaterial;
  103538. /**
  103539. * Serializes this material in a JSON representation
  103540. * @returns the serialized material object
  103541. */
  103542. serialize(): any;
  103543. /**
  103544. * Creates a standard material from parsed material data
  103545. * @param source defines the JSON representation of the material
  103546. * @param scene defines the hosting scene
  103547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103548. * @returns a new standard material
  103549. */
  103550. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103551. /**
  103552. * Are diffuse textures enabled in the application.
  103553. */
  103554. static DiffuseTextureEnabled: boolean;
  103555. /**
  103556. * Are ambient textures enabled in the application.
  103557. */
  103558. static AmbientTextureEnabled: boolean;
  103559. /**
  103560. * Are opacity textures enabled in the application.
  103561. */
  103562. static OpacityTextureEnabled: boolean;
  103563. /**
  103564. * Are reflection textures enabled in the application.
  103565. */
  103566. static ReflectionTextureEnabled: boolean;
  103567. /**
  103568. * Are emissive textures enabled in the application.
  103569. */
  103570. static EmissiveTextureEnabled: boolean;
  103571. /**
  103572. * Are specular textures enabled in the application.
  103573. */
  103574. static SpecularTextureEnabled: boolean;
  103575. /**
  103576. * Are bump textures enabled in the application.
  103577. */
  103578. static BumpTextureEnabled: boolean;
  103579. /**
  103580. * Are lightmap textures enabled in the application.
  103581. */
  103582. static LightmapTextureEnabled: boolean;
  103583. /**
  103584. * Are refraction textures enabled in the application.
  103585. */
  103586. static RefractionTextureEnabled: boolean;
  103587. /**
  103588. * Are color grading textures enabled in the application.
  103589. */
  103590. static ColorGradingTextureEnabled: boolean;
  103591. /**
  103592. * Are fresnels enabled in the application.
  103593. */
  103594. static FresnelEnabled: boolean;
  103595. }
  103596. }
  103597. declare module BABYLON {
  103598. /**
  103599. * A class extending Texture allowing drawing on a texture
  103600. * @see http://doc.babylonjs.com/how_to/dynamictexture
  103601. */
  103602. export class DynamicTexture extends Texture {
  103603. private _generateMipMaps;
  103604. private _canvas;
  103605. private _context;
  103606. private _engine;
  103607. /**
  103608. * Creates a DynamicTexture
  103609. * @param name defines the name of the texture
  103610. * @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
  103611. * @param scene defines the scene where you want the texture
  103612. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  103613. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  103614. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  103615. */
  103616. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  103617. /**
  103618. * Get the current class name of the texture useful for serialization or dynamic coding.
  103619. * @returns "DynamicTexture"
  103620. */
  103621. getClassName(): string;
  103622. /**
  103623. * Gets the current state of canRescale
  103624. */
  103625. readonly canRescale: boolean;
  103626. private _recreate;
  103627. /**
  103628. * Scales the texture
  103629. * @param ratio the scale factor to apply to both width and height
  103630. */
  103631. scale(ratio: number): void;
  103632. /**
  103633. * Resizes the texture
  103634. * @param width the new width
  103635. * @param height the new height
  103636. */
  103637. scaleTo(width: number, height: number): void;
  103638. /**
  103639. * Gets the context of the canvas used by the texture
  103640. * @returns the canvas context of the dynamic texture
  103641. */
  103642. getContext(): CanvasRenderingContext2D;
  103643. /**
  103644. * Clears the texture
  103645. */
  103646. clear(): void;
  103647. /**
  103648. * Updates the texture
  103649. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103650. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  103651. */
  103652. update(invertY?: boolean, premulAlpha?: boolean): void;
  103653. /**
  103654. * Draws text onto the texture
  103655. * @param text defines the text to be drawn
  103656. * @param x defines the placement of the text from the left
  103657. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  103658. * @param font defines the font to be used with font-style, font-size, font-name
  103659. * @param color defines the color used for the text
  103660. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  103661. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103662. * @param update defines whether texture is immediately update (default is true)
  103663. */
  103664. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  103665. /**
  103666. * Clones the texture
  103667. * @returns the clone of the texture.
  103668. */
  103669. clone(): DynamicTexture;
  103670. /**
  103671. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  103672. * @returns a serialized dynamic texture object
  103673. */
  103674. serialize(): any;
  103675. /** @hidden */
  103676. _rebuild(): void;
  103677. }
  103678. }
  103679. declare module BABYLON {
  103680. /** @hidden */
  103681. export var imageProcessingPixelShader: {
  103682. name: string;
  103683. shader: string;
  103684. };
  103685. }
  103686. declare module BABYLON {
  103687. /**
  103688. * ImageProcessingPostProcess
  103689. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103690. */
  103691. export class ImageProcessingPostProcess extends PostProcess {
  103692. /**
  103693. * Default configuration related to image processing available in the PBR Material.
  103694. */
  103695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103696. /**
  103697. * Gets the image processing configuration used either in this material.
  103698. */
  103699. /**
  103700. * Sets the Default image processing configuration used either in the this material.
  103701. *
  103702. * If sets to null, the scene one is in use.
  103703. */
  103704. imageProcessingConfiguration: ImageProcessingConfiguration;
  103705. /**
  103706. * Keep track of the image processing observer to allow dispose and replace.
  103707. */
  103708. private _imageProcessingObserver;
  103709. /**
  103710. * Attaches a new image processing configuration to the PBR Material.
  103711. * @param configuration
  103712. */
  103713. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103714. /**
  103715. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103716. */
  103717. /**
  103718. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103719. */
  103720. colorCurves: Nullable<ColorCurves>;
  103721. /**
  103722. * Gets wether the color curves effect is enabled.
  103723. */
  103724. /**
  103725. * Sets wether the color curves effect is enabled.
  103726. */
  103727. colorCurvesEnabled: boolean;
  103728. /**
  103729. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103730. */
  103731. /**
  103732. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103733. */
  103734. colorGradingTexture: Nullable<BaseTexture>;
  103735. /**
  103736. * Gets wether the color grading effect is enabled.
  103737. */
  103738. /**
  103739. * Gets wether the color grading effect is enabled.
  103740. */
  103741. colorGradingEnabled: boolean;
  103742. /**
  103743. * Gets exposure used in the effect.
  103744. */
  103745. /**
  103746. * Sets exposure used in the effect.
  103747. */
  103748. exposure: number;
  103749. /**
  103750. * Gets wether tonemapping is enabled or not.
  103751. */
  103752. /**
  103753. * Sets wether tonemapping is enabled or not
  103754. */
  103755. toneMappingEnabled: boolean;
  103756. /**
  103757. * Gets the type of tone mapping effect.
  103758. */
  103759. /**
  103760. * Sets the type of tone mapping effect.
  103761. */
  103762. toneMappingType: number;
  103763. /**
  103764. * Gets contrast used in the effect.
  103765. */
  103766. /**
  103767. * Sets contrast used in the effect.
  103768. */
  103769. contrast: number;
  103770. /**
  103771. * Gets Vignette stretch size.
  103772. */
  103773. /**
  103774. * Sets Vignette stretch size.
  103775. */
  103776. vignetteStretch: number;
  103777. /**
  103778. * Gets Vignette centre X Offset.
  103779. */
  103780. /**
  103781. * Sets Vignette centre X Offset.
  103782. */
  103783. vignetteCentreX: number;
  103784. /**
  103785. * Gets Vignette centre Y Offset.
  103786. */
  103787. /**
  103788. * Sets Vignette centre Y Offset.
  103789. */
  103790. vignetteCentreY: number;
  103791. /**
  103792. * Gets Vignette weight or intensity of the vignette effect.
  103793. */
  103794. /**
  103795. * Sets Vignette weight or intensity of the vignette effect.
  103796. */
  103797. vignetteWeight: number;
  103798. /**
  103799. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103800. * if vignetteEnabled is set to true.
  103801. */
  103802. /**
  103803. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103804. * if vignetteEnabled is set to true.
  103805. */
  103806. vignetteColor: Color4;
  103807. /**
  103808. * Gets Camera field of view used by the Vignette effect.
  103809. */
  103810. /**
  103811. * Sets Camera field of view used by the Vignette effect.
  103812. */
  103813. vignetteCameraFov: number;
  103814. /**
  103815. * Gets the vignette blend mode allowing different kind of effect.
  103816. */
  103817. /**
  103818. * Sets the vignette blend mode allowing different kind of effect.
  103819. */
  103820. vignetteBlendMode: number;
  103821. /**
  103822. * Gets wether the vignette effect is enabled.
  103823. */
  103824. /**
  103825. * Sets wether the vignette effect is enabled.
  103826. */
  103827. vignetteEnabled: boolean;
  103828. private _fromLinearSpace;
  103829. /**
  103830. * Gets wether the input of the processing is in Gamma or Linear Space.
  103831. */
  103832. /**
  103833. * Sets wether the input of the processing is in Gamma or Linear Space.
  103834. */
  103835. fromLinearSpace: boolean;
  103836. /**
  103837. * Defines cache preventing GC.
  103838. */
  103839. private _defines;
  103840. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103841. /**
  103842. * "ImageProcessingPostProcess"
  103843. * @returns "ImageProcessingPostProcess"
  103844. */
  103845. getClassName(): string;
  103846. protected _updateParameters(): void;
  103847. dispose(camera?: Camera): void;
  103848. }
  103849. }
  103850. declare module BABYLON {
  103851. /**
  103852. * Class containing static functions to help procedurally build meshes
  103853. */
  103854. export class GroundBuilder {
  103855. /**
  103856. * Creates a ground mesh
  103857. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  103858. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  103859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103860. * @param name defines the name of the mesh
  103861. * @param options defines the options used to create the mesh
  103862. * @param scene defines the hosting scene
  103863. * @returns the ground mesh
  103864. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  103865. */
  103866. static CreateGround(name: string, options: {
  103867. width?: number;
  103868. height?: number;
  103869. subdivisions?: number;
  103870. subdivisionsX?: number;
  103871. subdivisionsY?: number;
  103872. updatable?: boolean;
  103873. }, scene: any): Mesh;
  103874. /**
  103875. * Creates a tiled ground mesh
  103876. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  103877. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  103878. * * 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
  103879. * * 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
  103880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103881. * @param name defines the name of the mesh
  103882. * @param options defines the options used to create the mesh
  103883. * @param scene defines the hosting scene
  103884. * @returns the tiled ground mesh
  103885. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  103886. */
  103887. static CreateTiledGround(name: string, options: {
  103888. xmin: number;
  103889. zmin: number;
  103890. xmax: number;
  103891. zmax: number;
  103892. subdivisions?: {
  103893. w: number;
  103894. h: number;
  103895. };
  103896. precision?: {
  103897. w: number;
  103898. h: number;
  103899. };
  103900. updatable?: boolean;
  103901. }, scene?: Nullable<Scene>): Mesh;
  103902. /**
  103903. * Creates a ground mesh from a height map
  103904. * * The parameter `url` sets the URL of the height map image resource.
  103905. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  103906. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  103907. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  103908. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  103909. * * 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.
  103910. * * 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).
  103911. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  103912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103913. * @param name defines the name of the mesh
  103914. * @param url defines the url to the height map
  103915. * @param options defines the options used to create the mesh
  103916. * @param scene defines the hosting scene
  103917. * @returns the ground mesh
  103918. * @see https://doc.babylonjs.com/babylon101/height_map
  103919. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  103920. */
  103921. static CreateGroundFromHeightMap(name: string, url: string, options: {
  103922. width?: number;
  103923. height?: number;
  103924. subdivisions?: number;
  103925. minHeight?: number;
  103926. maxHeight?: number;
  103927. colorFilter?: Color3;
  103928. alphaFilter?: number;
  103929. updatable?: boolean;
  103930. onReady?: (mesh: GroundMesh) => void;
  103931. }, scene?: Nullable<Scene>): GroundMesh;
  103932. }
  103933. }
  103934. declare module BABYLON {
  103935. /**
  103936. * Class containing static functions to help procedurally build meshes
  103937. */
  103938. export class TorusBuilder {
  103939. /**
  103940. * Creates a torus mesh
  103941. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103942. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103943. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103947. * @param name defines the name of the mesh
  103948. * @param options defines the options used to create the mesh
  103949. * @param scene defines the hosting scene
  103950. * @returns the torus mesh
  103951. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103952. */
  103953. static CreateTorus(name: string, options: {
  103954. diameter?: number;
  103955. thickness?: number;
  103956. tessellation?: number;
  103957. updatable?: boolean;
  103958. sideOrientation?: number;
  103959. frontUVs?: Vector4;
  103960. backUVs?: Vector4;
  103961. }, scene: any): Mesh;
  103962. }
  103963. }
  103964. declare module BABYLON {
  103965. /**
  103966. * Class containing static functions to help procedurally build meshes
  103967. */
  103968. export class CylinderBuilder {
  103969. /**
  103970. * Creates a cylinder or a cone mesh
  103971. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103972. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103973. * * 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.
  103974. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103975. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103976. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103977. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103978. * * 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).
  103979. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103980. * * 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).
  103981. * * 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
  103982. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103983. * * 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
  103984. * * 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.
  103985. * * If `enclose` is false, a ring surface is one element.
  103986. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103987. * * 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
  103988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103991. * @param name defines the name of the mesh
  103992. * @param options defines the options used to create the mesh
  103993. * @param scene defines the hosting scene
  103994. * @returns the cylinder mesh
  103995. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103996. */
  103997. static CreateCylinder(name: string, options: {
  103998. height?: number;
  103999. diameterTop?: number;
  104000. diameterBottom?: number;
  104001. diameter?: number;
  104002. tessellation?: number;
  104003. subdivisions?: number;
  104004. arc?: number;
  104005. faceColors?: Color4[];
  104006. faceUV?: Vector4[];
  104007. updatable?: boolean;
  104008. hasRings?: boolean;
  104009. enclose?: boolean;
  104010. cap?: number;
  104011. sideOrientation?: number;
  104012. frontUVs?: Vector4;
  104013. backUVs?: Vector4;
  104014. }, scene: any): Mesh;
  104015. }
  104016. }
  104017. declare module BABYLON {
  104018. /**
  104019. * Options to modify the vr teleportation behavior.
  104020. */
  104021. export interface VRTeleportationOptions {
  104022. /**
  104023. * The name of the mesh which should be used as the teleportation floor. (default: null)
  104024. */
  104025. floorMeshName?: string;
  104026. /**
  104027. * A list of meshes to be used as the teleportation floor. (default: empty)
  104028. */
  104029. floorMeshes?: Mesh[];
  104030. }
  104031. /**
  104032. * Options to modify the vr experience helper's behavior.
  104033. */
  104034. export interface VRExperienceHelperOptions extends WebVROptions {
  104035. /**
  104036. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  104037. */
  104038. createDeviceOrientationCamera?: boolean;
  104039. /**
  104040. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  104041. */
  104042. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  104043. /**
  104044. * Uses the main button on the controller to toggle the laser casted. (default: true)
  104045. */
  104046. laserToggle?: boolean;
  104047. /**
  104048. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  104049. */
  104050. floorMeshes?: Mesh[];
  104051. /**
  104052. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  104053. */
  104054. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  104055. }
  104056. /**
  104057. * Event containing information after VR has been entered
  104058. */
  104059. export class OnAfterEnteringVRObservableEvent {
  104060. /**
  104061. * If entering vr was successful
  104062. */
  104063. success: boolean;
  104064. }
  104065. /**
  104066. * Helps to quickly add VR support to an existing scene.
  104067. * See http://doc.babylonjs.com/how_to/webvr_helper
  104068. */
  104069. export class VRExperienceHelper {
  104070. /** Options to modify the vr experience helper's behavior. */
  104071. webVROptions: VRExperienceHelperOptions;
  104072. private _scene;
  104073. private _position;
  104074. private _btnVR;
  104075. private _btnVRDisplayed;
  104076. private _webVRsupported;
  104077. private _webVRready;
  104078. private _webVRrequesting;
  104079. private _webVRpresenting;
  104080. private _hasEnteredVR;
  104081. private _fullscreenVRpresenting;
  104082. private _canvas;
  104083. private _webVRCamera;
  104084. private _vrDeviceOrientationCamera;
  104085. private _deviceOrientationCamera;
  104086. private _existingCamera;
  104087. private _onKeyDown;
  104088. private _onVrDisplayPresentChange;
  104089. private _onVRDisplayChanged;
  104090. private _onVRRequestPresentStart;
  104091. private _onVRRequestPresentComplete;
  104092. /**
  104093. * Observable raised right before entering VR.
  104094. */
  104095. onEnteringVRObservable: Observable<VRExperienceHelper>;
  104096. /**
  104097. * Observable raised when entering VR has completed.
  104098. */
  104099. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  104100. /**
  104101. * Observable raised when exiting VR.
  104102. */
  104103. onExitingVRObservable: Observable<VRExperienceHelper>;
  104104. /**
  104105. * Observable raised when controller mesh is loaded.
  104106. */
  104107. onControllerMeshLoadedObservable: Observable<WebVRController>;
  104108. /** Return this.onEnteringVRObservable
  104109. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  104110. */
  104111. readonly onEnteringVR: Observable<VRExperienceHelper>;
  104112. /** Return this.onExitingVRObservable
  104113. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  104114. */
  104115. readonly onExitingVR: Observable<VRExperienceHelper>;
  104116. /** Return this.onControllerMeshLoadedObservable
  104117. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  104118. */
  104119. readonly onControllerMeshLoaded: Observable<WebVRController>;
  104120. private _rayLength;
  104121. private _useCustomVRButton;
  104122. private _teleportationRequested;
  104123. private _teleportActive;
  104124. private _floorMeshName;
  104125. private _floorMeshesCollection;
  104126. private _rotationAllowed;
  104127. private _teleportBackwardsVector;
  104128. private _teleportationTarget;
  104129. private _isDefaultTeleportationTarget;
  104130. private _postProcessMove;
  104131. private _teleportationFillColor;
  104132. private _teleportationBorderColor;
  104133. private _rotationAngle;
  104134. private _haloCenter;
  104135. private _cameraGazer;
  104136. private _padSensibilityUp;
  104137. private _padSensibilityDown;
  104138. private _leftController;
  104139. private _rightController;
  104140. /**
  104141. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  104142. */
  104143. onNewMeshSelected: Observable<AbstractMesh>;
  104144. /**
  104145. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  104146. */
  104147. onNewMeshPicked: Observable<PickingInfo>;
  104148. private _circleEase;
  104149. /**
  104150. * Observable raised before camera teleportation
  104151. */
  104152. onBeforeCameraTeleport: Observable<Vector3>;
  104153. /**
  104154. * Observable raised after camera teleportation
  104155. */
  104156. onAfterCameraTeleport: Observable<Vector3>;
  104157. /**
  104158. * Observable raised when current selected mesh gets unselected
  104159. */
  104160. onSelectedMeshUnselected: Observable<AbstractMesh>;
  104161. private _raySelectionPredicate;
  104162. /**
  104163. * To be optionaly changed by user to define custom ray selection
  104164. */
  104165. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  104166. /**
  104167. * To be optionaly changed by user to define custom selection logic (after ray selection)
  104168. */
  104169. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104170. /**
  104171. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  104172. */
  104173. teleportationEnabled: boolean;
  104174. private _defaultHeight;
  104175. private _teleportationInitialized;
  104176. private _interactionsEnabled;
  104177. private _interactionsRequested;
  104178. private _displayGaze;
  104179. private _displayLaserPointer;
  104180. /**
  104181. * The mesh used to display where the user is going to teleport.
  104182. */
  104183. /**
  104184. * Sets the mesh to be used to display where the user is going to teleport.
  104185. */
  104186. teleportationTarget: Mesh;
  104187. /**
  104188. * 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
  104189. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  104190. * See http://doc.babylonjs.com/resources/baking_transformations
  104191. */
  104192. gazeTrackerMesh: Mesh;
  104193. /**
  104194. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  104195. */
  104196. updateGazeTrackerScale: boolean;
  104197. /**
  104198. * If the gaze trackers color should be updated when selecting meshes
  104199. */
  104200. updateGazeTrackerColor: boolean;
  104201. /**
  104202. * The gaze tracking mesh corresponding to the left controller
  104203. */
  104204. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  104205. /**
  104206. * The gaze tracking mesh corresponding to the right controller
  104207. */
  104208. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  104209. /**
  104210. * If the ray of the gaze should be displayed.
  104211. */
  104212. /**
  104213. * Sets if the ray of the gaze should be displayed.
  104214. */
  104215. displayGaze: boolean;
  104216. /**
  104217. * If the ray of the LaserPointer should be displayed.
  104218. */
  104219. /**
  104220. * Sets if the ray of the LaserPointer should be displayed.
  104221. */
  104222. displayLaserPointer: boolean;
  104223. /**
  104224. * The deviceOrientationCamera used as the camera when not in VR.
  104225. */
  104226. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  104227. /**
  104228. * Based on the current WebVR support, returns the current VR camera used.
  104229. */
  104230. readonly currentVRCamera: Nullable<Camera>;
  104231. /**
  104232. * The webVRCamera which is used when in VR.
  104233. */
  104234. readonly webVRCamera: WebVRFreeCamera;
  104235. /**
  104236. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  104237. */
  104238. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  104239. private readonly _teleportationRequestInitiated;
  104240. /**
  104241. * Defines wether or not Pointer lock should be requested when switching to
  104242. * full screen.
  104243. */
  104244. requestPointerLockOnFullScreen: boolean;
  104245. /**
  104246. * Instantiates a VRExperienceHelper.
  104247. * Helps to quickly add VR support to an existing scene.
  104248. * @param scene The scene the VRExperienceHelper belongs to.
  104249. * @param webVROptions Options to modify the vr experience helper's behavior.
  104250. */
  104251. constructor(scene: Scene,
  104252. /** Options to modify the vr experience helper's behavior. */
  104253. webVROptions?: VRExperienceHelperOptions);
  104254. private _onDefaultMeshLoaded;
  104255. private _onResize;
  104256. private _onFullscreenChange;
  104257. /**
  104258. * Gets a value indicating if we are currently in VR mode.
  104259. */
  104260. readonly isInVRMode: boolean;
  104261. private onVrDisplayPresentChange;
  104262. private onVRDisplayChanged;
  104263. private moveButtonToBottomRight;
  104264. private displayVRButton;
  104265. private updateButtonVisibility;
  104266. private _cachedAngularSensibility;
  104267. /**
  104268. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  104269. * Otherwise, will use the fullscreen API.
  104270. */
  104271. enterVR(): void;
  104272. /**
  104273. * Attempt to exit VR, or fullscreen.
  104274. */
  104275. exitVR(): void;
  104276. /**
  104277. * The position of the vr experience helper.
  104278. */
  104279. /**
  104280. * Sets the position of the vr experience helper.
  104281. */
  104282. position: Vector3;
  104283. /**
  104284. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  104285. */
  104286. enableInteractions(): void;
  104287. private readonly _noControllerIsActive;
  104288. private beforeRender;
  104289. private _isTeleportationFloor;
  104290. /**
  104291. * Adds a floor mesh to be used for teleportation.
  104292. * @param floorMesh the mesh to be used for teleportation.
  104293. */
  104294. addFloorMesh(floorMesh: Mesh): void;
  104295. /**
  104296. * Removes a floor mesh from being used for teleportation.
  104297. * @param floorMesh the mesh to be removed.
  104298. */
  104299. removeFloorMesh(floorMesh: Mesh): void;
  104300. /**
  104301. * Enables interactions and teleportation using the VR controllers and gaze.
  104302. * @param vrTeleportationOptions options to modify teleportation behavior.
  104303. */
  104304. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  104305. private _onNewGamepadConnected;
  104306. private _tryEnableInteractionOnController;
  104307. private _onNewGamepadDisconnected;
  104308. private _enableInteractionOnController;
  104309. private _checkTeleportWithRay;
  104310. private _checkRotate;
  104311. private _checkTeleportBackwards;
  104312. private _enableTeleportationOnController;
  104313. private _createTeleportationCircles;
  104314. private _displayTeleportationTarget;
  104315. private _hideTeleportationTarget;
  104316. private _rotateCamera;
  104317. private _moveTeleportationSelectorTo;
  104318. private _workingVector;
  104319. private _workingQuaternion;
  104320. private _workingMatrix;
  104321. /**
  104322. * Teleports the users feet to the desired location
  104323. * @param location The location where the user's feet should be placed
  104324. */
  104325. teleportCamera(location: Vector3): void;
  104326. private _convertNormalToDirectionOfRay;
  104327. private _castRayAndSelectObject;
  104328. private _notifySelectedMeshUnselected;
  104329. /**
  104330. * Sets the color of the laser ray from the vr controllers.
  104331. * @param color new color for the ray.
  104332. */
  104333. changeLaserColor(color: Color3): void;
  104334. /**
  104335. * Sets the color of the ray from the vr headsets gaze.
  104336. * @param color new color for the ray.
  104337. */
  104338. changeGazeColor(color: Color3): void;
  104339. /**
  104340. * Exits VR and disposes of the vr experience helper
  104341. */
  104342. dispose(): void;
  104343. /**
  104344. * Gets the name of the VRExperienceHelper class
  104345. * @returns "VRExperienceHelper"
  104346. */
  104347. getClassName(): string;
  104348. }
  104349. }
  104350. declare module BABYLON {
  104351. /**
  104352. * Manages an XRSession to work with Babylon's engine
  104353. * @see https://doc.babylonjs.com/how_to/webxr
  104354. */
  104355. export class WebXRSessionManager implements IDisposable {
  104356. private scene;
  104357. /**
  104358. * Fires every time a new xrFrame arrives which can be used to update the camera
  104359. */
  104360. onXRFrameObservable: Observable<any>;
  104361. /**
  104362. * Fires when the xr session is ended either by the device or manually done
  104363. */
  104364. onXRSessionEnded: Observable<any>;
  104365. /**
  104366. * Underlying xr session
  104367. */
  104368. session: XRSession;
  104369. /**
  104370. * Type of reference space used when creating the session
  104371. */
  104372. referenceSpace: XRReferenceSpace;
  104373. /** @hidden */
  104374. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  104375. /**
  104376. * Current XR frame
  104377. */
  104378. currentFrame: Nullable<XRFrame>;
  104379. private _xrNavigator;
  104380. private baseLayer;
  104381. /**
  104382. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  104383. * @param scene The scene which the session should be created for
  104384. */
  104385. constructor(scene: Scene);
  104386. /**
  104387. * Initializes the manager
  104388. * After initialization enterXR can be called to start an XR session
  104389. * @returns Promise which resolves after it is initialized
  104390. */
  104391. initializeAsync(): Promise<void>;
  104392. /**
  104393. * Initializes an xr session
  104394. * @param xrSessionMode mode to initialize
  104395. * @returns a promise which will resolve once the session has been initialized
  104396. */
  104397. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  104398. /**
  104399. * Sets the reference space on the xr session
  104400. * @param referenceSpace space to set
  104401. * @returns a promise that will resolve once the reference space has been set
  104402. */
  104403. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  104404. /**
  104405. * Updates the render state of the session
  104406. * @param state state to set
  104407. * @returns a promise that resolves once the render state has been updated
  104408. */
  104409. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  104410. /**
  104411. * Starts rendering to the xr layer
  104412. * @returns a promise that will resolve once rendering has started
  104413. */
  104414. startRenderingToXRAsync(): Promise<void>;
  104415. /**
  104416. * Stops the xrSession and restores the renderloop
  104417. * @returns Promise which resolves after it exits XR
  104418. */
  104419. exitXRAsync(): Promise<unknown>;
  104420. /**
  104421. * Checks if a session would be supported for the creation options specified
  104422. * @param sessionMode session mode to check if supported eg. immersive-vr
  104423. * @returns true if supported
  104424. */
  104425. supportsSessionAsync(sessionMode: XRSessionMode): any;
  104426. /**
  104427. * @hidden
  104428. * Converts the render layer of xrSession to a render target
  104429. * @param session session to create render target for
  104430. * @param scene scene the new render target should be created for
  104431. */
  104432. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  104433. /**
  104434. * Disposes of the session manager
  104435. */
  104436. dispose(): void;
  104437. }
  104438. }
  104439. declare module BABYLON {
  104440. /**
  104441. * WebXR Camera which holds the views for the xrSession
  104442. * @see https://doc.babylonjs.com/how_to/webxr
  104443. */
  104444. export class WebXRCamera extends FreeCamera {
  104445. private static _TmpMatrix;
  104446. /**
  104447. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  104448. * @param name the name of the camera
  104449. * @param scene the scene to add the camera to
  104450. */
  104451. constructor(name: string, scene: Scene);
  104452. private _updateNumberOfRigCameras;
  104453. /** @hidden */
  104454. _updateForDualEyeDebugging(pupilDistance?: number): void;
  104455. /**
  104456. * Updates the cameras position from the current pose information of the XR session
  104457. * @param xrSessionManager the session containing pose information
  104458. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  104459. */
  104460. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  104461. }
  104462. }
  104463. declare module BABYLON {
  104464. /**
  104465. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  104466. */
  104467. export class WebXRManagedOutputCanvas implements IDisposable {
  104468. private helper;
  104469. private _canvas;
  104470. /**
  104471. * xrpresent context of the canvas which can be used to display/mirror xr content
  104472. */
  104473. canvasContext: WebGLRenderingContext;
  104474. /**
  104475. * xr layer for the canvas
  104476. */
  104477. xrLayer: Nullable<XRWebGLLayer>;
  104478. /**
  104479. * Initializes the xr layer for the session
  104480. * @param xrSession xr session
  104481. * @returns a promise that will resolve once the XR Layer has been created
  104482. */
  104483. initializeXRLayerAsync(xrSession: any): any;
  104484. /**
  104485. * Initializes the canvas to be added/removed upon entering/exiting xr
  104486. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  104487. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  104488. */
  104489. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  104490. /**
  104491. * Disposes of the object
  104492. */
  104493. dispose(): void;
  104494. private _setManagedOutputCanvas;
  104495. private _addCanvas;
  104496. private _removeCanvas;
  104497. }
  104498. }
  104499. declare module BABYLON {
  104500. /**
  104501. * States of the webXR experience
  104502. */
  104503. export enum WebXRState {
  104504. /**
  104505. * Transitioning to being in XR mode
  104506. */
  104507. ENTERING_XR = 0,
  104508. /**
  104509. * Transitioning to non XR mode
  104510. */
  104511. EXITING_XR = 1,
  104512. /**
  104513. * In XR mode and presenting
  104514. */
  104515. IN_XR = 2,
  104516. /**
  104517. * Not entered XR mode
  104518. */
  104519. NOT_IN_XR = 3
  104520. }
  104521. /**
  104522. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  104523. * @see https://doc.babylonjs.com/how_to/webxr
  104524. */
  104525. export class WebXRExperienceHelper implements IDisposable {
  104526. private scene;
  104527. /**
  104528. * 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
  104529. */
  104530. container: AbstractMesh;
  104531. /**
  104532. * Camera used to render xr content
  104533. */
  104534. camera: WebXRCamera;
  104535. /**
  104536. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  104537. */
  104538. state: WebXRState;
  104539. private _setState;
  104540. private static _TmpVector;
  104541. /**
  104542. * Fires when the state of the experience helper has changed
  104543. */
  104544. onStateChangedObservable: Observable<WebXRState>;
  104545. /** Session manager used to keep track of xr session */
  104546. sessionManager: WebXRSessionManager;
  104547. private _nonVRCamera;
  104548. private _originalSceneAutoClear;
  104549. private _supported;
  104550. /**
  104551. * Creates the experience helper
  104552. * @param scene the scene to attach the experience helper to
  104553. * @returns a promise for the experience helper
  104554. */
  104555. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  104556. /**
  104557. * Creates a WebXRExperienceHelper
  104558. * @param scene The scene the helper should be created in
  104559. */
  104560. private constructor();
  104561. /**
  104562. * Exits XR mode and returns the scene to its original state
  104563. * @returns promise that resolves after xr mode has exited
  104564. */
  104565. exitXRAsync(): Promise<unknown>;
  104566. /**
  104567. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  104568. * @param sessionCreationOptions options for the XR session
  104569. * @param referenceSpaceType frame of reference of the XR session
  104570. * @param outputCanvas the output canvas that will be used to enter XR mode
  104571. * @returns promise that resolves after xr mode has entered
  104572. */
  104573. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  104574. /**
  104575. * Updates the global position of the camera by moving the camera's container
  104576. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  104577. * @param position The desired global position of the camera
  104578. */
  104579. setPositionOfCameraUsingContainer(position: Vector3): void;
  104580. /**
  104581. * Rotates the xr camera by rotating the camera's container around the camera's position
  104582. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  104583. * @param rotation the desired quaternion rotation to apply to the camera
  104584. */
  104585. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  104586. /**
  104587. * Disposes of the experience helper
  104588. */
  104589. dispose(): void;
  104590. }
  104591. }
  104592. declare module BABYLON {
  104593. /**
  104594. * Button which can be used to enter a different mode of XR
  104595. */
  104596. export class WebXREnterExitUIButton {
  104597. /** button element */
  104598. element: HTMLElement;
  104599. /** XR initialization options for the button */
  104600. sessionMode: XRSessionMode;
  104601. /** Reference space type */
  104602. referenceSpaceType: XRReferenceSpaceType;
  104603. /**
  104604. * Creates a WebXREnterExitUIButton
  104605. * @param element button element
  104606. * @param sessionMode XR initialization session mode
  104607. * @param referenceSpaceType the type of reference space to be used
  104608. */
  104609. constructor(
  104610. /** button element */
  104611. element: HTMLElement,
  104612. /** XR initialization options for the button */
  104613. sessionMode: XRSessionMode,
  104614. /** Reference space type */
  104615. referenceSpaceType: XRReferenceSpaceType);
  104616. /**
  104617. * Overwritable function which can be used to update the button's visuals when the state changes
  104618. * @param activeButton the current active button in the UI
  104619. */
  104620. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  104621. }
  104622. /**
  104623. * Options to create the webXR UI
  104624. */
  104625. export class WebXREnterExitUIOptions {
  104626. /**
  104627. * Context to enter xr with
  104628. */
  104629. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  104630. /**
  104631. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  104632. */
  104633. customButtons?: Array<WebXREnterExitUIButton>;
  104634. }
  104635. /**
  104636. * UI to allow the user to enter/exit XR mode
  104637. */
  104638. export class WebXREnterExitUI implements IDisposable {
  104639. private scene;
  104640. private _overlay;
  104641. private _buttons;
  104642. private _activeButton;
  104643. /**
  104644. * Fired every time the active button is changed.
  104645. *
  104646. * When xr is entered via a button that launches xr that button will be the callback parameter
  104647. *
  104648. * When exiting xr the callback parameter will be null)
  104649. */
  104650. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  104651. /**
  104652. * Creates UI to allow the user to enter/exit XR mode
  104653. * @param scene the scene to add the ui to
  104654. * @param helper the xr experience helper to enter/exit xr with
  104655. * @param options options to configure the UI
  104656. * @returns the created ui
  104657. */
  104658. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  104659. private constructor();
  104660. private _updateButtons;
  104661. /**
  104662. * Disposes of the object
  104663. */
  104664. dispose(): void;
  104665. }
  104666. }
  104667. declare module BABYLON {
  104668. /**
  104669. * Represents an XR input
  104670. */
  104671. export class WebXRController {
  104672. private scene;
  104673. /** The underlying input source for the controller */
  104674. inputSource: XRInputSource;
  104675. private parentContainer;
  104676. /**
  104677. * 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
  104678. */
  104679. grip?: AbstractMesh;
  104680. /**
  104681. * Pointer which can be used to select objects or attach a visible laser to
  104682. */
  104683. pointer: AbstractMesh;
  104684. /**
  104685. * Event that fires when the controller is removed/disposed
  104686. */
  104687. onDisposeObservable: Observable<{}>;
  104688. private _tmpMatrix;
  104689. private _tmpQuaternion;
  104690. private _tmpVector;
  104691. /**
  104692. * Creates the controller
  104693. * @see https://doc.babylonjs.com/how_to/webxr
  104694. * @param scene the scene which the controller should be associated to
  104695. * @param inputSource the underlying input source for the controller
  104696. * @param parentContainer parent that the controller meshes should be children of
  104697. */
  104698. constructor(scene: Scene,
  104699. /** The underlying input source for the controller */
  104700. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  104701. /**
  104702. * Updates the controller pose based on the given XRFrame
  104703. * @param xrFrame xr frame to update the pose with
  104704. * @param referenceSpace reference space to use
  104705. */
  104706. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  104707. /**
  104708. * Gets a world space ray coming from the controller
  104709. * @param result the resulting ray
  104710. */
  104711. getWorldPointerRayToRef(result: Ray): void;
  104712. /**
  104713. * Disposes of the object
  104714. */
  104715. dispose(): void;
  104716. }
  104717. }
  104718. declare module BABYLON {
  104719. /**
  104720. * XR input used to track XR inputs such as controllers/rays
  104721. */
  104722. export class WebXRInput implements IDisposable {
  104723. /**
  104724. * Base experience the input listens to
  104725. */
  104726. baseExperience: WebXRExperienceHelper;
  104727. /**
  104728. * XR controllers being tracked
  104729. */
  104730. controllers: Array<WebXRController>;
  104731. private _frameObserver;
  104732. private _stateObserver;
  104733. /**
  104734. * Event when a controller has been connected/added
  104735. */
  104736. onControllerAddedObservable: Observable<WebXRController>;
  104737. /**
  104738. * Event when a controller has been removed/disconnected
  104739. */
  104740. onControllerRemovedObservable: Observable<WebXRController>;
  104741. /**
  104742. * Initializes the WebXRInput
  104743. * @param baseExperience experience helper which the input should be created for
  104744. */
  104745. constructor(
  104746. /**
  104747. * Base experience the input listens to
  104748. */
  104749. baseExperience: WebXRExperienceHelper);
  104750. private _onInputSourcesChange;
  104751. private _addAndRemoveControllers;
  104752. /**
  104753. * Disposes of the object
  104754. */
  104755. dispose(): void;
  104756. }
  104757. }
  104758. declare module BABYLON {
  104759. /**
  104760. * Enables teleportation
  104761. */
  104762. export class WebXRControllerTeleportation {
  104763. private _teleportationFillColor;
  104764. private _teleportationBorderColor;
  104765. private _tmpRay;
  104766. private _tmpVector;
  104767. /**
  104768. * Creates a WebXRControllerTeleportation
  104769. * @param input input manager to add teleportation to
  104770. * @param floorMeshes floormeshes which can be teleported to
  104771. */
  104772. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  104773. }
  104774. }
  104775. declare module BABYLON {
  104776. /**
  104777. * Handles pointer input automatically for the pointer of XR controllers
  104778. */
  104779. export class WebXRControllerPointerSelection {
  104780. private static _idCounter;
  104781. private _tmpRay;
  104782. /**
  104783. * Creates a WebXRControllerPointerSelection
  104784. * @param input input manager to setup pointer selection
  104785. */
  104786. constructor(input: WebXRInput);
  104787. private _convertNormalToDirectionOfRay;
  104788. private _updatePointerDistance;
  104789. }
  104790. }
  104791. declare module BABYLON {
  104792. /**
  104793. * Class used to represent data loading progression
  104794. */
  104795. export class SceneLoaderProgressEvent {
  104796. /** defines if data length to load can be evaluated */
  104797. readonly lengthComputable: boolean;
  104798. /** defines the loaded data length */
  104799. readonly loaded: number;
  104800. /** defines the data length to load */
  104801. readonly total: number;
  104802. /**
  104803. * Create a new progress event
  104804. * @param lengthComputable defines if data length to load can be evaluated
  104805. * @param loaded defines the loaded data length
  104806. * @param total defines the data length to load
  104807. */
  104808. constructor(
  104809. /** defines if data length to load can be evaluated */
  104810. lengthComputable: boolean,
  104811. /** defines the loaded data length */
  104812. loaded: number,
  104813. /** defines the data length to load */
  104814. total: number);
  104815. /**
  104816. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104817. * @param event defines the source event
  104818. * @returns a new SceneLoaderProgressEvent
  104819. */
  104820. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104821. }
  104822. /**
  104823. * Interface used by SceneLoader plugins to define supported file extensions
  104824. */
  104825. export interface ISceneLoaderPluginExtensions {
  104826. /**
  104827. * Defines the list of supported extensions
  104828. */
  104829. [extension: string]: {
  104830. isBinary: boolean;
  104831. };
  104832. }
  104833. /**
  104834. * Interface used by SceneLoader plugin factory
  104835. */
  104836. export interface ISceneLoaderPluginFactory {
  104837. /**
  104838. * Defines the name of the factory
  104839. */
  104840. name: string;
  104841. /**
  104842. * Function called to create a new plugin
  104843. * @return the new plugin
  104844. */
  104845. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104846. /**
  104847. * Boolean indicating if the plugin can direct load specific data
  104848. */
  104849. canDirectLoad?: (data: string) => boolean;
  104850. }
  104851. /**
  104852. * Interface used to define a SceneLoader plugin
  104853. */
  104854. export interface ISceneLoaderPlugin {
  104855. /**
  104856. * The friendly name of this plugin.
  104857. */
  104858. name: string;
  104859. /**
  104860. * The file extensions supported by this plugin.
  104861. */
  104862. extensions: string | ISceneLoaderPluginExtensions;
  104863. /**
  104864. * Import meshes into a scene.
  104865. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104866. * @param scene The scene to import into
  104867. * @param data The data to import
  104868. * @param rootUrl The root url for scene and resources
  104869. * @param meshes The meshes array to import into
  104870. * @param particleSystems The particle systems array to import into
  104871. * @param skeletons The skeletons array to import into
  104872. * @param onError The callback when import fails
  104873. * @returns True if successful or false otherwise
  104874. */
  104875. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104876. /**
  104877. * Load into a scene.
  104878. * @param scene The scene to load into
  104879. * @param data The data to import
  104880. * @param rootUrl The root url for scene and resources
  104881. * @param onError The callback when import fails
  104882. * @returns true if successful or false otherwise
  104883. */
  104884. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104885. /**
  104886. * The callback that returns true if the data can be directly loaded.
  104887. */
  104888. canDirectLoad?: (data: string) => boolean;
  104889. /**
  104890. * The callback that allows custom handling of the root url based on the response url.
  104891. */
  104892. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104893. /**
  104894. * Load into an asset container.
  104895. * @param scene The scene to load into
  104896. * @param data The data to import
  104897. * @param rootUrl The root url for scene and resources
  104898. * @param onError The callback when import fails
  104899. * @returns The loaded asset container
  104900. */
  104901. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104902. }
  104903. /**
  104904. * Interface used to define an async SceneLoader plugin
  104905. */
  104906. export interface ISceneLoaderPluginAsync {
  104907. /**
  104908. * The friendly name of this plugin.
  104909. */
  104910. name: string;
  104911. /**
  104912. * The file extensions supported by this plugin.
  104913. */
  104914. extensions: string | ISceneLoaderPluginExtensions;
  104915. /**
  104916. * Import meshes into a scene.
  104917. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104918. * @param scene The scene to import into
  104919. * @param data The data to import
  104920. * @param rootUrl The root url for scene and resources
  104921. * @param onProgress The callback when the load progresses
  104922. * @param fileName Defines the name of the file to load
  104923. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  104924. */
  104925. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  104926. meshes: AbstractMesh[];
  104927. particleSystems: IParticleSystem[];
  104928. skeletons: Skeleton[];
  104929. animationGroups: AnimationGroup[];
  104930. }>;
  104931. /**
  104932. * Load into a scene.
  104933. * @param scene The scene to load into
  104934. * @param data The data to import
  104935. * @param rootUrl The root url for scene and resources
  104936. * @param onProgress The callback when the load progresses
  104937. * @param fileName Defines the name of the file to load
  104938. * @returns Nothing
  104939. */
  104940. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  104941. /**
  104942. * The callback that returns true if the data can be directly loaded.
  104943. */
  104944. canDirectLoad?: (data: string) => boolean;
  104945. /**
  104946. * The callback that allows custom handling of the root url based on the response url.
  104947. */
  104948. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104949. /**
  104950. * Load into an asset container.
  104951. * @param scene The scene to load into
  104952. * @param data The data to import
  104953. * @param rootUrl The root url for scene and resources
  104954. * @param onProgress The callback when the load progresses
  104955. * @param fileName Defines the name of the file to load
  104956. * @returns The loaded asset container
  104957. */
  104958. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  104959. }
  104960. /**
  104961. * Class used to load scene from various file formats using registered plugins
  104962. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  104963. */
  104964. export class SceneLoader {
  104965. /**
  104966. * No logging while loading
  104967. */
  104968. static readonly NO_LOGGING: number;
  104969. /**
  104970. * Minimal logging while loading
  104971. */
  104972. static readonly MINIMAL_LOGGING: number;
  104973. /**
  104974. * Summary logging while loading
  104975. */
  104976. static readonly SUMMARY_LOGGING: number;
  104977. /**
  104978. * Detailled logging while loading
  104979. */
  104980. static readonly DETAILED_LOGGING: number;
  104981. /**
  104982. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104983. */
  104984. static ForceFullSceneLoadingForIncremental: boolean;
  104985. /**
  104986. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104987. */
  104988. static ShowLoadingScreen: boolean;
  104989. /**
  104990. * Defines the current logging level (while loading the scene)
  104991. * @ignorenaming
  104992. */
  104993. static loggingLevel: number;
  104994. /**
  104995. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104996. */
  104997. static CleanBoneMatrixWeights: boolean;
  104998. /**
  104999. * Event raised when a plugin is used to load a scene
  105000. */
  105001. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105002. private static _registeredPlugins;
  105003. private static _getDefaultPlugin;
  105004. private static _getPluginForExtension;
  105005. private static _getPluginForDirectLoad;
  105006. private static _getPluginForFilename;
  105007. private static _getDirectLoad;
  105008. private static _loadData;
  105009. private static _getFileInfo;
  105010. /**
  105011. * Gets a plugin that can load the given extension
  105012. * @param extension defines the extension to load
  105013. * @returns a plugin or null if none works
  105014. */
  105015. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105016. /**
  105017. * Gets a boolean indicating that the given extension can be loaded
  105018. * @param extension defines the extension to load
  105019. * @returns true if the extension is supported
  105020. */
  105021. static IsPluginForExtensionAvailable(extension: string): boolean;
  105022. /**
  105023. * Adds a new plugin to the list of registered plugins
  105024. * @param plugin defines the plugin to add
  105025. */
  105026. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105027. /**
  105028. * Import meshes into a scene
  105029. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105030. * @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)
  105031. * @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)
  105032. * @param scene the instance of BABYLON.Scene to append to
  105033. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105034. * @param onProgress a callback with a progress event for each file being loaded
  105035. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105036. * @param pluginExtension the extension used to determine the plugin
  105037. * @returns The loaded plugin
  105038. */
  105039. 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>;
  105040. /**
  105041. * Import meshes into a scene
  105042. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105043. * @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)
  105044. * @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)
  105045. * @param scene the instance of BABYLON.Scene to append to
  105046. * @param onProgress a callback with a progress event for each file being loaded
  105047. * @param pluginExtension the extension used to determine the plugin
  105048. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105049. */
  105050. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105051. meshes: AbstractMesh[];
  105052. particleSystems: IParticleSystem[];
  105053. skeletons: Skeleton[];
  105054. animationGroups: AnimationGroup[];
  105055. }>;
  105056. /**
  105057. * Load a scene
  105058. * @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)
  105059. * @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)
  105060. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105061. * @param onSuccess a callback with the scene when import succeeds
  105062. * @param onProgress a callback with a progress event for each file being loaded
  105063. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105064. * @param pluginExtension the extension used to determine the plugin
  105065. * @returns The loaded plugin
  105066. */
  105067. 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>;
  105068. /**
  105069. * Load a scene
  105070. * @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)
  105071. * @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)
  105072. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105073. * @param onProgress a callback with a progress event for each file being loaded
  105074. * @param pluginExtension the extension used to determine the plugin
  105075. * @returns The loaded scene
  105076. */
  105077. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105078. /**
  105079. * Append a scene
  105080. * @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)
  105081. * @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)
  105082. * @param scene is the instance of BABYLON.Scene to append to
  105083. * @param onSuccess a callback with the scene when import succeeds
  105084. * @param onProgress a callback with a progress event for each file being loaded
  105085. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105086. * @param pluginExtension the extension used to determine the plugin
  105087. * @returns The loaded plugin
  105088. */
  105089. 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>;
  105090. /**
  105091. * Append a scene
  105092. * @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)
  105093. * @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)
  105094. * @param scene is the instance of BABYLON.Scene to append to
  105095. * @param onProgress a callback with a progress event for each file being loaded
  105096. * @param pluginExtension the extension used to determine the plugin
  105097. * @returns The given scene
  105098. */
  105099. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105100. /**
  105101. * Load a scene into an asset container
  105102. * @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)
  105103. * @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)
  105104. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105105. * @param onSuccess a callback with the scene when import succeeds
  105106. * @param onProgress a callback with a progress event for each file being loaded
  105107. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105108. * @param pluginExtension the extension used to determine the plugin
  105109. * @returns The loaded plugin
  105110. */
  105111. 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>;
  105112. /**
  105113. * Load a scene into an asset container
  105114. * @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)
  105115. * @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)
  105116. * @param scene is the instance of Scene to append to
  105117. * @param onProgress a callback with a progress event for each file being loaded
  105118. * @param pluginExtension the extension used to determine the plugin
  105119. * @returns The loaded asset container
  105120. */
  105121. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105122. }
  105123. }
  105124. declare module BABYLON {
  105125. /**
  105126. * Generic Controller
  105127. */
  105128. export class GenericController extends WebVRController {
  105129. /**
  105130. * Base Url for the controller model.
  105131. */
  105132. static readonly MODEL_BASE_URL: string;
  105133. /**
  105134. * File name for the controller model.
  105135. */
  105136. static readonly MODEL_FILENAME: string;
  105137. /**
  105138. * Creates a new GenericController from a gamepad
  105139. * @param vrGamepad the gamepad that the controller should be created from
  105140. */
  105141. constructor(vrGamepad: any);
  105142. /**
  105143. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105144. * @param scene scene in which to add meshes
  105145. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105146. */
  105147. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105148. /**
  105149. * Called once for each button that changed state since the last frame
  105150. * @param buttonIdx Which button index changed
  105151. * @param state New state of the button
  105152. * @param changes Which properties on the state changed since last frame
  105153. */
  105154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105155. }
  105156. }
  105157. declare module BABYLON {
  105158. /**
  105159. * Defines the WindowsMotionController object that the state of the windows motion controller
  105160. */
  105161. export class WindowsMotionController extends WebVRController {
  105162. /**
  105163. * The base url used to load the left and right controller models
  105164. */
  105165. static MODEL_BASE_URL: string;
  105166. /**
  105167. * The name of the left controller model file
  105168. */
  105169. static MODEL_LEFT_FILENAME: string;
  105170. /**
  105171. * The name of the right controller model file
  105172. */
  105173. static MODEL_RIGHT_FILENAME: string;
  105174. /**
  105175. * The controller name prefix for this controller type
  105176. */
  105177. static readonly GAMEPAD_ID_PREFIX: string;
  105178. /**
  105179. * The controller id pattern for this controller type
  105180. */
  105181. private static readonly GAMEPAD_ID_PATTERN;
  105182. private _loadedMeshInfo;
  105183. private readonly _mapping;
  105184. /**
  105185. * Fired when the trackpad on this controller is clicked
  105186. */
  105187. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105188. /**
  105189. * Fired when the trackpad on this controller is modified
  105190. */
  105191. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105192. /**
  105193. * The current x and y values of this controller's trackpad
  105194. */
  105195. trackpad: StickValues;
  105196. /**
  105197. * Creates a new WindowsMotionController from a gamepad
  105198. * @param vrGamepad the gamepad that the controller should be created from
  105199. */
  105200. constructor(vrGamepad: any);
  105201. /**
  105202. * Fired when the trigger on this controller is modified
  105203. */
  105204. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105205. /**
  105206. * Fired when the menu button on this controller is modified
  105207. */
  105208. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105209. /**
  105210. * Fired when the grip button on this controller is modified
  105211. */
  105212. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105213. /**
  105214. * Fired when the thumbstick button on this controller is modified
  105215. */
  105216. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105217. /**
  105218. * Fired when the touchpad button on this controller is modified
  105219. */
  105220. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105221. /**
  105222. * Fired when the touchpad values on this controller are modified
  105223. */
  105224. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105225. private _updateTrackpad;
  105226. /**
  105227. * Called once per frame by the engine.
  105228. */
  105229. update(): void;
  105230. /**
  105231. * Called once for each button that changed state since the last frame
  105232. * @param buttonIdx Which button index changed
  105233. * @param state New state of the button
  105234. * @param changes Which properties on the state changed since last frame
  105235. */
  105236. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105237. /**
  105238. * Moves the buttons on the controller mesh based on their current state
  105239. * @param buttonName the name of the button to move
  105240. * @param buttonValue the value of the button which determines the buttons new position
  105241. */
  105242. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105243. /**
  105244. * Moves the axis on the controller mesh based on its current state
  105245. * @param axis the index of the axis
  105246. * @param axisValue the value of the axis which determines the meshes new position
  105247. * @hidden
  105248. */
  105249. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105250. /**
  105251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105252. * @param scene scene in which to add meshes
  105253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105254. */
  105255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105256. /**
  105257. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105258. * can be transformed by button presses and axes values, based on this._mapping.
  105259. *
  105260. * @param scene scene in which the meshes exist
  105261. * @param meshes list of meshes that make up the controller model to process
  105262. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105263. */
  105264. private processModel;
  105265. private createMeshInfo;
  105266. /**
  105267. * Gets the ray of the controller in the direction the controller is pointing
  105268. * @param length the length the resulting ray should be
  105269. * @returns a ray in the direction the controller is pointing
  105270. */
  105271. getForwardRay(length?: number): Ray;
  105272. /**
  105273. * Disposes of the controller
  105274. */
  105275. dispose(): void;
  105276. }
  105277. }
  105278. declare module BABYLON {
  105279. /**
  105280. * Oculus Touch Controller
  105281. */
  105282. export class OculusTouchController extends WebVRController {
  105283. /**
  105284. * Base Url for the controller model.
  105285. */
  105286. static MODEL_BASE_URL: string;
  105287. /**
  105288. * File name for the left controller model.
  105289. */
  105290. static MODEL_LEFT_FILENAME: string;
  105291. /**
  105292. * File name for the right controller model.
  105293. */
  105294. static MODEL_RIGHT_FILENAME: string;
  105295. /**
  105296. * Base Url for the Quest controller model.
  105297. */
  105298. static QUEST_MODEL_BASE_URL: string;
  105299. /**
  105300. * @hidden
  105301. * If the controllers are running on a device that needs the updated Quest controller models
  105302. */
  105303. static _IsQuest: boolean;
  105304. /**
  105305. * Fired when the secondary trigger on this controller is modified
  105306. */
  105307. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105308. /**
  105309. * Fired when the thumb rest on this controller is modified
  105310. */
  105311. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105312. /**
  105313. * Creates a new OculusTouchController from a gamepad
  105314. * @param vrGamepad the gamepad that the controller should be created from
  105315. */
  105316. constructor(vrGamepad: any);
  105317. /**
  105318. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105319. * @param scene scene in which to add meshes
  105320. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105321. */
  105322. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105323. /**
  105324. * Fired when the A button on this controller is modified
  105325. */
  105326. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105327. /**
  105328. * Fired when the B button on this controller is modified
  105329. */
  105330. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105331. /**
  105332. * Fired when the X button on this controller is modified
  105333. */
  105334. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105335. /**
  105336. * Fired when the Y button on this controller is modified
  105337. */
  105338. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105339. /**
  105340. * Called once for each button that changed state since the last frame
  105341. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105342. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105343. * 2) secondary trigger (same)
  105344. * 3) A (right) X (left), touch, pressed = value
  105345. * 4) B / Y
  105346. * 5) thumb rest
  105347. * @param buttonIdx Which button index changed
  105348. * @param state New state of the button
  105349. * @param changes Which properties on the state changed since last frame
  105350. */
  105351. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105352. }
  105353. }
  105354. declare module BABYLON {
  105355. /**
  105356. * Vive Controller
  105357. */
  105358. export class ViveController extends WebVRController {
  105359. /**
  105360. * Base Url for the controller model.
  105361. */
  105362. static MODEL_BASE_URL: string;
  105363. /**
  105364. * File name for the controller model.
  105365. */
  105366. static MODEL_FILENAME: string;
  105367. /**
  105368. * Creates a new ViveController from a gamepad
  105369. * @param vrGamepad the gamepad that the controller should be created from
  105370. */
  105371. constructor(vrGamepad: any);
  105372. /**
  105373. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105374. * @param scene scene in which to add meshes
  105375. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105376. */
  105377. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105378. /**
  105379. * Fired when the left button on this controller is modified
  105380. */
  105381. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105382. /**
  105383. * Fired when the right button on this controller is modified
  105384. */
  105385. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105386. /**
  105387. * Fired when the menu button on this controller is modified
  105388. */
  105389. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105390. /**
  105391. * Called once for each button that changed state since the last frame
  105392. * Vive mapping:
  105393. * 0: touchpad
  105394. * 1: trigger
  105395. * 2: left AND right buttons
  105396. * 3: menu button
  105397. * @param buttonIdx Which button index changed
  105398. * @param state New state of the button
  105399. * @param changes Which properties on the state changed since last frame
  105400. */
  105401. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105402. }
  105403. }
  105404. declare module BABYLON {
  105405. /**
  105406. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  105407. */
  105408. export class WebXRControllerModelLoader {
  105409. /**
  105410. * Creates the WebXRControllerModelLoader
  105411. * @param input xr input that creates the controllers
  105412. */
  105413. constructor(input: WebXRInput);
  105414. }
  105415. }
  105416. declare module BABYLON {
  105417. /**
  105418. * Contains an array of blocks representing the octree
  105419. */
  105420. export interface IOctreeContainer<T> {
  105421. /**
  105422. * Blocks within the octree
  105423. */
  105424. blocks: Array<OctreeBlock<T>>;
  105425. }
  105426. /**
  105427. * Class used to store a cell in an octree
  105428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105429. */
  105430. export class OctreeBlock<T> {
  105431. /**
  105432. * Gets the content of the current block
  105433. */
  105434. entries: T[];
  105435. /**
  105436. * Gets the list of block children
  105437. */
  105438. blocks: Array<OctreeBlock<T>>;
  105439. private _depth;
  105440. private _maxDepth;
  105441. private _capacity;
  105442. private _minPoint;
  105443. private _maxPoint;
  105444. private _boundingVectors;
  105445. private _creationFunc;
  105446. /**
  105447. * Creates a new block
  105448. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  105449. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  105450. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105451. * @param depth defines the current depth of this block in the octree
  105452. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  105453. * @param creationFunc defines a callback to call when an element is added to the block
  105454. */
  105455. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  105456. /**
  105457. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105458. */
  105459. readonly capacity: number;
  105460. /**
  105461. * Gets the minimum vector (in world space) of the block's bounding box
  105462. */
  105463. readonly minPoint: Vector3;
  105464. /**
  105465. * Gets the maximum vector (in world space) of the block's bounding box
  105466. */
  105467. readonly maxPoint: Vector3;
  105468. /**
  105469. * Add a new element to this block
  105470. * @param entry defines the element to add
  105471. */
  105472. addEntry(entry: T): void;
  105473. /**
  105474. * Remove an element from this block
  105475. * @param entry defines the element to remove
  105476. */
  105477. removeEntry(entry: T): void;
  105478. /**
  105479. * Add an array of elements to this block
  105480. * @param entries defines the array of elements to add
  105481. */
  105482. addEntries(entries: T[]): void;
  105483. /**
  105484. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  105485. * @param frustumPlanes defines the frustum planes to test
  105486. * @param selection defines the array to store current content if selection is positive
  105487. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105488. */
  105489. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105490. /**
  105491. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  105492. * @param sphereCenter defines the bounding sphere center
  105493. * @param sphereRadius defines the bounding sphere radius
  105494. * @param selection defines the array to store current content if selection is positive
  105495. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105496. */
  105497. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105498. /**
  105499. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  105500. * @param ray defines the ray to test with
  105501. * @param selection defines the array to store current content if selection is positive
  105502. */
  105503. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  105504. /**
  105505. * Subdivide the content into child blocks (this block will then be empty)
  105506. */
  105507. createInnerBlocks(): void;
  105508. /**
  105509. * @hidden
  105510. */
  105511. 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;
  105512. }
  105513. }
  105514. declare module BABYLON {
  105515. /**
  105516. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  105517. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105518. */
  105519. export class Octree<T> {
  105520. /** 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.) */
  105521. maxDepth: number;
  105522. /**
  105523. * Blocks within the octree containing objects
  105524. */
  105525. blocks: Array<OctreeBlock<T>>;
  105526. /**
  105527. * Content stored in the octree
  105528. */
  105529. dynamicContent: T[];
  105530. private _maxBlockCapacity;
  105531. private _selectionContent;
  105532. private _creationFunc;
  105533. /**
  105534. * Creates a octree
  105535. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105536. * @param creationFunc function to be used to instatiate the octree
  105537. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  105538. * @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.)
  105539. */
  105540. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  105541. /** 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.) */
  105542. maxDepth?: number);
  105543. /**
  105544. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  105545. * @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);
  105546. * @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);
  105547. * @param entries meshes to be added to the octree blocks
  105548. */
  105549. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  105550. /**
  105551. * Adds a mesh to the octree
  105552. * @param entry Mesh to add to the octree
  105553. */
  105554. addMesh(entry: T): void;
  105555. /**
  105556. * Remove an element from the octree
  105557. * @param entry defines the element to remove
  105558. */
  105559. removeMesh(entry: T): void;
  105560. /**
  105561. * Selects an array of meshes within the frustum
  105562. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  105563. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  105564. * @returns array of meshes within the frustum
  105565. */
  105566. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  105567. /**
  105568. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  105569. * @param sphereCenter defines the bounding sphere center
  105570. * @param sphereRadius defines the bounding sphere radius
  105571. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105572. * @returns an array of objects that intersect the sphere
  105573. */
  105574. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  105575. /**
  105576. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  105577. * @param ray defines the ray to test with
  105578. * @returns array of intersected objects
  105579. */
  105580. intersectsRay(ray: Ray): SmartArray<T>;
  105581. /**
  105582. * Adds a mesh into the octree block if it intersects the block
  105583. */
  105584. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  105585. /**
  105586. * Adds a submesh into the octree block if it intersects the block
  105587. */
  105588. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  105589. }
  105590. }
  105591. declare module BABYLON {
  105592. interface Scene {
  105593. /**
  105594. * @hidden
  105595. * Backing Filed
  105596. */
  105597. _selectionOctree: Octree<AbstractMesh>;
  105598. /**
  105599. * Gets the octree used to boost mesh selection (picking)
  105600. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105601. */
  105602. selectionOctree: Octree<AbstractMesh>;
  105603. /**
  105604. * Creates or updates the octree used to boost selection (picking)
  105605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105606. * @param maxCapacity defines the maximum capacity per leaf
  105607. * @param maxDepth defines the maximum depth of the octree
  105608. * @returns an octree of AbstractMesh
  105609. */
  105610. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  105611. }
  105612. interface AbstractMesh {
  105613. /**
  105614. * @hidden
  105615. * Backing Field
  105616. */
  105617. _submeshesOctree: Octree<SubMesh>;
  105618. /**
  105619. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  105620. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105621. * @param maxCapacity defines the maximum size of each block (64 by default)
  105622. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  105623. * @returns the new octree
  105624. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  105625. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105626. */
  105627. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  105628. }
  105629. /**
  105630. * Defines the octree scene component responsible to manage any octrees
  105631. * in a given scene.
  105632. */
  105633. export class OctreeSceneComponent {
  105634. /**
  105635. * The component name help to identify the component in the list of scene components.
  105636. */
  105637. readonly name: string;
  105638. /**
  105639. * The scene the component belongs to.
  105640. */
  105641. scene: Scene;
  105642. /**
  105643. * Indicates if the meshes have been checked to make sure they are isEnabled()
  105644. */
  105645. readonly checksIsEnabled: boolean;
  105646. /**
  105647. * Creates a new instance of the component for the given scene
  105648. * @param scene Defines the scene to register the component in
  105649. */
  105650. constructor(scene: Scene);
  105651. /**
  105652. * Registers the component in a given scene
  105653. */
  105654. register(): void;
  105655. /**
  105656. * Return the list of active meshes
  105657. * @returns the list of active meshes
  105658. */
  105659. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  105660. /**
  105661. * Return the list of active sub meshes
  105662. * @param mesh The mesh to get the candidates sub meshes from
  105663. * @returns the list of active sub meshes
  105664. */
  105665. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  105666. private _tempRay;
  105667. /**
  105668. * Return the list of sub meshes intersecting with a given local ray
  105669. * @param mesh defines the mesh to find the submesh for
  105670. * @param localRay defines the ray in local space
  105671. * @returns the list of intersecting sub meshes
  105672. */
  105673. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  105674. /**
  105675. * Return the list of sub meshes colliding with a collider
  105676. * @param mesh defines the mesh to find the submesh for
  105677. * @param collider defines the collider to evaluate the collision against
  105678. * @returns the list of colliding sub meshes
  105679. */
  105680. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  105681. /**
  105682. * Rebuilds the elements related to this component in case of
  105683. * context lost for instance.
  105684. */
  105685. rebuild(): void;
  105686. /**
  105687. * Disposes the component and the associated ressources.
  105688. */
  105689. dispose(): void;
  105690. }
  105691. }
  105692. declare module BABYLON {
  105693. /**
  105694. * Renders a layer on top of an existing scene
  105695. */
  105696. export class UtilityLayerRenderer implements IDisposable {
  105697. /** the original scene that will be rendered on top of */
  105698. originalScene: Scene;
  105699. private _pointerCaptures;
  105700. private _lastPointerEvents;
  105701. private static _DefaultUtilityLayer;
  105702. private static _DefaultKeepDepthUtilityLayer;
  105703. private _sharedGizmoLight;
  105704. private _renderCamera;
  105705. /**
  105706. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  105707. * @returns the camera that is used when rendering the utility layer
  105708. */
  105709. getRenderCamera(): Nullable<Camera>;
  105710. /**
  105711. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  105712. * @param cam the camera that should be used when rendering the utility layer
  105713. */
  105714. setRenderCamera(cam: Nullable<Camera>): void;
  105715. /**
  105716. * @hidden
  105717. * Light which used by gizmos to get light shading
  105718. */
  105719. _getSharedGizmoLight(): HemisphericLight;
  105720. /**
  105721. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  105722. */
  105723. pickUtilitySceneFirst: boolean;
  105724. /**
  105725. * 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)
  105726. */
  105727. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  105728. /**
  105729. * 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)
  105730. */
  105731. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  105732. /**
  105733. * The scene that is rendered on top of the original scene
  105734. */
  105735. utilityLayerScene: Scene;
  105736. /**
  105737. * If the utility layer should automatically be rendered on top of existing scene
  105738. */
  105739. shouldRender: boolean;
  105740. /**
  105741. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  105742. */
  105743. onlyCheckPointerDownEvents: boolean;
  105744. /**
  105745. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  105746. */
  105747. processAllEvents: boolean;
  105748. /**
  105749. * Observable raised when the pointer move from the utility layer scene to the main scene
  105750. */
  105751. onPointerOutObservable: Observable<number>;
  105752. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  105753. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  105754. private _afterRenderObserver;
  105755. private _sceneDisposeObserver;
  105756. private _originalPointerObserver;
  105757. /**
  105758. * Instantiates a UtilityLayerRenderer
  105759. * @param originalScene the original scene that will be rendered on top of
  105760. * @param handleEvents boolean indicating if the utility layer should handle events
  105761. */
  105762. constructor(
  105763. /** the original scene that will be rendered on top of */
  105764. originalScene: Scene, handleEvents?: boolean);
  105765. private _notifyObservers;
  105766. /**
  105767. * Renders the utility layers scene on top of the original scene
  105768. */
  105769. render(): void;
  105770. /**
  105771. * Disposes of the renderer
  105772. */
  105773. dispose(): void;
  105774. private _updateCamera;
  105775. }
  105776. }
  105777. declare module BABYLON {
  105778. /**
  105779. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  105780. */
  105781. export class Gizmo implements IDisposable {
  105782. /** The utility layer the gizmo will be added to */
  105783. gizmoLayer: UtilityLayerRenderer;
  105784. /**
  105785. * The root mesh of the gizmo
  105786. */
  105787. _rootMesh: Mesh;
  105788. private _attachedMesh;
  105789. /**
  105790. * Ratio for the scale of the gizmo (Default: 1)
  105791. */
  105792. scaleRatio: number;
  105793. /**
  105794. * If a custom mesh has been set (Default: false)
  105795. */
  105796. protected _customMeshSet: boolean;
  105797. /**
  105798. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  105799. * * When set, interactions will be enabled
  105800. */
  105801. attachedMesh: Nullable<AbstractMesh>;
  105802. /**
  105803. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105804. * @param mesh The mesh to replace the default mesh of the gizmo
  105805. */
  105806. setCustomMesh(mesh: Mesh): void;
  105807. /**
  105808. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  105809. */
  105810. updateGizmoRotationToMatchAttachedMesh: boolean;
  105811. /**
  105812. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  105813. */
  105814. updateGizmoPositionToMatchAttachedMesh: boolean;
  105815. /**
  105816. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  105817. */
  105818. updateScale: boolean;
  105819. protected _interactionsEnabled: boolean;
  105820. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105821. private _beforeRenderObserver;
  105822. private _tempVector;
  105823. /**
  105824. * Creates a gizmo
  105825. * @param gizmoLayer The utility layer the gizmo will be added to
  105826. */
  105827. constructor(
  105828. /** The utility layer the gizmo will be added to */
  105829. gizmoLayer?: UtilityLayerRenderer);
  105830. /**
  105831. * Updates the gizmo to match the attached mesh's position/rotation
  105832. */
  105833. protected _update(): void;
  105834. /**
  105835. * Disposes of the gizmo
  105836. */
  105837. dispose(): void;
  105838. }
  105839. }
  105840. declare module BABYLON {
  105841. /**
  105842. * Single plane drag gizmo
  105843. */
  105844. export class PlaneDragGizmo extends Gizmo {
  105845. /**
  105846. * Drag behavior responsible for the gizmos dragging interactions
  105847. */
  105848. dragBehavior: PointerDragBehavior;
  105849. private _pointerObserver;
  105850. /**
  105851. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105852. */
  105853. snapDistance: number;
  105854. /**
  105855. * Event that fires each time the gizmo snaps to a new location.
  105856. * * snapDistance is the the change in distance
  105857. */
  105858. onSnapObservable: Observable<{
  105859. snapDistance: number;
  105860. }>;
  105861. private _plane;
  105862. private _coloredMaterial;
  105863. private _hoverMaterial;
  105864. private _isEnabled;
  105865. private _parent;
  105866. /** @hidden */
  105867. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  105868. /** @hidden */
  105869. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  105870. /**
  105871. * Creates a PlaneDragGizmo
  105872. * @param gizmoLayer The utility layer the gizmo will be added to
  105873. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  105874. * @param color The color of the gizmo
  105875. */
  105876. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  105877. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105878. /**
  105879. * If the gizmo is enabled
  105880. */
  105881. isEnabled: boolean;
  105882. /**
  105883. * Disposes of the gizmo
  105884. */
  105885. dispose(): void;
  105886. }
  105887. }
  105888. declare module BABYLON {
  105889. /**
  105890. * Gizmo that enables dragging a mesh along 3 axis
  105891. */
  105892. export class PositionGizmo extends Gizmo {
  105893. /**
  105894. * Internal gizmo used for interactions on the x axis
  105895. */
  105896. xGizmo: AxisDragGizmo;
  105897. /**
  105898. * Internal gizmo used for interactions on the y axis
  105899. */
  105900. yGizmo: AxisDragGizmo;
  105901. /**
  105902. * Internal gizmo used for interactions on the z axis
  105903. */
  105904. zGizmo: AxisDragGizmo;
  105905. /**
  105906. * Internal gizmo used for interactions on the yz plane
  105907. */
  105908. xPlaneGizmo: PlaneDragGizmo;
  105909. /**
  105910. * Internal gizmo used for interactions on the xz plane
  105911. */
  105912. yPlaneGizmo: PlaneDragGizmo;
  105913. /**
  105914. * Internal gizmo used for interactions on the xy plane
  105915. */
  105916. zPlaneGizmo: PlaneDragGizmo;
  105917. /**
  105918. * private variables
  105919. */
  105920. private _meshAttached;
  105921. private _updateGizmoRotationToMatchAttachedMesh;
  105922. private _snapDistance;
  105923. private _scaleRatio;
  105924. /** Fires an event when any of it's sub gizmos are dragged */
  105925. onDragStartObservable: Observable<unknown>;
  105926. /** Fires an event when any of it's sub gizmos are released from dragging */
  105927. onDragEndObservable: Observable<unknown>;
  105928. /**
  105929. * If set to true, planar drag is enabled
  105930. */
  105931. private _planarGizmoEnabled;
  105932. attachedMesh: Nullable<AbstractMesh>;
  105933. /**
  105934. * Creates a PositionGizmo
  105935. * @param gizmoLayer The utility layer the gizmo will be added to
  105936. */
  105937. constructor(gizmoLayer?: UtilityLayerRenderer);
  105938. /**
  105939. * If the planar drag gizmo is enabled
  105940. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  105941. */
  105942. planarGizmoEnabled: boolean;
  105943. updateGizmoRotationToMatchAttachedMesh: boolean;
  105944. /**
  105945. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105946. */
  105947. snapDistance: number;
  105948. /**
  105949. * Ratio for the scale of the gizmo (Default: 1)
  105950. */
  105951. scaleRatio: number;
  105952. /**
  105953. * Disposes of the gizmo
  105954. */
  105955. dispose(): void;
  105956. /**
  105957. * CustomMeshes are not supported by this gizmo
  105958. * @param mesh The mesh to replace the default mesh of the gizmo
  105959. */
  105960. setCustomMesh(mesh: Mesh): void;
  105961. }
  105962. }
  105963. declare module BABYLON {
  105964. /**
  105965. * Single axis drag gizmo
  105966. */
  105967. export class AxisDragGizmo extends Gizmo {
  105968. /**
  105969. * Drag behavior responsible for the gizmos dragging interactions
  105970. */
  105971. dragBehavior: PointerDragBehavior;
  105972. private _pointerObserver;
  105973. /**
  105974. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105975. */
  105976. snapDistance: number;
  105977. /**
  105978. * Event that fires each time the gizmo snaps to a new location.
  105979. * * snapDistance is the the change in distance
  105980. */
  105981. onSnapObservable: Observable<{
  105982. snapDistance: number;
  105983. }>;
  105984. private _isEnabled;
  105985. private _parent;
  105986. private _arrow;
  105987. private _coloredMaterial;
  105988. private _hoverMaterial;
  105989. /** @hidden */
  105990. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  105991. /** @hidden */
  105992. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  105993. /**
  105994. * Creates an AxisDragGizmo
  105995. * @param gizmoLayer The utility layer the gizmo will be added to
  105996. * @param dragAxis The axis which the gizmo will be able to drag on
  105997. * @param color The color of the gizmo
  105998. */
  105999. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106000. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106001. /**
  106002. * If the gizmo is enabled
  106003. */
  106004. isEnabled: boolean;
  106005. /**
  106006. * Disposes of the gizmo
  106007. */
  106008. dispose(): void;
  106009. }
  106010. }
  106011. declare module BABYLON.Debug {
  106012. /**
  106013. * The Axes viewer will show 3 axes in a specific point in space
  106014. */
  106015. export class AxesViewer {
  106016. private _xAxis;
  106017. private _yAxis;
  106018. private _zAxis;
  106019. private _scaleLinesFactor;
  106020. private _instanced;
  106021. /**
  106022. * Gets the hosting scene
  106023. */
  106024. scene: Scene;
  106025. /**
  106026. * Gets or sets a number used to scale line length
  106027. */
  106028. scaleLines: number;
  106029. /** Gets the node hierarchy used to render x-axis */
  106030. readonly xAxis: TransformNode;
  106031. /** Gets the node hierarchy used to render y-axis */
  106032. readonly yAxis: TransformNode;
  106033. /** Gets the node hierarchy used to render z-axis */
  106034. readonly zAxis: TransformNode;
  106035. /**
  106036. * Creates a new AxesViewer
  106037. * @param scene defines the hosting scene
  106038. * @param scaleLines defines a number used to scale line length (1 by default)
  106039. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  106040. * @param xAxis defines the node hierarchy used to render the x-axis
  106041. * @param yAxis defines the node hierarchy used to render the y-axis
  106042. * @param zAxis defines the node hierarchy used to render the z-axis
  106043. */
  106044. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  106045. /**
  106046. * Force the viewer to update
  106047. * @param position defines the position of the viewer
  106048. * @param xaxis defines the x axis of the viewer
  106049. * @param yaxis defines the y axis of the viewer
  106050. * @param zaxis defines the z axis of the viewer
  106051. */
  106052. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  106053. /**
  106054. * Creates an instance of this axes viewer.
  106055. * @returns a new axes viewer with instanced meshes
  106056. */
  106057. createInstance(): AxesViewer;
  106058. /** Releases resources */
  106059. dispose(): void;
  106060. private static _SetRenderingGroupId;
  106061. }
  106062. }
  106063. declare module BABYLON.Debug {
  106064. /**
  106065. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  106066. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  106067. */
  106068. export class BoneAxesViewer extends AxesViewer {
  106069. /**
  106070. * Gets or sets the target mesh where to display the axes viewer
  106071. */
  106072. mesh: Nullable<Mesh>;
  106073. /**
  106074. * Gets or sets the target bone where to display the axes viewer
  106075. */
  106076. bone: Nullable<Bone>;
  106077. /** Gets current position */
  106078. pos: Vector3;
  106079. /** Gets direction of X axis */
  106080. xaxis: Vector3;
  106081. /** Gets direction of Y axis */
  106082. yaxis: Vector3;
  106083. /** Gets direction of Z axis */
  106084. zaxis: Vector3;
  106085. /**
  106086. * Creates a new BoneAxesViewer
  106087. * @param scene defines the hosting scene
  106088. * @param bone defines the target bone
  106089. * @param mesh defines the target mesh
  106090. * @param scaleLines defines a scaling factor for line length (1 by default)
  106091. */
  106092. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  106093. /**
  106094. * Force the viewer to update
  106095. */
  106096. update(): void;
  106097. /** Releases resources */
  106098. dispose(): void;
  106099. }
  106100. }
  106101. declare module BABYLON {
  106102. /**
  106103. * Interface used to define scene explorer extensibility option
  106104. */
  106105. export interface IExplorerExtensibilityOption {
  106106. /**
  106107. * Define the option label
  106108. */
  106109. label: string;
  106110. /**
  106111. * Defines the action to execute on click
  106112. */
  106113. action: (entity: any) => void;
  106114. }
  106115. /**
  106116. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  106117. */
  106118. export interface IExplorerExtensibilityGroup {
  106119. /**
  106120. * Defines a predicate to test if a given type mut be extended
  106121. */
  106122. predicate: (entity: any) => boolean;
  106123. /**
  106124. * Gets the list of options added to a type
  106125. */
  106126. entries: IExplorerExtensibilityOption[];
  106127. }
  106128. /**
  106129. * Interface used to define the options to use to create the Inspector
  106130. */
  106131. export interface IInspectorOptions {
  106132. /**
  106133. * Display in overlay mode (default: false)
  106134. */
  106135. overlay?: boolean;
  106136. /**
  106137. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  106138. */
  106139. globalRoot?: HTMLElement;
  106140. /**
  106141. * Display the Scene explorer
  106142. */
  106143. showExplorer?: boolean;
  106144. /**
  106145. * Display the property inspector
  106146. */
  106147. showInspector?: boolean;
  106148. /**
  106149. * Display in embed mode (both panes on the right)
  106150. */
  106151. embedMode?: boolean;
  106152. /**
  106153. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  106154. */
  106155. handleResize?: boolean;
  106156. /**
  106157. * Allow the panes to popup (default: true)
  106158. */
  106159. enablePopup?: boolean;
  106160. /**
  106161. * Allow the panes to be closed by users (default: true)
  106162. */
  106163. enableClose?: boolean;
  106164. /**
  106165. * Optional list of extensibility entries
  106166. */
  106167. explorerExtensibility?: IExplorerExtensibilityGroup[];
  106168. /**
  106169. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  106170. */
  106171. inspectorURL?: string;
  106172. }
  106173. interface Scene {
  106174. /**
  106175. * @hidden
  106176. * Backing field
  106177. */
  106178. _debugLayer: DebugLayer;
  106179. /**
  106180. * Gets the debug layer (aka Inspector) associated with the scene
  106181. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106182. */
  106183. debugLayer: DebugLayer;
  106184. }
  106185. /**
  106186. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106187. * what is happening in your scene
  106188. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106189. */
  106190. export class DebugLayer {
  106191. /**
  106192. * Define the url to get the inspector script from.
  106193. * By default it uses the babylonjs CDN.
  106194. * @ignoreNaming
  106195. */
  106196. static InspectorURL: string;
  106197. private _scene;
  106198. private BJSINSPECTOR;
  106199. private _onPropertyChangedObservable?;
  106200. /**
  106201. * Observable triggered when a property is changed through the inspector.
  106202. */
  106203. readonly onPropertyChangedObservable: any;
  106204. /**
  106205. * Instantiates a new debug layer.
  106206. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106207. * what is happening in your scene
  106208. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106209. * @param scene Defines the scene to inspect
  106210. */
  106211. constructor(scene: Scene);
  106212. /** Creates the inspector window. */
  106213. private _createInspector;
  106214. /**
  106215. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  106216. * @param entity defines the entity to select
  106217. * @param lineContainerTitle defines the specific block to highlight
  106218. */
  106219. select(entity: any, lineContainerTitle?: string): void;
  106220. /** Get the inspector from bundle or global */
  106221. private _getGlobalInspector;
  106222. /**
  106223. * Get if the inspector is visible or not.
  106224. * @returns true if visible otherwise, false
  106225. */
  106226. isVisible(): boolean;
  106227. /**
  106228. * Hide the inspector and close its window.
  106229. */
  106230. hide(): void;
  106231. /**
  106232. * Launch the debugLayer.
  106233. * @param config Define the configuration of the inspector
  106234. * @return a promise fulfilled when the debug layer is visible
  106235. */
  106236. show(config?: IInspectorOptions): Promise<DebugLayer>;
  106237. }
  106238. }
  106239. declare module BABYLON {
  106240. /**
  106241. * Class containing static functions to help procedurally build meshes
  106242. */
  106243. export class BoxBuilder {
  106244. /**
  106245. * Creates a box mesh
  106246. * * The parameter `size` sets the size (float) of each box side (default 1)
  106247. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106248. * * 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)
  106249. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106253. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106254. * @param name defines the name of the mesh
  106255. * @param options defines the options used to create the mesh
  106256. * @param scene defines the hosting scene
  106257. * @returns the box mesh
  106258. */
  106259. static CreateBox(name: string, options: {
  106260. size?: number;
  106261. width?: number;
  106262. height?: number;
  106263. depth?: number;
  106264. faceUV?: Vector4[];
  106265. faceColors?: Color4[];
  106266. sideOrientation?: number;
  106267. frontUVs?: Vector4;
  106268. backUVs?: Vector4;
  106269. wrap?: boolean;
  106270. topBaseAt?: number;
  106271. bottomBaseAt?: number;
  106272. updatable?: boolean;
  106273. }, scene?: Nullable<Scene>): Mesh;
  106274. }
  106275. }
  106276. declare module BABYLON {
  106277. /**
  106278. * Class containing static functions to help procedurally build meshes
  106279. */
  106280. export class SphereBuilder {
  106281. /**
  106282. * Creates a sphere mesh
  106283. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106284. * * 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`)
  106285. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106286. * * 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
  106287. * * 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)
  106288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106291. * @param name defines the name of the mesh
  106292. * @param options defines the options used to create the mesh
  106293. * @param scene defines the hosting scene
  106294. * @returns the sphere mesh
  106295. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106296. */
  106297. static CreateSphere(name: string, options: {
  106298. segments?: number;
  106299. diameter?: number;
  106300. diameterX?: number;
  106301. diameterY?: number;
  106302. diameterZ?: number;
  106303. arc?: number;
  106304. slice?: number;
  106305. sideOrientation?: number;
  106306. frontUVs?: Vector4;
  106307. backUVs?: Vector4;
  106308. updatable?: boolean;
  106309. }, scene: any): Mesh;
  106310. }
  106311. }
  106312. declare module BABYLON.Debug {
  106313. /**
  106314. * Used to show the physics impostor around the specific mesh
  106315. */
  106316. export class PhysicsViewer {
  106317. /** @hidden */
  106318. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  106319. /** @hidden */
  106320. protected _meshes: Array<Nullable<AbstractMesh>>;
  106321. /** @hidden */
  106322. protected _scene: Nullable<Scene>;
  106323. /** @hidden */
  106324. protected _numMeshes: number;
  106325. /** @hidden */
  106326. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  106327. private _renderFunction;
  106328. private _utilityLayer;
  106329. private _debugBoxMesh;
  106330. private _debugSphereMesh;
  106331. private _debugCylinderMesh;
  106332. private _debugMaterial;
  106333. private _debugMeshMeshes;
  106334. /**
  106335. * Creates a new PhysicsViewer
  106336. * @param scene defines the hosting scene
  106337. */
  106338. constructor(scene: Scene);
  106339. /** @hidden */
  106340. protected _updateDebugMeshes(): void;
  106341. /**
  106342. * Renders a specified physic impostor
  106343. * @param impostor defines the impostor to render
  106344. * @param targetMesh defines the mesh represented by the impostor
  106345. * @returns the new debug mesh used to render the impostor
  106346. */
  106347. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  106348. /**
  106349. * Hides a specified physic impostor
  106350. * @param impostor defines the impostor to hide
  106351. */
  106352. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  106353. private _getDebugMaterial;
  106354. private _getDebugBoxMesh;
  106355. private _getDebugSphereMesh;
  106356. private _getDebugCylinderMesh;
  106357. private _getDebugMeshMesh;
  106358. private _getDebugMesh;
  106359. /** Releases all resources */
  106360. dispose(): void;
  106361. }
  106362. }
  106363. declare module BABYLON {
  106364. /**
  106365. * Class containing static functions to help procedurally build meshes
  106366. */
  106367. export class LinesBuilder {
  106368. /**
  106369. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106370. * * 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
  106371. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106372. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106373. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106374. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106375. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106376. * * 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
  106377. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106380. * @param name defines the name of the new line system
  106381. * @param options defines the options used to create the line system
  106382. * @param scene defines the hosting scene
  106383. * @returns a new line system mesh
  106384. */
  106385. static CreateLineSystem(name: string, options: {
  106386. lines: Vector3[][];
  106387. updatable?: boolean;
  106388. instance?: Nullable<LinesMesh>;
  106389. colors?: Nullable<Color4[][]>;
  106390. useVertexAlpha?: boolean;
  106391. }, scene: Nullable<Scene>): LinesMesh;
  106392. /**
  106393. * Creates a line mesh
  106394. * 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
  106395. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106396. * * The parameter `points` is an array successive Vector3
  106397. * * 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
  106398. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106399. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106400. * * When updating an instance, remember that only point positions can change, not the number of points
  106401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106403. * @param name defines the name of the new line system
  106404. * @param options defines the options used to create the line system
  106405. * @param scene defines the hosting scene
  106406. * @returns a new line mesh
  106407. */
  106408. static CreateLines(name: string, options: {
  106409. points: Vector3[];
  106410. updatable?: boolean;
  106411. instance?: Nullable<LinesMesh>;
  106412. colors?: Color4[];
  106413. useVertexAlpha?: boolean;
  106414. }, scene?: Nullable<Scene>): LinesMesh;
  106415. /**
  106416. * Creates a dashed line mesh
  106417. * * 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
  106418. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106419. * * The parameter `points` is an array successive Vector3
  106420. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106421. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106422. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106423. * * 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
  106424. * * When updating an instance, remember that only point positions can change, not the number of points
  106425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106426. * @param name defines the name of the mesh
  106427. * @param options defines the options used to create the mesh
  106428. * @param scene defines the hosting scene
  106429. * @returns the dashed line mesh
  106430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106431. */
  106432. static CreateDashedLines(name: string, options: {
  106433. points: Vector3[];
  106434. dashSize?: number;
  106435. gapSize?: number;
  106436. dashNb?: number;
  106437. updatable?: boolean;
  106438. instance?: LinesMesh;
  106439. }, scene?: Nullable<Scene>): LinesMesh;
  106440. }
  106441. }
  106442. declare module BABYLON {
  106443. /**
  106444. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106445. * in order to better appreciate the issue one might have.
  106446. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106447. */
  106448. export class RayHelper {
  106449. /**
  106450. * Defines the ray we are currently tryin to visualize.
  106451. */
  106452. ray: Nullable<Ray>;
  106453. private _renderPoints;
  106454. private _renderLine;
  106455. private _renderFunction;
  106456. private _scene;
  106457. private _updateToMeshFunction;
  106458. private _attachedToMesh;
  106459. private _meshSpaceDirection;
  106460. private _meshSpaceOrigin;
  106461. /**
  106462. * Helper function to create a colored helper in a scene in one line.
  106463. * @param ray Defines the ray we are currently tryin to visualize
  106464. * @param scene Defines the scene the ray is used in
  106465. * @param color Defines the color we want to see the ray in
  106466. * @returns The newly created ray helper.
  106467. */
  106468. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  106469. /**
  106470. * Instantiate a new ray helper.
  106471. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106472. * in order to better appreciate the issue one might have.
  106473. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106474. * @param ray Defines the ray we are currently tryin to visualize
  106475. */
  106476. constructor(ray: Ray);
  106477. /**
  106478. * Shows the ray we are willing to debug.
  106479. * @param scene Defines the scene the ray needs to be rendered in
  106480. * @param color Defines the color the ray needs to be rendered in
  106481. */
  106482. show(scene: Scene, color?: Color3): void;
  106483. /**
  106484. * Hides the ray we are debugging.
  106485. */
  106486. hide(): void;
  106487. private _render;
  106488. /**
  106489. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  106490. * @param mesh Defines the mesh we want the helper attached to
  106491. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  106492. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  106493. * @param length Defines the length of the ray
  106494. */
  106495. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  106496. /**
  106497. * Detach the ray helper from the mesh it has previously been attached to.
  106498. */
  106499. detachFromMesh(): void;
  106500. private _updateToMesh;
  106501. /**
  106502. * Dispose the helper and release its associated resources.
  106503. */
  106504. dispose(): void;
  106505. }
  106506. }
  106507. declare module BABYLON.Debug {
  106508. /**
  106509. * Class used to render a debug view of a given skeleton
  106510. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  106511. */
  106512. export class SkeletonViewer {
  106513. /** defines the skeleton to render */
  106514. skeleton: Skeleton;
  106515. /** defines the mesh attached to the skeleton */
  106516. mesh: AbstractMesh;
  106517. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106518. autoUpdateBonesMatrices: boolean;
  106519. /** defines the rendering group id to use with the viewer */
  106520. renderingGroupId: number;
  106521. /** Gets or sets the color used to render the skeleton */
  106522. color: Color3;
  106523. private _scene;
  106524. private _debugLines;
  106525. private _debugMesh;
  106526. private _isEnabled;
  106527. private _renderFunction;
  106528. private _utilityLayer;
  106529. /**
  106530. * Returns the mesh used to render the bones
  106531. */
  106532. readonly debugMesh: Nullable<LinesMesh>;
  106533. /**
  106534. * Creates a new SkeletonViewer
  106535. * @param skeleton defines the skeleton to render
  106536. * @param mesh defines the mesh attached to the skeleton
  106537. * @param scene defines the hosting scene
  106538. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  106539. * @param renderingGroupId defines the rendering group id to use with the viewer
  106540. */
  106541. constructor(
  106542. /** defines the skeleton to render */
  106543. skeleton: Skeleton,
  106544. /** defines the mesh attached to the skeleton */
  106545. mesh: AbstractMesh, scene: Scene,
  106546. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106547. autoUpdateBonesMatrices?: boolean,
  106548. /** defines the rendering group id to use with the viewer */
  106549. renderingGroupId?: number);
  106550. /** Gets or sets a boolean indicating if the viewer is enabled */
  106551. isEnabled: boolean;
  106552. private _getBonePosition;
  106553. private _getLinesForBonesWithLength;
  106554. private _getLinesForBonesNoLength;
  106555. /** Update the viewer to sync with current skeleton state */
  106556. update(): void;
  106557. /** Release associated resources */
  106558. dispose(): void;
  106559. }
  106560. }
  106561. declare module BABYLON {
  106562. /**
  106563. * Options to create the null engine
  106564. */
  106565. export class NullEngineOptions {
  106566. /**
  106567. * Render width (Default: 512)
  106568. */
  106569. renderWidth: number;
  106570. /**
  106571. * Render height (Default: 256)
  106572. */
  106573. renderHeight: number;
  106574. /**
  106575. * Texture size (Default: 512)
  106576. */
  106577. textureSize: number;
  106578. /**
  106579. * If delta time between frames should be constant
  106580. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106581. */
  106582. deterministicLockstep: boolean;
  106583. /**
  106584. * Maximum about of steps between frames (Default: 4)
  106585. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106586. */
  106587. lockstepMaxSteps: number;
  106588. }
  106589. /**
  106590. * The null engine class provides support for headless version of babylon.js.
  106591. * This can be used in server side scenario or for testing purposes
  106592. */
  106593. export class NullEngine extends Engine {
  106594. private _options;
  106595. /**
  106596. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106597. */
  106598. isDeterministicLockStep(): boolean;
  106599. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  106600. getLockstepMaxSteps(): number;
  106601. /**
  106602. * Sets hardware scaling, used to save performance if needed
  106603. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  106604. */
  106605. getHardwareScalingLevel(): number;
  106606. constructor(options?: NullEngineOptions);
  106607. createVertexBuffer(vertices: FloatArray): DataBuffer;
  106608. createIndexBuffer(indices: IndicesArray): DataBuffer;
  106609. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  106610. getRenderWidth(useScreen?: boolean): number;
  106611. getRenderHeight(useScreen?: boolean): number;
  106612. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  106613. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  106614. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106615. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106616. bindSamplers(effect: Effect): void;
  106617. enableEffect(effect: Effect): void;
  106618. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106619. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  106620. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  106621. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  106622. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  106623. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  106624. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  106625. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  106626. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  106627. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  106628. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  106629. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  106630. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  106631. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  106632. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106633. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106634. setFloat(uniform: WebGLUniformLocation, value: number): void;
  106635. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  106636. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  106637. setBool(uniform: WebGLUniformLocation, bool: number): void;
  106638. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  106639. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106640. bindBuffers(vertexBuffers: {
  106641. [key: string]: VertexBuffer;
  106642. }, indexBuffer: DataBuffer, effect: Effect): void;
  106643. wipeCaches(bruteForce?: boolean): void;
  106644. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106645. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106646. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106647. /** @hidden */
  106648. _createTexture(): WebGLTexture;
  106649. /** @hidden */
  106650. _releaseTexture(texture: InternalTexture): void;
  106651. 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;
  106652. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  106653. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  106654. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  106655. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  106656. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  106657. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  106658. areAllEffectsReady(): boolean;
  106659. /**
  106660. * @hidden
  106661. * Get the current error code of the webGL context
  106662. * @returns the error code
  106663. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106664. */
  106665. getError(): number;
  106666. /** @hidden */
  106667. _getUnpackAlignement(): number;
  106668. /** @hidden */
  106669. _unpackFlipY(value: boolean): void;
  106670. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  106671. /**
  106672. * Updates a dynamic vertex buffer.
  106673. * @param vertexBuffer the vertex buffer to update
  106674. * @param data the data used to update the vertex buffer
  106675. * @param byteOffset the byte offset of the data (optional)
  106676. * @param byteLength the byte length of the data (optional)
  106677. */
  106678. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  106679. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  106680. /** @hidden */
  106681. _bindTexture(channel: number, texture: InternalTexture): void;
  106682. /** @hidden */
  106683. _releaseBuffer(buffer: DataBuffer): boolean;
  106684. releaseEffects(): void;
  106685. displayLoadingUI(): void;
  106686. hideLoadingUI(): void;
  106687. /** @hidden */
  106688. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106689. /** @hidden */
  106690. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106691. /** @hidden */
  106692. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106693. /** @hidden */
  106694. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  106695. }
  106696. }
  106697. declare module BABYLON {
  106698. /** @hidden */
  106699. export class _OcclusionDataStorage {
  106700. /** @hidden */
  106701. occlusionInternalRetryCounter: number;
  106702. /** @hidden */
  106703. isOcclusionQueryInProgress: boolean;
  106704. /** @hidden */
  106705. isOccluded: boolean;
  106706. /** @hidden */
  106707. occlusionRetryCount: number;
  106708. /** @hidden */
  106709. occlusionType: number;
  106710. /** @hidden */
  106711. occlusionQueryAlgorithmType: number;
  106712. }
  106713. interface Engine {
  106714. /**
  106715. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  106716. * @return the new query
  106717. */
  106718. createQuery(): WebGLQuery;
  106719. /**
  106720. * Delete and release a webGL query
  106721. * @param query defines the query to delete
  106722. * @return the current engine
  106723. */
  106724. deleteQuery(query: WebGLQuery): Engine;
  106725. /**
  106726. * Check if a given query has resolved and got its value
  106727. * @param query defines the query to check
  106728. * @returns true if the query got its value
  106729. */
  106730. isQueryResultAvailable(query: WebGLQuery): boolean;
  106731. /**
  106732. * Gets the value of a given query
  106733. * @param query defines the query to check
  106734. * @returns the value of the query
  106735. */
  106736. getQueryResult(query: WebGLQuery): number;
  106737. /**
  106738. * Initiates an occlusion query
  106739. * @param algorithmType defines the algorithm to use
  106740. * @param query defines the query to use
  106741. * @returns the current engine
  106742. * @see http://doc.babylonjs.com/features/occlusionquery
  106743. */
  106744. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  106745. /**
  106746. * Ends an occlusion query
  106747. * @see http://doc.babylonjs.com/features/occlusionquery
  106748. * @param algorithmType defines the algorithm to use
  106749. * @returns the current engine
  106750. */
  106751. endOcclusionQuery(algorithmType: number): Engine;
  106752. /**
  106753. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  106754. * Please note that only one query can be issued at a time
  106755. * @returns a time token used to track the time span
  106756. */
  106757. startTimeQuery(): Nullable<_TimeToken>;
  106758. /**
  106759. * Ends a time query
  106760. * @param token defines the token used to measure the time span
  106761. * @returns the time spent (in ns)
  106762. */
  106763. endTimeQuery(token: _TimeToken): int;
  106764. /** @hidden */
  106765. _currentNonTimestampToken: Nullable<_TimeToken>;
  106766. /** @hidden */
  106767. _createTimeQuery(): WebGLQuery;
  106768. /** @hidden */
  106769. _deleteTimeQuery(query: WebGLQuery): void;
  106770. /** @hidden */
  106771. _getGlAlgorithmType(algorithmType: number): number;
  106772. /** @hidden */
  106773. _getTimeQueryResult(query: WebGLQuery): any;
  106774. /** @hidden */
  106775. _getTimeQueryAvailability(query: WebGLQuery): any;
  106776. }
  106777. interface AbstractMesh {
  106778. /**
  106779. * Backing filed
  106780. * @hidden
  106781. */
  106782. __occlusionDataStorage: _OcclusionDataStorage;
  106783. /**
  106784. * Access property
  106785. * @hidden
  106786. */
  106787. _occlusionDataStorage: _OcclusionDataStorage;
  106788. /**
  106789. * 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.
  106790. * The default value is -1 which means don't break the query and wait till the result
  106791. * @see http://doc.babylonjs.com/features/occlusionquery
  106792. */
  106793. occlusionRetryCount: number;
  106794. /**
  106795. * 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:
  106796. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  106797. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  106798. * * 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.
  106799. * @see http://doc.babylonjs.com/features/occlusionquery
  106800. */
  106801. occlusionType: number;
  106802. /**
  106803. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  106804. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  106805. * * 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.
  106806. * @see http://doc.babylonjs.com/features/occlusionquery
  106807. */
  106808. occlusionQueryAlgorithmType: number;
  106809. /**
  106810. * 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
  106811. * @see http://doc.babylonjs.com/features/occlusionquery
  106812. */
  106813. isOccluded: boolean;
  106814. /**
  106815. * Flag to check the progress status of the query
  106816. * @see http://doc.babylonjs.com/features/occlusionquery
  106817. */
  106818. isOcclusionQueryInProgress: boolean;
  106819. }
  106820. }
  106821. declare module BABYLON {
  106822. /** @hidden */
  106823. export var _forceTransformFeedbackToBundle: boolean;
  106824. interface Engine {
  106825. /**
  106826. * Creates a webGL transform feedback object
  106827. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  106828. * @returns the webGL transform feedback object
  106829. */
  106830. createTransformFeedback(): WebGLTransformFeedback;
  106831. /**
  106832. * Delete a webGL transform feedback object
  106833. * @param value defines the webGL transform feedback object to delete
  106834. */
  106835. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  106836. /**
  106837. * Bind a webGL transform feedback object to the webgl context
  106838. * @param value defines the webGL transform feedback object to bind
  106839. */
  106840. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  106841. /**
  106842. * Begins a transform feedback operation
  106843. * @param usePoints defines if points or triangles must be used
  106844. */
  106845. beginTransformFeedback(usePoints: boolean): void;
  106846. /**
  106847. * Ends a transform feedback operation
  106848. */
  106849. endTransformFeedback(): void;
  106850. /**
  106851. * Specify the varyings to use with transform feedback
  106852. * @param program defines the associated webGL program
  106853. * @param value defines the list of strings representing the varying names
  106854. */
  106855. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  106856. /**
  106857. * Bind a webGL buffer for a transform feedback operation
  106858. * @param value defines the webGL buffer to bind
  106859. */
  106860. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  106861. }
  106862. }
  106863. declare module BABYLON {
  106864. /**
  106865. * Creation options of the multi render target texture.
  106866. */
  106867. export interface IMultiRenderTargetOptions {
  106868. /**
  106869. * Define if the texture needs to create mip maps after render.
  106870. */
  106871. generateMipMaps?: boolean;
  106872. /**
  106873. * Define the types of all the draw buffers we want to create
  106874. */
  106875. types?: number[];
  106876. /**
  106877. * Define the sampling modes of all the draw buffers we want to create
  106878. */
  106879. samplingModes?: number[];
  106880. /**
  106881. * Define if a depth buffer is required
  106882. */
  106883. generateDepthBuffer?: boolean;
  106884. /**
  106885. * Define if a stencil buffer is required
  106886. */
  106887. generateStencilBuffer?: boolean;
  106888. /**
  106889. * Define if a depth texture is required instead of a depth buffer
  106890. */
  106891. generateDepthTexture?: boolean;
  106892. /**
  106893. * Define the number of desired draw buffers
  106894. */
  106895. textureCount?: number;
  106896. /**
  106897. * Define if aspect ratio should be adapted to the texture or stay the scene one
  106898. */
  106899. doNotChangeAspectRatio?: boolean;
  106900. /**
  106901. * Define the default type of the buffers we are creating
  106902. */
  106903. defaultType?: number;
  106904. }
  106905. /**
  106906. * A multi render target, like a render target provides the ability to render to a texture.
  106907. * Unlike the render target, it can render to several draw buffers in one draw.
  106908. * This is specially interesting in deferred rendering or for any effects requiring more than
  106909. * just one color from a single pass.
  106910. */
  106911. export class MultiRenderTarget extends RenderTargetTexture {
  106912. private _internalTextures;
  106913. private _textures;
  106914. private _multiRenderTargetOptions;
  106915. /**
  106916. * Get if draw buffers are currently supported by the used hardware and browser.
  106917. */
  106918. readonly isSupported: boolean;
  106919. /**
  106920. * Get the list of textures generated by the multi render target.
  106921. */
  106922. readonly textures: Texture[];
  106923. /**
  106924. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  106925. */
  106926. readonly depthTexture: Texture;
  106927. /**
  106928. * Set the wrapping mode on U of all the textures we are rendering to.
  106929. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  106930. */
  106931. wrapU: number;
  106932. /**
  106933. * Set the wrapping mode on V of all the textures we are rendering to.
  106934. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  106935. */
  106936. wrapV: number;
  106937. /**
  106938. * Instantiate a new multi render target texture.
  106939. * A multi render target, like a render target provides the ability to render to a texture.
  106940. * Unlike the render target, it can render to several draw buffers in one draw.
  106941. * This is specially interesting in deferred rendering or for any effects requiring more than
  106942. * just one color from a single pass.
  106943. * @param name Define the name of the texture
  106944. * @param size Define the size of the buffers to render to
  106945. * @param count Define the number of target we are rendering into
  106946. * @param scene Define the scene the texture belongs to
  106947. * @param options Define the options used to create the multi render target
  106948. */
  106949. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  106950. /** @hidden */
  106951. _rebuild(): void;
  106952. private _createInternalTextures;
  106953. private _createTextures;
  106954. /**
  106955. * Define the number of samples used if MSAA is enabled.
  106956. */
  106957. samples: number;
  106958. /**
  106959. * Resize all the textures in the multi render target.
  106960. * Be carrefull as it will recreate all the data in the new texture.
  106961. * @param size Define the new size
  106962. */
  106963. resize(size: any): void;
  106964. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  106965. /**
  106966. * Dispose the render targets and their associated resources
  106967. */
  106968. dispose(): void;
  106969. /**
  106970. * Release all the underlying texture used as draw buffers.
  106971. */
  106972. releaseInternalTextures(): void;
  106973. }
  106974. }
  106975. declare module BABYLON {
  106976. interface Engine {
  106977. /**
  106978. * Unbind a list of render target textures from the webGL context
  106979. * This is used only when drawBuffer extension or webGL2 are active
  106980. * @param textures defines the render target textures to unbind
  106981. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  106982. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  106983. */
  106984. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  106985. /**
  106986. * Create a multi render target texture
  106987. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  106988. * @param size defines the size of the texture
  106989. * @param options defines the creation options
  106990. * @returns the cube texture as an InternalTexture
  106991. */
  106992. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  106993. /**
  106994. * Update the sample count for a given multiple render target texture
  106995. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106996. * @param textures defines the textures to update
  106997. * @param samples defines the sample count to set
  106998. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106999. */
  107000. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  107001. }
  107002. }
  107003. declare module BABYLON {
  107004. /**
  107005. * Gather the list of clipboard event types as constants.
  107006. */
  107007. export class ClipboardEventTypes {
  107008. /**
  107009. * The clipboard event is fired when a copy command is active (pressed).
  107010. */
  107011. static readonly COPY: number;
  107012. /**
  107013. * The clipboard event is fired when a cut command is active (pressed).
  107014. */
  107015. static readonly CUT: number;
  107016. /**
  107017. * The clipboard event is fired when a paste command is active (pressed).
  107018. */
  107019. static readonly PASTE: number;
  107020. }
  107021. /**
  107022. * This class is used to store clipboard related info for the onClipboardObservable event.
  107023. */
  107024. export class ClipboardInfo {
  107025. /**
  107026. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107027. */
  107028. type: number;
  107029. /**
  107030. * Defines the related dom event
  107031. */
  107032. event: ClipboardEvent;
  107033. /**
  107034. *Creates an instance of ClipboardInfo.
  107035. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  107036. * @param event Defines the related dom event
  107037. */
  107038. constructor(
  107039. /**
  107040. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107041. */
  107042. type: number,
  107043. /**
  107044. * Defines the related dom event
  107045. */
  107046. event: ClipboardEvent);
  107047. /**
  107048. * Get the clipboard event's type from the keycode.
  107049. * @param keyCode Defines the keyCode for the current keyboard event.
  107050. * @return {number}
  107051. */
  107052. static GetTypeFromCharacter(keyCode: number): number;
  107053. }
  107054. }
  107055. declare module BABYLON {
  107056. /**
  107057. * Google Daydream controller
  107058. */
  107059. export class DaydreamController extends WebVRController {
  107060. /**
  107061. * Base Url for the controller model.
  107062. */
  107063. static MODEL_BASE_URL: string;
  107064. /**
  107065. * File name for the controller model.
  107066. */
  107067. static MODEL_FILENAME: string;
  107068. /**
  107069. * Gamepad Id prefix used to identify Daydream Controller.
  107070. */
  107071. static readonly GAMEPAD_ID_PREFIX: string;
  107072. /**
  107073. * Creates a new DaydreamController from a gamepad
  107074. * @param vrGamepad the gamepad that the controller should be created from
  107075. */
  107076. constructor(vrGamepad: any);
  107077. /**
  107078. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107079. * @param scene scene in which to add meshes
  107080. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107081. */
  107082. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107083. /**
  107084. * Called once for each button that changed state since the last frame
  107085. * @param buttonIdx Which button index changed
  107086. * @param state New state of the button
  107087. * @param changes Which properties on the state changed since last frame
  107088. */
  107089. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107090. }
  107091. }
  107092. declare module BABYLON {
  107093. /**
  107094. * Gear VR Controller
  107095. */
  107096. export class GearVRController extends WebVRController {
  107097. /**
  107098. * Base Url for the controller model.
  107099. */
  107100. static MODEL_BASE_URL: string;
  107101. /**
  107102. * File name for the controller model.
  107103. */
  107104. static MODEL_FILENAME: string;
  107105. /**
  107106. * Gamepad Id prefix used to identify this controller.
  107107. */
  107108. static readonly GAMEPAD_ID_PREFIX: string;
  107109. private readonly _buttonIndexToObservableNameMap;
  107110. /**
  107111. * Creates a new GearVRController from a gamepad
  107112. * @param vrGamepad the gamepad that the controller should be created from
  107113. */
  107114. constructor(vrGamepad: any);
  107115. /**
  107116. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107117. * @param scene scene in which to add meshes
  107118. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107119. */
  107120. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107121. /**
  107122. * Called once for each button that changed state since the last frame
  107123. * @param buttonIdx Which button index changed
  107124. * @param state New state of the button
  107125. * @param changes Which properties on the state changed since last frame
  107126. */
  107127. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107128. }
  107129. }
  107130. declare module BABYLON {
  107131. /**
  107132. * Class containing static functions to help procedurally build meshes
  107133. */
  107134. export class PolyhedronBuilder {
  107135. /**
  107136. * Creates a polyhedron mesh
  107137. * * 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
  107138. * * The parameter `size` (positive float, default 1) sets the polygon size
  107139. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107140. * * 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`
  107141. * * 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
  107142. * * 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)`)
  107143. * * 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
  107144. * * 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
  107145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107146. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107148. * @param name defines the name of the mesh
  107149. * @param options defines the options used to create the mesh
  107150. * @param scene defines the hosting scene
  107151. * @returns the polyhedron mesh
  107152. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107153. */
  107154. static CreatePolyhedron(name: string, options: {
  107155. type?: number;
  107156. size?: number;
  107157. sizeX?: number;
  107158. sizeY?: number;
  107159. sizeZ?: number;
  107160. custom?: any;
  107161. faceUV?: Vector4[];
  107162. faceColors?: Color4[];
  107163. flat?: boolean;
  107164. updatable?: boolean;
  107165. sideOrientation?: number;
  107166. frontUVs?: Vector4;
  107167. backUVs?: Vector4;
  107168. }, scene?: Nullable<Scene>): Mesh;
  107169. }
  107170. }
  107171. declare module BABYLON {
  107172. /**
  107173. * Gizmo that enables scaling a mesh along 3 axis
  107174. */
  107175. export class ScaleGizmo extends Gizmo {
  107176. /**
  107177. * Internal gizmo used for interactions on the x axis
  107178. */
  107179. xGizmo: AxisScaleGizmo;
  107180. /**
  107181. * Internal gizmo used for interactions on the y axis
  107182. */
  107183. yGizmo: AxisScaleGizmo;
  107184. /**
  107185. * Internal gizmo used for interactions on the z axis
  107186. */
  107187. zGizmo: AxisScaleGizmo;
  107188. /**
  107189. * Internal gizmo used to scale all axis equally
  107190. */
  107191. uniformScaleGizmo: AxisScaleGizmo;
  107192. private _meshAttached;
  107193. private _updateGizmoRotationToMatchAttachedMesh;
  107194. private _snapDistance;
  107195. private _scaleRatio;
  107196. private _uniformScalingMesh;
  107197. private _octahedron;
  107198. /** Fires an event when any of it's sub gizmos are dragged */
  107199. onDragStartObservable: Observable<unknown>;
  107200. /** Fires an event when any of it's sub gizmos are released from dragging */
  107201. onDragEndObservable: Observable<unknown>;
  107202. attachedMesh: Nullable<AbstractMesh>;
  107203. /**
  107204. * Creates a ScaleGizmo
  107205. * @param gizmoLayer The utility layer the gizmo will be added to
  107206. */
  107207. constructor(gizmoLayer?: UtilityLayerRenderer);
  107208. updateGizmoRotationToMatchAttachedMesh: boolean;
  107209. /**
  107210. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107211. */
  107212. snapDistance: number;
  107213. /**
  107214. * Ratio for the scale of the gizmo (Default: 1)
  107215. */
  107216. scaleRatio: number;
  107217. /**
  107218. * Disposes of the gizmo
  107219. */
  107220. dispose(): void;
  107221. }
  107222. }
  107223. declare module BABYLON {
  107224. /**
  107225. * Single axis scale gizmo
  107226. */
  107227. export class AxisScaleGizmo extends Gizmo {
  107228. /**
  107229. * Drag behavior responsible for the gizmos dragging interactions
  107230. */
  107231. dragBehavior: PointerDragBehavior;
  107232. private _pointerObserver;
  107233. /**
  107234. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107235. */
  107236. snapDistance: number;
  107237. /**
  107238. * Event that fires each time the gizmo snaps to a new location.
  107239. * * snapDistance is the the change in distance
  107240. */
  107241. onSnapObservable: Observable<{
  107242. snapDistance: number;
  107243. }>;
  107244. /**
  107245. * If the scaling operation should be done on all axis (default: false)
  107246. */
  107247. uniformScaling: boolean;
  107248. private _isEnabled;
  107249. private _parent;
  107250. private _arrow;
  107251. private _coloredMaterial;
  107252. private _hoverMaterial;
  107253. /**
  107254. * Creates an AxisScaleGizmo
  107255. * @param gizmoLayer The utility layer the gizmo will be added to
  107256. * @param dragAxis The axis which the gizmo will be able to scale on
  107257. * @param color The color of the gizmo
  107258. */
  107259. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  107260. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107261. /**
  107262. * If the gizmo is enabled
  107263. */
  107264. isEnabled: boolean;
  107265. /**
  107266. * Disposes of the gizmo
  107267. */
  107268. dispose(): void;
  107269. /**
  107270. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107271. * @param mesh The mesh to replace the default mesh of the gizmo
  107272. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  107273. */
  107274. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  107275. }
  107276. }
  107277. declare module BABYLON {
  107278. /**
  107279. * Bounding box gizmo
  107280. */
  107281. export class BoundingBoxGizmo extends Gizmo {
  107282. private _lineBoundingBox;
  107283. private _rotateSpheresParent;
  107284. private _scaleBoxesParent;
  107285. private _boundingDimensions;
  107286. private _renderObserver;
  107287. private _pointerObserver;
  107288. private _scaleDragSpeed;
  107289. private _tmpQuaternion;
  107290. private _tmpVector;
  107291. private _tmpRotationMatrix;
  107292. /**
  107293. * 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)
  107294. */
  107295. ignoreChildren: boolean;
  107296. /**
  107297. * 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)
  107298. */
  107299. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  107300. /**
  107301. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  107302. */
  107303. rotationSphereSize: number;
  107304. /**
  107305. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  107306. */
  107307. scaleBoxSize: number;
  107308. /**
  107309. * 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)
  107310. */
  107311. fixedDragMeshScreenSize: boolean;
  107312. /**
  107313. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  107314. */
  107315. fixedDragMeshScreenSizeDistanceFactor: number;
  107316. /**
  107317. * Fired when a rotation sphere or scale box is dragged
  107318. */
  107319. onDragStartObservable: Observable<{}>;
  107320. /**
  107321. * Fired when a scale box is dragged
  107322. */
  107323. onScaleBoxDragObservable: Observable<{}>;
  107324. /**
  107325. * Fired when a scale box drag is ended
  107326. */
  107327. onScaleBoxDragEndObservable: Observable<{}>;
  107328. /**
  107329. * Fired when a rotation sphere is dragged
  107330. */
  107331. onRotationSphereDragObservable: Observable<{}>;
  107332. /**
  107333. * Fired when a rotation sphere drag is ended
  107334. */
  107335. onRotationSphereDragEndObservable: Observable<{}>;
  107336. /**
  107337. * 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)
  107338. */
  107339. scalePivot: Nullable<Vector3>;
  107340. /**
  107341. * Mesh used as a pivot to rotate the attached mesh
  107342. */
  107343. private _anchorMesh;
  107344. private _existingMeshScale;
  107345. private _dragMesh;
  107346. private pointerDragBehavior;
  107347. private coloredMaterial;
  107348. private hoverColoredMaterial;
  107349. /**
  107350. * Sets the color of the bounding box gizmo
  107351. * @param color the color to set
  107352. */
  107353. setColor(color: Color3): void;
  107354. /**
  107355. * Creates an BoundingBoxGizmo
  107356. * @param gizmoLayer The utility layer the gizmo will be added to
  107357. * @param color The color of the gizmo
  107358. */
  107359. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  107360. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107361. private _selectNode;
  107362. /**
  107363. * Updates the bounding box information for the Gizmo
  107364. */
  107365. updateBoundingBox(): void;
  107366. private _updateRotationSpheres;
  107367. private _updateScaleBoxes;
  107368. /**
  107369. * Enables rotation on the specified axis and disables rotation on the others
  107370. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  107371. */
  107372. setEnabledRotationAxis(axis: string): void;
  107373. /**
  107374. * Enables/disables scaling
  107375. * @param enable if scaling should be enabled
  107376. */
  107377. setEnabledScaling(enable: boolean): void;
  107378. private _updateDummy;
  107379. /**
  107380. * Enables a pointer drag behavior on the bounding box of the gizmo
  107381. */
  107382. enableDragBehavior(): void;
  107383. /**
  107384. * Disposes of the gizmo
  107385. */
  107386. dispose(): void;
  107387. /**
  107388. * 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)
  107389. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  107390. * @returns the bounding box mesh with the passed in mesh as a child
  107391. */
  107392. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  107393. /**
  107394. * CustomMeshes are not supported by this gizmo
  107395. * @param mesh The mesh to replace the default mesh of the gizmo
  107396. */
  107397. setCustomMesh(mesh: Mesh): void;
  107398. }
  107399. }
  107400. declare module BABYLON {
  107401. /**
  107402. * Single plane rotation gizmo
  107403. */
  107404. export class PlaneRotationGizmo extends Gizmo {
  107405. /**
  107406. * Drag behavior responsible for the gizmos dragging interactions
  107407. */
  107408. dragBehavior: PointerDragBehavior;
  107409. private _pointerObserver;
  107410. /**
  107411. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  107412. */
  107413. snapDistance: number;
  107414. /**
  107415. * Event that fires each time the gizmo snaps to a new location.
  107416. * * snapDistance is the the change in distance
  107417. */
  107418. onSnapObservable: Observable<{
  107419. snapDistance: number;
  107420. }>;
  107421. private _isEnabled;
  107422. private _parent;
  107423. /**
  107424. * Creates a PlaneRotationGizmo
  107425. * @param gizmoLayer The utility layer the gizmo will be added to
  107426. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  107427. * @param color The color of the gizmo
  107428. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107429. */
  107430. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  107431. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107432. /**
  107433. * If the gizmo is enabled
  107434. */
  107435. isEnabled: boolean;
  107436. /**
  107437. * Disposes of the gizmo
  107438. */
  107439. dispose(): void;
  107440. }
  107441. }
  107442. declare module BABYLON {
  107443. /**
  107444. * Gizmo that enables rotating a mesh along 3 axis
  107445. */
  107446. export class RotationGizmo extends Gizmo {
  107447. /**
  107448. * Internal gizmo used for interactions on the x axis
  107449. */
  107450. xGizmo: PlaneRotationGizmo;
  107451. /**
  107452. * Internal gizmo used for interactions on the y axis
  107453. */
  107454. yGizmo: PlaneRotationGizmo;
  107455. /**
  107456. * Internal gizmo used for interactions on the z axis
  107457. */
  107458. zGizmo: PlaneRotationGizmo;
  107459. /** Fires an event when any of it's sub gizmos are dragged */
  107460. onDragStartObservable: Observable<unknown>;
  107461. /** Fires an event when any of it's sub gizmos are released from dragging */
  107462. onDragEndObservable: Observable<unknown>;
  107463. private _meshAttached;
  107464. attachedMesh: Nullable<AbstractMesh>;
  107465. /**
  107466. * Creates a RotationGizmo
  107467. * @param gizmoLayer The utility layer the gizmo will be added to
  107468. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107469. */
  107470. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  107471. updateGizmoRotationToMatchAttachedMesh: boolean;
  107472. /**
  107473. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107474. */
  107475. snapDistance: number;
  107476. /**
  107477. * Ratio for the scale of the gizmo (Default: 1)
  107478. */
  107479. scaleRatio: number;
  107480. /**
  107481. * Disposes of the gizmo
  107482. */
  107483. dispose(): void;
  107484. /**
  107485. * CustomMeshes are not supported by this gizmo
  107486. * @param mesh The mesh to replace the default mesh of the gizmo
  107487. */
  107488. setCustomMesh(mesh: Mesh): void;
  107489. }
  107490. }
  107491. declare module BABYLON {
  107492. /**
  107493. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  107494. */
  107495. export class GizmoManager implements IDisposable {
  107496. private scene;
  107497. /**
  107498. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  107499. */
  107500. gizmos: {
  107501. positionGizmo: Nullable<PositionGizmo>;
  107502. rotationGizmo: Nullable<RotationGizmo>;
  107503. scaleGizmo: Nullable<ScaleGizmo>;
  107504. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  107505. };
  107506. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  107507. clearGizmoOnEmptyPointerEvent: boolean;
  107508. /** Fires an event when the manager is attached to a mesh */
  107509. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  107510. private _gizmosEnabled;
  107511. private _pointerObserver;
  107512. private _attachedMesh;
  107513. private _boundingBoxColor;
  107514. private _defaultUtilityLayer;
  107515. private _defaultKeepDepthUtilityLayer;
  107516. /**
  107517. * When bounding box gizmo is enabled, this can be used to track drag/end events
  107518. */
  107519. boundingBoxDragBehavior: SixDofDragBehavior;
  107520. /**
  107521. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  107522. */
  107523. attachableMeshes: Nullable<Array<AbstractMesh>>;
  107524. /**
  107525. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  107526. */
  107527. usePointerToAttachGizmos: boolean;
  107528. /**
  107529. * Utility layer that the bounding box gizmo belongs to
  107530. */
  107531. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  107532. /**
  107533. * Utility layer that all gizmos besides bounding box belong to
  107534. */
  107535. readonly utilityLayer: UtilityLayerRenderer;
  107536. /**
  107537. * Instatiates a gizmo manager
  107538. * @param scene the scene to overlay the gizmos on top of
  107539. */
  107540. constructor(scene: Scene);
  107541. /**
  107542. * Attaches a set of gizmos to the specified mesh
  107543. * @param mesh The mesh the gizmo's should be attached to
  107544. */
  107545. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107546. /**
  107547. * If the position gizmo is enabled
  107548. */
  107549. positionGizmoEnabled: boolean;
  107550. /**
  107551. * If the rotation gizmo is enabled
  107552. */
  107553. rotationGizmoEnabled: boolean;
  107554. /**
  107555. * If the scale gizmo is enabled
  107556. */
  107557. scaleGizmoEnabled: boolean;
  107558. /**
  107559. * If the boundingBox gizmo is enabled
  107560. */
  107561. boundingBoxGizmoEnabled: boolean;
  107562. /**
  107563. * Disposes of the gizmo manager
  107564. */
  107565. dispose(): void;
  107566. }
  107567. }
  107568. declare module BABYLON {
  107569. /**
  107570. * A directional light is defined by a direction (what a surprise!).
  107571. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  107572. * 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.
  107573. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107574. */
  107575. export class DirectionalLight extends ShadowLight {
  107576. private _shadowFrustumSize;
  107577. /**
  107578. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  107579. */
  107580. /**
  107581. * Specifies a fix frustum size for the shadow generation.
  107582. */
  107583. shadowFrustumSize: number;
  107584. private _shadowOrthoScale;
  107585. /**
  107586. * Gets the shadow projection scale against the optimal computed one.
  107587. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107588. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107589. */
  107590. /**
  107591. * Sets the shadow projection scale against the optimal computed one.
  107592. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107593. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107594. */
  107595. shadowOrthoScale: number;
  107596. /**
  107597. * Automatically compute the projection matrix to best fit (including all the casters)
  107598. * on each frame.
  107599. */
  107600. autoUpdateExtends: boolean;
  107601. private _orthoLeft;
  107602. private _orthoRight;
  107603. private _orthoTop;
  107604. private _orthoBottom;
  107605. /**
  107606. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  107607. * The directional light is emitted from everywhere in the given direction.
  107608. * It can cast shadows.
  107609. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107610. * @param name The friendly name of the light
  107611. * @param direction The direction of the light
  107612. * @param scene The scene the light belongs to
  107613. */
  107614. constructor(name: string, direction: Vector3, scene: Scene);
  107615. /**
  107616. * Returns the string "DirectionalLight".
  107617. * @return The class name
  107618. */
  107619. getClassName(): string;
  107620. /**
  107621. * Returns the integer 1.
  107622. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107623. */
  107624. getTypeID(): number;
  107625. /**
  107626. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  107627. * Returns the DirectionalLight Shadow projection matrix.
  107628. */
  107629. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107630. /**
  107631. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  107632. * Returns the DirectionalLight Shadow projection matrix.
  107633. */
  107634. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  107635. /**
  107636. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  107637. * Returns the DirectionalLight Shadow projection matrix.
  107638. */
  107639. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107640. protected _buildUniformLayout(): void;
  107641. /**
  107642. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  107643. * @param effect The effect to update
  107644. * @param lightIndex The index of the light in the effect to update
  107645. * @returns The directional light
  107646. */
  107647. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  107648. /**
  107649. * Gets the minZ used for shadow according to both the scene and the light.
  107650. *
  107651. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107652. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107653. * @param activeCamera The camera we are returning the min for
  107654. * @returns the depth min z
  107655. */
  107656. getDepthMinZ(activeCamera: Camera): number;
  107657. /**
  107658. * Gets the maxZ used for shadow according to both the scene and the light.
  107659. *
  107660. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107661. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107662. * @param activeCamera The camera we are returning the max for
  107663. * @returns the depth max z
  107664. */
  107665. getDepthMaxZ(activeCamera: Camera): number;
  107666. /**
  107667. * Prepares the list of defines specific to the light type.
  107668. * @param defines the list of defines
  107669. * @param lightIndex defines the index of the light for the effect
  107670. */
  107671. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107672. }
  107673. }
  107674. declare module BABYLON {
  107675. /**
  107676. * Class containing static functions to help procedurally build meshes
  107677. */
  107678. export class HemisphereBuilder {
  107679. /**
  107680. * Creates a hemisphere mesh
  107681. * @param name defines the name of the mesh
  107682. * @param options defines the options used to create the mesh
  107683. * @param scene defines the hosting scene
  107684. * @returns the hemisphere mesh
  107685. */
  107686. static CreateHemisphere(name: string, options: {
  107687. segments?: number;
  107688. diameter?: number;
  107689. sideOrientation?: number;
  107690. }, scene: any): Mesh;
  107691. }
  107692. }
  107693. declare module BABYLON {
  107694. /**
  107695. * A spot light is defined by a position, a direction, an angle, and an exponent.
  107696. * These values define a cone of light starting from the position, emitting toward the direction.
  107697. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  107698. * and the exponent defines the speed of the decay of the light with distance (reach).
  107699. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107700. */
  107701. export class SpotLight extends ShadowLight {
  107702. private _angle;
  107703. private _innerAngle;
  107704. private _cosHalfAngle;
  107705. private _lightAngleScale;
  107706. private _lightAngleOffset;
  107707. /**
  107708. * Gets the cone angle of the spot light in Radians.
  107709. */
  107710. /**
  107711. * Sets the cone angle of the spot light in Radians.
  107712. */
  107713. angle: number;
  107714. /**
  107715. * Only used in gltf falloff mode, this defines the angle where
  107716. * the directional falloff will start before cutting at angle which could be seen
  107717. * as outer angle.
  107718. */
  107719. /**
  107720. * Only used in gltf falloff mode, this defines the angle where
  107721. * the directional falloff will start before cutting at angle which could be seen
  107722. * as outer angle.
  107723. */
  107724. innerAngle: number;
  107725. private _shadowAngleScale;
  107726. /**
  107727. * Allows scaling the angle of the light for shadow generation only.
  107728. */
  107729. /**
  107730. * Allows scaling the angle of the light for shadow generation only.
  107731. */
  107732. shadowAngleScale: number;
  107733. /**
  107734. * The light decay speed with the distance from the emission spot.
  107735. */
  107736. exponent: number;
  107737. private _projectionTextureMatrix;
  107738. /**
  107739. * Allows reading the projecton texture
  107740. */
  107741. readonly projectionTextureMatrix: Matrix;
  107742. protected _projectionTextureLightNear: number;
  107743. /**
  107744. * Gets the near clip of the Spotlight for texture projection.
  107745. */
  107746. /**
  107747. * Sets the near clip of the Spotlight for texture projection.
  107748. */
  107749. projectionTextureLightNear: number;
  107750. protected _projectionTextureLightFar: number;
  107751. /**
  107752. * Gets the far clip of the Spotlight for texture projection.
  107753. */
  107754. /**
  107755. * Sets the far clip of the Spotlight for texture projection.
  107756. */
  107757. projectionTextureLightFar: number;
  107758. protected _projectionTextureUpDirection: Vector3;
  107759. /**
  107760. * Gets the Up vector of the Spotlight for texture projection.
  107761. */
  107762. /**
  107763. * Sets the Up vector of the Spotlight for texture projection.
  107764. */
  107765. projectionTextureUpDirection: Vector3;
  107766. private _projectionTexture;
  107767. /**
  107768. * Gets the projection texture of the light.
  107769. */
  107770. /**
  107771. * Sets the projection texture of the light.
  107772. */
  107773. projectionTexture: Nullable<BaseTexture>;
  107774. private _projectionTextureViewLightDirty;
  107775. private _projectionTextureProjectionLightDirty;
  107776. private _projectionTextureDirty;
  107777. private _projectionTextureViewTargetVector;
  107778. private _projectionTextureViewLightMatrix;
  107779. private _projectionTextureProjectionLightMatrix;
  107780. private _projectionTextureScalingMatrix;
  107781. /**
  107782. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  107783. * It can cast shadows.
  107784. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107785. * @param name The light friendly name
  107786. * @param position The position of the spot light in the scene
  107787. * @param direction The direction of the light in the scene
  107788. * @param angle The cone angle of the light in Radians
  107789. * @param exponent The light decay speed with the distance from the emission spot
  107790. * @param scene The scene the lights belongs to
  107791. */
  107792. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  107793. /**
  107794. * Returns the string "SpotLight".
  107795. * @returns the class name
  107796. */
  107797. getClassName(): string;
  107798. /**
  107799. * Returns the integer 2.
  107800. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107801. */
  107802. getTypeID(): number;
  107803. /**
  107804. * Overrides the direction setter to recompute the projection texture view light Matrix.
  107805. */
  107806. protected _setDirection(value: Vector3): void;
  107807. /**
  107808. * Overrides the position setter to recompute the projection texture view light Matrix.
  107809. */
  107810. protected _setPosition(value: Vector3): void;
  107811. /**
  107812. * 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.
  107813. * Returns the SpotLight.
  107814. */
  107815. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107816. protected _computeProjectionTextureViewLightMatrix(): void;
  107817. protected _computeProjectionTextureProjectionLightMatrix(): void;
  107818. /**
  107819. * Main function for light texture projection matrix computing.
  107820. */
  107821. protected _computeProjectionTextureMatrix(): void;
  107822. protected _buildUniformLayout(): void;
  107823. private _computeAngleValues;
  107824. /**
  107825. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  107826. * @param effect The effect to update
  107827. * @param lightIndex The index of the light in the effect to update
  107828. * @returns The spot light
  107829. */
  107830. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  107831. /**
  107832. * Disposes the light and the associated resources.
  107833. */
  107834. dispose(): void;
  107835. /**
  107836. * Prepares the list of defines specific to the light type.
  107837. * @param defines the list of defines
  107838. * @param lightIndex defines the index of the light for the effect
  107839. */
  107840. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107841. }
  107842. }
  107843. declare module BABYLON {
  107844. /**
  107845. * Gizmo that enables viewing a light
  107846. */
  107847. export class LightGizmo extends Gizmo {
  107848. private _lightMesh;
  107849. private _material;
  107850. private cachedPosition;
  107851. private cachedForward;
  107852. /**
  107853. * Creates a LightGizmo
  107854. * @param gizmoLayer The utility layer the gizmo will be added to
  107855. */
  107856. constructor(gizmoLayer?: UtilityLayerRenderer);
  107857. private _light;
  107858. /**
  107859. * The light that the gizmo is attached to
  107860. */
  107861. light: Nullable<Light>;
  107862. /**
  107863. * @hidden
  107864. * Updates the gizmo to match the attached mesh's position/rotation
  107865. */
  107866. protected _update(): void;
  107867. private static _Scale;
  107868. /**
  107869. * Creates the lines for a light mesh
  107870. */
  107871. private static _createLightLines;
  107872. /**
  107873. * Disposes of the light gizmo
  107874. */
  107875. dispose(): void;
  107876. private static _CreateHemisphericLightMesh;
  107877. private static _CreatePointLightMesh;
  107878. private static _CreateSpotLightMesh;
  107879. private static _CreateDirectionalLightMesh;
  107880. }
  107881. }
  107882. declare module BABYLON {
  107883. /** @hidden */
  107884. export var backgroundFragmentDeclaration: {
  107885. name: string;
  107886. shader: string;
  107887. };
  107888. }
  107889. declare module BABYLON {
  107890. /** @hidden */
  107891. export var backgroundUboDeclaration: {
  107892. name: string;
  107893. shader: string;
  107894. };
  107895. }
  107896. declare module BABYLON {
  107897. /** @hidden */
  107898. export var backgroundPixelShader: {
  107899. name: string;
  107900. shader: string;
  107901. };
  107902. }
  107903. declare module BABYLON {
  107904. /** @hidden */
  107905. export var backgroundVertexDeclaration: {
  107906. name: string;
  107907. shader: string;
  107908. };
  107909. }
  107910. declare module BABYLON {
  107911. /** @hidden */
  107912. export var backgroundVertexShader: {
  107913. name: string;
  107914. shader: string;
  107915. };
  107916. }
  107917. declare module BABYLON {
  107918. /**
  107919. * Background material used to create an efficient environement around your scene.
  107920. */
  107921. export class BackgroundMaterial extends PushMaterial {
  107922. /**
  107923. * Standard reflectance value at parallel view angle.
  107924. */
  107925. static StandardReflectance0: number;
  107926. /**
  107927. * Standard reflectance value at grazing angle.
  107928. */
  107929. static StandardReflectance90: number;
  107930. protected _primaryColor: Color3;
  107931. /**
  107932. * Key light Color (multiply against the environement texture)
  107933. */
  107934. primaryColor: Color3;
  107935. protected __perceptualColor: Nullable<Color3>;
  107936. /**
  107937. * Experimental Internal Use Only.
  107938. *
  107939. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  107940. * This acts as a helper to set the primary color to a more "human friendly" value.
  107941. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  107942. * output color as close as possible from the chosen value.
  107943. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  107944. * part of lighting setup.)
  107945. */
  107946. _perceptualColor: Nullable<Color3>;
  107947. protected _primaryColorShadowLevel: float;
  107948. /**
  107949. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  107950. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  107951. */
  107952. primaryColorShadowLevel: float;
  107953. protected _primaryColorHighlightLevel: float;
  107954. /**
  107955. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  107956. * The primary color is used at the level chosen to define what the white area would look.
  107957. */
  107958. primaryColorHighlightLevel: float;
  107959. protected _reflectionTexture: Nullable<BaseTexture>;
  107960. /**
  107961. * Reflection Texture used in the material.
  107962. * Should be author in a specific way for the best result (refer to the documentation).
  107963. */
  107964. reflectionTexture: Nullable<BaseTexture>;
  107965. protected _reflectionBlur: float;
  107966. /**
  107967. * Reflection Texture level of blur.
  107968. *
  107969. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  107970. * texture twice.
  107971. */
  107972. reflectionBlur: float;
  107973. protected _diffuseTexture: Nullable<BaseTexture>;
  107974. /**
  107975. * Diffuse Texture used in the material.
  107976. * Should be author in a specific way for the best result (refer to the documentation).
  107977. */
  107978. diffuseTexture: Nullable<BaseTexture>;
  107979. protected _shadowLights: Nullable<IShadowLight[]>;
  107980. /**
  107981. * Specify the list of lights casting shadow on the material.
  107982. * All scene shadow lights will be included if null.
  107983. */
  107984. shadowLights: Nullable<IShadowLight[]>;
  107985. protected _shadowLevel: float;
  107986. /**
  107987. * Helps adjusting the shadow to a softer level if required.
  107988. * 0 means black shadows and 1 means no shadows.
  107989. */
  107990. shadowLevel: float;
  107991. protected _sceneCenter: Vector3;
  107992. /**
  107993. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  107994. * It is usually zero but might be interesting to modify according to your setup.
  107995. */
  107996. sceneCenter: Vector3;
  107997. protected _opacityFresnel: boolean;
  107998. /**
  107999. * This helps specifying that the material is falling off to the sky box at grazing angle.
  108000. * This helps ensuring a nice transition when the camera goes under the ground.
  108001. */
  108002. opacityFresnel: boolean;
  108003. protected _reflectionFresnel: boolean;
  108004. /**
  108005. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  108006. * This helps adding a mirror texture on the ground.
  108007. */
  108008. reflectionFresnel: boolean;
  108009. protected _reflectionFalloffDistance: number;
  108010. /**
  108011. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  108012. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  108013. */
  108014. reflectionFalloffDistance: number;
  108015. protected _reflectionAmount: number;
  108016. /**
  108017. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  108018. */
  108019. reflectionAmount: number;
  108020. protected _reflectionReflectance0: number;
  108021. /**
  108022. * This specifies the weight of the reflection at grazing angle.
  108023. */
  108024. reflectionReflectance0: number;
  108025. protected _reflectionReflectance90: number;
  108026. /**
  108027. * This specifies the weight of the reflection at a perpendicular point of view.
  108028. */
  108029. reflectionReflectance90: number;
  108030. /**
  108031. * Sets the reflection reflectance fresnel values according to the default standard
  108032. * empirically know to work well :-)
  108033. */
  108034. reflectionStandardFresnelWeight: number;
  108035. protected _useRGBColor: boolean;
  108036. /**
  108037. * Helps to directly use the maps channels instead of their level.
  108038. */
  108039. useRGBColor: boolean;
  108040. protected _enableNoise: boolean;
  108041. /**
  108042. * This helps reducing the banding effect that could occur on the background.
  108043. */
  108044. enableNoise: boolean;
  108045. /**
  108046. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108047. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  108048. * Recommended to be keep at 1.0 except for special cases.
  108049. */
  108050. fovMultiplier: number;
  108051. private _fovMultiplier;
  108052. /**
  108053. * Enable the FOV adjustment feature controlled by fovMultiplier.
  108054. */
  108055. useEquirectangularFOV: boolean;
  108056. private _maxSimultaneousLights;
  108057. /**
  108058. * Number of Simultaneous lights allowed on the material.
  108059. */
  108060. maxSimultaneousLights: int;
  108061. /**
  108062. * Default configuration related to image processing available in the Background Material.
  108063. */
  108064. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108065. /**
  108066. * Keep track of the image processing observer to allow dispose and replace.
  108067. */
  108068. private _imageProcessingObserver;
  108069. /**
  108070. * Attaches a new image processing configuration to the PBR Material.
  108071. * @param configuration (if null the scene configuration will be use)
  108072. */
  108073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108074. /**
  108075. * Gets the image processing configuration used either in this material.
  108076. */
  108077. /**
  108078. * Sets the Default image processing configuration used either in the this material.
  108079. *
  108080. * If sets to null, the scene one is in use.
  108081. */
  108082. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  108083. /**
  108084. * Gets wether the color curves effect is enabled.
  108085. */
  108086. /**
  108087. * Sets wether the color curves effect is enabled.
  108088. */
  108089. cameraColorCurvesEnabled: boolean;
  108090. /**
  108091. * Gets wether the color grading effect is enabled.
  108092. */
  108093. /**
  108094. * Gets wether the color grading effect is enabled.
  108095. */
  108096. cameraColorGradingEnabled: boolean;
  108097. /**
  108098. * Gets wether tonemapping is enabled or not.
  108099. */
  108100. /**
  108101. * Sets wether tonemapping is enabled or not
  108102. */
  108103. cameraToneMappingEnabled: boolean;
  108104. /**
  108105. * The camera exposure used on this material.
  108106. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108107. * This corresponds to a photographic exposure.
  108108. */
  108109. /**
  108110. * The camera exposure used on this material.
  108111. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108112. * This corresponds to a photographic exposure.
  108113. */
  108114. cameraExposure: float;
  108115. /**
  108116. * Gets The camera contrast used on this material.
  108117. */
  108118. /**
  108119. * Sets The camera contrast used on this material.
  108120. */
  108121. cameraContrast: float;
  108122. /**
  108123. * Gets the Color Grading 2D Lookup Texture.
  108124. */
  108125. /**
  108126. * Sets the Color Grading 2D Lookup Texture.
  108127. */
  108128. cameraColorGradingTexture: Nullable<BaseTexture>;
  108129. /**
  108130. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108131. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108132. * 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;
  108133. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108134. */
  108135. /**
  108136. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108137. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108138. * 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;
  108139. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108140. */
  108141. cameraColorCurves: Nullable<ColorCurves>;
  108142. /**
  108143. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  108144. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  108145. */
  108146. switchToBGR: boolean;
  108147. private _renderTargets;
  108148. private _reflectionControls;
  108149. private _white;
  108150. private _primaryShadowColor;
  108151. private _primaryHighlightColor;
  108152. /**
  108153. * Instantiates a Background Material in the given scene
  108154. * @param name The friendly name of the material
  108155. * @param scene The scene to add the material to
  108156. */
  108157. constructor(name: string, scene: Scene);
  108158. /**
  108159. * Gets a boolean indicating that current material needs to register RTT
  108160. */
  108161. readonly hasRenderTargetTextures: boolean;
  108162. /**
  108163. * The entire material has been created in order to prevent overdraw.
  108164. * @returns false
  108165. */
  108166. needAlphaTesting(): boolean;
  108167. /**
  108168. * The entire material has been created in order to prevent overdraw.
  108169. * @returns true if blending is enable
  108170. */
  108171. needAlphaBlending(): boolean;
  108172. /**
  108173. * Checks wether the material is ready to be rendered for a given mesh.
  108174. * @param mesh The mesh to render
  108175. * @param subMesh The submesh to check against
  108176. * @param useInstances Specify wether or not the material is used with instances
  108177. * @returns true if all the dependencies are ready (Textures, Effects...)
  108178. */
  108179. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108180. /**
  108181. * Compute the primary color according to the chosen perceptual color.
  108182. */
  108183. private _computePrimaryColorFromPerceptualColor;
  108184. /**
  108185. * Compute the highlights and shadow colors according to their chosen levels.
  108186. */
  108187. private _computePrimaryColors;
  108188. /**
  108189. * Build the uniform buffer used in the material.
  108190. */
  108191. buildUniformLayout(): void;
  108192. /**
  108193. * Unbind the material.
  108194. */
  108195. unbind(): void;
  108196. /**
  108197. * Bind only the world matrix to the material.
  108198. * @param world The world matrix to bind.
  108199. */
  108200. bindOnlyWorldMatrix(world: Matrix): void;
  108201. /**
  108202. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  108203. * @param world The world matrix to bind.
  108204. * @param subMesh The submesh to bind for.
  108205. */
  108206. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108207. /**
  108208. * Dispose the material.
  108209. * @param forceDisposeEffect Force disposal of the associated effect.
  108210. * @param forceDisposeTextures Force disposal of the associated textures.
  108211. */
  108212. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108213. /**
  108214. * Clones the material.
  108215. * @param name The cloned name.
  108216. * @returns The cloned material.
  108217. */
  108218. clone(name: string): BackgroundMaterial;
  108219. /**
  108220. * Serializes the current material to its JSON representation.
  108221. * @returns The JSON representation.
  108222. */
  108223. serialize(): any;
  108224. /**
  108225. * Gets the class name of the material
  108226. * @returns "BackgroundMaterial"
  108227. */
  108228. getClassName(): string;
  108229. /**
  108230. * Parse a JSON input to create back a background material.
  108231. * @param source The JSON data to parse
  108232. * @param scene The scene to create the parsed material in
  108233. * @param rootUrl The root url of the assets the material depends upon
  108234. * @returns the instantiated BackgroundMaterial.
  108235. */
  108236. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  108237. }
  108238. }
  108239. declare module BABYLON {
  108240. /**
  108241. * Represents the different options available during the creation of
  108242. * a Environment helper.
  108243. *
  108244. * This can control the default ground, skybox and image processing setup of your scene.
  108245. */
  108246. export interface IEnvironmentHelperOptions {
  108247. /**
  108248. * Specifies wether or not to create a ground.
  108249. * True by default.
  108250. */
  108251. createGround: boolean;
  108252. /**
  108253. * Specifies the ground size.
  108254. * 15 by default.
  108255. */
  108256. groundSize: number;
  108257. /**
  108258. * The texture used on the ground for the main color.
  108259. * Comes from the BabylonJS CDN by default.
  108260. *
  108261. * Remarks: Can be either a texture or a url.
  108262. */
  108263. groundTexture: string | BaseTexture;
  108264. /**
  108265. * The color mixed in the ground texture by default.
  108266. * BabylonJS clearColor by default.
  108267. */
  108268. groundColor: Color3;
  108269. /**
  108270. * Specifies the ground opacity.
  108271. * 1 by default.
  108272. */
  108273. groundOpacity: number;
  108274. /**
  108275. * Enables the ground to receive shadows.
  108276. * True by default.
  108277. */
  108278. enableGroundShadow: boolean;
  108279. /**
  108280. * Helps preventing the shadow to be fully black on the ground.
  108281. * 0.5 by default.
  108282. */
  108283. groundShadowLevel: number;
  108284. /**
  108285. * Creates a mirror texture attach to the ground.
  108286. * false by default.
  108287. */
  108288. enableGroundMirror: boolean;
  108289. /**
  108290. * Specifies the ground mirror size ratio.
  108291. * 0.3 by default as the default kernel is 64.
  108292. */
  108293. groundMirrorSizeRatio: number;
  108294. /**
  108295. * Specifies the ground mirror blur kernel size.
  108296. * 64 by default.
  108297. */
  108298. groundMirrorBlurKernel: number;
  108299. /**
  108300. * Specifies the ground mirror visibility amount.
  108301. * 1 by default
  108302. */
  108303. groundMirrorAmount: number;
  108304. /**
  108305. * Specifies the ground mirror reflectance weight.
  108306. * This uses the standard weight of the background material to setup the fresnel effect
  108307. * of the mirror.
  108308. * 1 by default.
  108309. */
  108310. groundMirrorFresnelWeight: number;
  108311. /**
  108312. * Specifies the ground mirror Falloff distance.
  108313. * This can helps reducing the size of the reflection.
  108314. * 0 by Default.
  108315. */
  108316. groundMirrorFallOffDistance: number;
  108317. /**
  108318. * Specifies the ground mirror texture type.
  108319. * Unsigned Int by Default.
  108320. */
  108321. groundMirrorTextureType: number;
  108322. /**
  108323. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  108324. * the shown objects.
  108325. */
  108326. groundYBias: number;
  108327. /**
  108328. * Specifies wether or not to create a skybox.
  108329. * True by default.
  108330. */
  108331. createSkybox: boolean;
  108332. /**
  108333. * Specifies the skybox size.
  108334. * 20 by default.
  108335. */
  108336. skyboxSize: number;
  108337. /**
  108338. * The texture used on the skybox for the main color.
  108339. * Comes from the BabylonJS CDN by default.
  108340. *
  108341. * Remarks: Can be either a texture or a url.
  108342. */
  108343. skyboxTexture: string | BaseTexture;
  108344. /**
  108345. * The color mixed in the skybox texture by default.
  108346. * BabylonJS clearColor by default.
  108347. */
  108348. skyboxColor: Color3;
  108349. /**
  108350. * The background rotation around the Y axis of the scene.
  108351. * This helps aligning the key lights of your scene with the background.
  108352. * 0 by default.
  108353. */
  108354. backgroundYRotation: number;
  108355. /**
  108356. * Compute automatically the size of the elements to best fit with the scene.
  108357. */
  108358. sizeAuto: boolean;
  108359. /**
  108360. * Default position of the rootMesh if autoSize is not true.
  108361. */
  108362. rootPosition: Vector3;
  108363. /**
  108364. * Sets up the image processing in the scene.
  108365. * true by default.
  108366. */
  108367. setupImageProcessing: boolean;
  108368. /**
  108369. * The texture used as your environment texture in the scene.
  108370. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  108371. *
  108372. * Remarks: Can be either a texture or a url.
  108373. */
  108374. environmentTexture: string | BaseTexture;
  108375. /**
  108376. * The value of the exposure to apply to the scene.
  108377. * 0.6 by default if setupImageProcessing is true.
  108378. */
  108379. cameraExposure: number;
  108380. /**
  108381. * The value of the contrast to apply to the scene.
  108382. * 1.6 by default if setupImageProcessing is true.
  108383. */
  108384. cameraContrast: number;
  108385. /**
  108386. * Specifies wether or not tonemapping should be enabled in the scene.
  108387. * true by default if setupImageProcessing is true.
  108388. */
  108389. toneMappingEnabled: boolean;
  108390. }
  108391. /**
  108392. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  108393. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  108394. * It also helps with the default setup of your imageProcessing configuration.
  108395. */
  108396. export class EnvironmentHelper {
  108397. /**
  108398. * Default ground texture URL.
  108399. */
  108400. private static _groundTextureCDNUrl;
  108401. /**
  108402. * Default skybox texture URL.
  108403. */
  108404. private static _skyboxTextureCDNUrl;
  108405. /**
  108406. * Default environment texture URL.
  108407. */
  108408. private static _environmentTextureCDNUrl;
  108409. /**
  108410. * Creates the default options for the helper.
  108411. */
  108412. private static _getDefaultOptions;
  108413. private _rootMesh;
  108414. /**
  108415. * Gets the root mesh created by the helper.
  108416. */
  108417. readonly rootMesh: Mesh;
  108418. private _skybox;
  108419. /**
  108420. * Gets the skybox created by the helper.
  108421. */
  108422. readonly skybox: Nullable<Mesh>;
  108423. private _skyboxTexture;
  108424. /**
  108425. * Gets the skybox texture created by the helper.
  108426. */
  108427. readonly skyboxTexture: Nullable<BaseTexture>;
  108428. private _skyboxMaterial;
  108429. /**
  108430. * Gets the skybox material created by the helper.
  108431. */
  108432. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  108433. private _ground;
  108434. /**
  108435. * Gets the ground mesh created by the helper.
  108436. */
  108437. readonly ground: Nullable<Mesh>;
  108438. private _groundTexture;
  108439. /**
  108440. * Gets the ground texture created by the helper.
  108441. */
  108442. readonly groundTexture: Nullable<BaseTexture>;
  108443. private _groundMirror;
  108444. /**
  108445. * Gets the ground mirror created by the helper.
  108446. */
  108447. readonly groundMirror: Nullable<MirrorTexture>;
  108448. /**
  108449. * Gets the ground mirror render list to helps pushing the meshes
  108450. * you wish in the ground reflection.
  108451. */
  108452. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  108453. private _groundMaterial;
  108454. /**
  108455. * Gets the ground material created by the helper.
  108456. */
  108457. readonly groundMaterial: Nullable<BackgroundMaterial>;
  108458. /**
  108459. * Stores the creation options.
  108460. */
  108461. private readonly _scene;
  108462. private _options;
  108463. /**
  108464. * This observable will be notified with any error during the creation of the environment,
  108465. * mainly texture creation errors.
  108466. */
  108467. onErrorObservable: Observable<{
  108468. message?: string;
  108469. exception?: any;
  108470. }>;
  108471. /**
  108472. * constructor
  108473. * @param options Defines the options we want to customize the helper
  108474. * @param scene The scene to add the material to
  108475. */
  108476. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  108477. /**
  108478. * Updates the background according to the new options
  108479. * @param options
  108480. */
  108481. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  108482. /**
  108483. * Sets the primary color of all the available elements.
  108484. * @param color the main color to affect to the ground and the background
  108485. */
  108486. setMainColor(color: Color3): void;
  108487. /**
  108488. * Setup the image processing according to the specified options.
  108489. */
  108490. private _setupImageProcessing;
  108491. /**
  108492. * Setup the environment texture according to the specified options.
  108493. */
  108494. private _setupEnvironmentTexture;
  108495. /**
  108496. * Setup the background according to the specified options.
  108497. */
  108498. private _setupBackground;
  108499. /**
  108500. * Get the scene sizes according to the setup.
  108501. */
  108502. private _getSceneSize;
  108503. /**
  108504. * Setup the ground according to the specified options.
  108505. */
  108506. private _setupGround;
  108507. /**
  108508. * Setup the ground material according to the specified options.
  108509. */
  108510. private _setupGroundMaterial;
  108511. /**
  108512. * Setup the ground diffuse texture according to the specified options.
  108513. */
  108514. private _setupGroundDiffuseTexture;
  108515. /**
  108516. * Setup the ground mirror texture according to the specified options.
  108517. */
  108518. private _setupGroundMirrorTexture;
  108519. /**
  108520. * Setup the ground to receive the mirror texture.
  108521. */
  108522. private _setupMirrorInGroundMaterial;
  108523. /**
  108524. * Setup the skybox according to the specified options.
  108525. */
  108526. private _setupSkybox;
  108527. /**
  108528. * Setup the skybox material according to the specified options.
  108529. */
  108530. private _setupSkyboxMaterial;
  108531. /**
  108532. * Setup the skybox reflection texture according to the specified options.
  108533. */
  108534. private _setupSkyboxReflectionTexture;
  108535. private _errorHandler;
  108536. /**
  108537. * Dispose all the elements created by the Helper.
  108538. */
  108539. dispose(): void;
  108540. }
  108541. }
  108542. declare module BABYLON {
  108543. /**
  108544. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  108545. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  108546. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  108547. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  108548. */
  108549. export class PhotoDome extends TransformNode {
  108550. /**
  108551. * Define the image as a Monoscopic panoramic 360 image.
  108552. */
  108553. static readonly MODE_MONOSCOPIC: number;
  108554. /**
  108555. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108556. */
  108557. static readonly MODE_TOPBOTTOM: number;
  108558. /**
  108559. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108560. */
  108561. static readonly MODE_SIDEBYSIDE: number;
  108562. private _useDirectMapping;
  108563. /**
  108564. * The texture being displayed on the sphere
  108565. */
  108566. protected _photoTexture: Texture;
  108567. /**
  108568. * Gets or sets the texture being displayed on the sphere
  108569. */
  108570. photoTexture: Texture;
  108571. /**
  108572. * Observable raised when an error occured while loading the 360 image
  108573. */
  108574. onLoadErrorObservable: Observable<string>;
  108575. /**
  108576. * The skybox material
  108577. */
  108578. protected _material: BackgroundMaterial;
  108579. /**
  108580. * The surface used for the skybox
  108581. */
  108582. protected _mesh: Mesh;
  108583. /**
  108584. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108585. * Also see the options.resolution property.
  108586. */
  108587. fovMultiplier: number;
  108588. private _imageMode;
  108589. /**
  108590. * Gets or set the current video mode for the video. It can be:
  108591. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  108592. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108593. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108594. */
  108595. imageMode: number;
  108596. /**
  108597. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  108598. * @param name Element's name, child elements will append suffixes for their own names.
  108599. * @param urlsOfPhoto defines the url of the photo to display
  108600. * @param options defines an object containing optional or exposed sub element properties
  108601. * @param onError defines a callback called when an error occured while loading the texture
  108602. */
  108603. constructor(name: string, urlOfPhoto: string, options: {
  108604. resolution?: number;
  108605. size?: number;
  108606. useDirectMapping?: boolean;
  108607. faceForward?: boolean;
  108608. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  108609. private _onBeforeCameraRenderObserver;
  108610. private _changeImageMode;
  108611. /**
  108612. * Releases resources associated with this node.
  108613. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108614. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108615. */
  108616. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108617. }
  108618. }
  108619. declare module BABYLON {
  108620. /** @hidden */
  108621. export var rgbdDecodePixelShader: {
  108622. name: string;
  108623. shader: string;
  108624. };
  108625. }
  108626. declare module BABYLON {
  108627. /**
  108628. * Class used to host texture specific utilities
  108629. */
  108630. export class BRDFTextureTools {
  108631. /**
  108632. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  108633. * @param texture the texture to expand.
  108634. */
  108635. private static _ExpandDefaultBRDFTexture;
  108636. /**
  108637. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  108638. * @param scene defines the hosting scene
  108639. * @returns the environment BRDF texture
  108640. */
  108641. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  108642. private static _environmentBRDFBase64Texture;
  108643. }
  108644. }
  108645. declare module BABYLON {
  108646. /**
  108647. * @hidden
  108648. */
  108649. export interface IMaterialClearCoatDefines {
  108650. CLEARCOAT: boolean;
  108651. CLEARCOAT_DEFAULTIOR: boolean;
  108652. CLEARCOAT_TEXTURE: boolean;
  108653. CLEARCOAT_TEXTUREDIRECTUV: number;
  108654. CLEARCOAT_BUMP: boolean;
  108655. CLEARCOAT_BUMPDIRECTUV: number;
  108656. CLEARCOAT_TINT: boolean;
  108657. CLEARCOAT_TINT_TEXTURE: boolean;
  108658. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108659. /** @hidden */
  108660. _areTexturesDirty: boolean;
  108661. }
  108662. /**
  108663. * Define the code related to the clear coat parameters of the pbr material.
  108664. */
  108665. export class PBRClearCoatConfiguration {
  108666. /**
  108667. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  108668. * The default fits with a polyurethane material.
  108669. */
  108670. private static readonly _DefaultIndexOfRefraction;
  108671. private _isEnabled;
  108672. /**
  108673. * Defines if the clear coat is enabled in the material.
  108674. */
  108675. isEnabled: boolean;
  108676. /**
  108677. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  108678. */
  108679. intensity: number;
  108680. /**
  108681. * Defines the clear coat layer roughness.
  108682. */
  108683. roughness: number;
  108684. private _indexOfRefraction;
  108685. /**
  108686. * Defines the index of refraction of the clear coat.
  108687. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  108688. * The default fits with a polyurethane material.
  108689. * Changing the default value is more performance intensive.
  108690. */
  108691. indexOfRefraction: number;
  108692. private _texture;
  108693. /**
  108694. * Stores the clear coat values in a texture.
  108695. */
  108696. texture: Nullable<BaseTexture>;
  108697. private _bumpTexture;
  108698. /**
  108699. * Define the clear coat specific bump texture.
  108700. */
  108701. bumpTexture: Nullable<BaseTexture>;
  108702. private _isTintEnabled;
  108703. /**
  108704. * Defines if the clear coat tint is enabled in the material.
  108705. */
  108706. isTintEnabled: boolean;
  108707. /**
  108708. * Defines the clear coat tint of the material.
  108709. * This is only use if tint is enabled
  108710. */
  108711. tintColor: Color3;
  108712. /**
  108713. * Defines the distance at which the tint color should be found in the
  108714. * clear coat media.
  108715. * This is only use if tint is enabled
  108716. */
  108717. tintColorAtDistance: number;
  108718. /**
  108719. * Defines the clear coat layer thickness.
  108720. * This is only use if tint is enabled
  108721. */
  108722. tintThickness: number;
  108723. private _tintTexture;
  108724. /**
  108725. * Stores the clear tint values in a texture.
  108726. * rgb is tint
  108727. * a is a thickness factor
  108728. */
  108729. tintTexture: Nullable<BaseTexture>;
  108730. /** @hidden */
  108731. private _internalMarkAllSubMeshesAsTexturesDirty;
  108732. /** @hidden */
  108733. _markAllSubMeshesAsTexturesDirty(): void;
  108734. /**
  108735. * Instantiate a new istance of clear coat configuration.
  108736. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108737. */
  108738. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108739. /**
  108740. * Gets wehter the submesh is ready to be used or not.
  108741. * @param defines the list of "defines" to update.
  108742. * @param scene defines the scene the material belongs to.
  108743. * @param engine defines the engine the material belongs to.
  108744. * @param disableBumpMap defines wether the material disables bump or not.
  108745. * @returns - boolean indicating that the submesh is ready or not.
  108746. */
  108747. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  108748. /**
  108749. * Checks to see if a texture is used in the material.
  108750. * @param defines the list of "defines" to update.
  108751. * @param scene defines the scene to the material belongs to.
  108752. */
  108753. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  108754. /**
  108755. * Binds the material data.
  108756. * @param uniformBuffer defines the Uniform buffer to fill in.
  108757. * @param scene defines the scene the material belongs to.
  108758. * @param engine defines the engine the material belongs to.
  108759. * @param disableBumpMap defines wether the material disables bump or not.
  108760. * @param isFrozen defines wether the material is frozen or not.
  108761. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108762. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108763. */
  108764. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  108765. /**
  108766. * Checks to see if a texture is used in the material.
  108767. * @param texture - Base texture to use.
  108768. * @returns - Boolean specifying if a texture is used in the material.
  108769. */
  108770. hasTexture(texture: BaseTexture): boolean;
  108771. /**
  108772. * Returns an array of the actively used textures.
  108773. * @param activeTextures Array of BaseTextures
  108774. */
  108775. getActiveTextures(activeTextures: BaseTexture[]): void;
  108776. /**
  108777. * Returns the animatable textures.
  108778. * @param animatables Array of animatable textures.
  108779. */
  108780. getAnimatables(animatables: IAnimatable[]): void;
  108781. /**
  108782. * Disposes the resources of the material.
  108783. * @param forceDisposeTextures - Forces the disposal of all textures.
  108784. */
  108785. dispose(forceDisposeTextures?: boolean): void;
  108786. /**
  108787. * Get the current class name of the texture useful for serialization or dynamic coding.
  108788. * @returns "PBRClearCoatConfiguration"
  108789. */
  108790. getClassName(): string;
  108791. /**
  108792. * Add fallbacks to the effect fallbacks list.
  108793. * @param defines defines the Base texture to use.
  108794. * @param fallbacks defines the current fallback list.
  108795. * @param currentRank defines the current fallback rank.
  108796. * @returns the new fallback rank.
  108797. */
  108798. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108799. /**
  108800. * Add the required uniforms to the current list.
  108801. * @param uniforms defines the current uniform list.
  108802. */
  108803. static AddUniforms(uniforms: string[]): void;
  108804. /**
  108805. * Add the required samplers to the current list.
  108806. * @param samplers defines the current sampler list.
  108807. */
  108808. static AddSamplers(samplers: string[]): void;
  108809. /**
  108810. * Add the required uniforms to the current buffer.
  108811. * @param uniformBuffer defines the current uniform buffer.
  108812. */
  108813. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108814. /**
  108815. * Makes a duplicate of the current configuration into another one.
  108816. * @param clearCoatConfiguration define the config where to copy the info
  108817. */
  108818. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  108819. /**
  108820. * Serializes this clear coat configuration.
  108821. * @returns - An object with the serialized config.
  108822. */
  108823. serialize(): any;
  108824. /**
  108825. * Parses a anisotropy Configuration from a serialized object.
  108826. * @param source - Serialized object.
  108827. * @param scene Defines the scene we are parsing for
  108828. * @param rootUrl Defines the rootUrl to load from
  108829. */
  108830. parse(source: any, scene: Scene, rootUrl: string): void;
  108831. }
  108832. }
  108833. declare module BABYLON {
  108834. /**
  108835. * @hidden
  108836. */
  108837. export interface IMaterialAnisotropicDefines {
  108838. ANISOTROPIC: boolean;
  108839. ANISOTROPIC_TEXTURE: boolean;
  108840. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108841. MAINUV1: boolean;
  108842. _areTexturesDirty: boolean;
  108843. _needUVs: boolean;
  108844. }
  108845. /**
  108846. * Define the code related to the anisotropic parameters of the pbr material.
  108847. */
  108848. export class PBRAnisotropicConfiguration {
  108849. private _isEnabled;
  108850. /**
  108851. * Defines if the anisotropy is enabled in the material.
  108852. */
  108853. isEnabled: boolean;
  108854. /**
  108855. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  108856. */
  108857. intensity: number;
  108858. /**
  108859. * Defines if the effect is along the tangents, bitangents or in between.
  108860. * By default, the effect is "strectching" the highlights along the tangents.
  108861. */
  108862. direction: Vector2;
  108863. private _texture;
  108864. /**
  108865. * Stores the anisotropy values in a texture.
  108866. * rg is direction (like normal from -1 to 1)
  108867. * b is a intensity
  108868. */
  108869. texture: Nullable<BaseTexture>;
  108870. /** @hidden */
  108871. private _internalMarkAllSubMeshesAsTexturesDirty;
  108872. /** @hidden */
  108873. _markAllSubMeshesAsTexturesDirty(): void;
  108874. /**
  108875. * Instantiate a new istance of anisotropy configuration.
  108876. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108877. */
  108878. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108879. /**
  108880. * Specifies that the submesh is ready to be used.
  108881. * @param defines the list of "defines" to update.
  108882. * @param scene defines the scene the material belongs to.
  108883. * @returns - boolean indicating that the submesh is ready or not.
  108884. */
  108885. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  108886. /**
  108887. * Checks to see if a texture is used in the material.
  108888. * @param defines the list of "defines" to update.
  108889. * @param mesh the mesh we are preparing the defines for.
  108890. * @param scene defines the scene the material belongs to.
  108891. */
  108892. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  108893. /**
  108894. * Binds the material data.
  108895. * @param uniformBuffer defines the Uniform buffer to fill in.
  108896. * @param scene defines the scene the material belongs to.
  108897. * @param isFrozen defines wether the material is frozen or not.
  108898. */
  108899. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108900. /**
  108901. * Checks to see if a texture is used in the material.
  108902. * @param texture - Base texture to use.
  108903. * @returns - Boolean specifying if a texture is used in the material.
  108904. */
  108905. hasTexture(texture: BaseTexture): boolean;
  108906. /**
  108907. * Returns an array of the actively used textures.
  108908. * @param activeTextures Array of BaseTextures
  108909. */
  108910. getActiveTextures(activeTextures: BaseTexture[]): void;
  108911. /**
  108912. * Returns the animatable textures.
  108913. * @param animatables Array of animatable textures.
  108914. */
  108915. getAnimatables(animatables: IAnimatable[]): void;
  108916. /**
  108917. * Disposes the resources of the material.
  108918. * @param forceDisposeTextures - Forces the disposal of all textures.
  108919. */
  108920. dispose(forceDisposeTextures?: boolean): void;
  108921. /**
  108922. * Get the current class name of the texture useful for serialization or dynamic coding.
  108923. * @returns "PBRAnisotropicConfiguration"
  108924. */
  108925. getClassName(): string;
  108926. /**
  108927. * Add fallbacks to the effect fallbacks list.
  108928. * @param defines defines the Base texture to use.
  108929. * @param fallbacks defines the current fallback list.
  108930. * @param currentRank defines the current fallback rank.
  108931. * @returns the new fallback rank.
  108932. */
  108933. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108934. /**
  108935. * Add the required uniforms to the current list.
  108936. * @param uniforms defines the current uniform list.
  108937. */
  108938. static AddUniforms(uniforms: string[]): void;
  108939. /**
  108940. * Add the required uniforms to the current buffer.
  108941. * @param uniformBuffer defines the current uniform buffer.
  108942. */
  108943. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108944. /**
  108945. * Add the required samplers to the current list.
  108946. * @param samplers defines the current sampler list.
  108947. */
  108948. static AddSamplers(samplers: string[]): void;
  108949. /**
  108950. * Makes a duplicate of the current configuration into another one.
  108951. * @param anisotropicConfiguration define the config where to copy the info
  108952. */
  108953. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  108954. /**
  108955. * Serializes this anisotropy configuration.
  108956. * @returns - An object with the serialized config.
  108957. */
  108958. serialize(): any;
  108959. /**
  108960. * Parses a anisotropy Configuration from a serialized object.
  108961. * @param source - Serialized object.
  108962. * @param scene Defines the scene we are parsing for
  108963. * @param rootUrl Defines the rootUrl to load from
  108964. */
  108965. parse(source: any, scene: Scene, rootUrl: string): void;
  108966. }
  108967. }
  108968. declare module BABYLON {
  108969. /**
  108970. * @hidden
  108971. */
  108972. export interface IMaterialBRDFDefines {
  108973. BRDF_V_HEIGHT_CORRELATED: boolean;
  108974. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108975. SPHERICAL_HARMONICS: boolean;
  108976. /** @hidden */
  108977. _areMiscDirty: boolean;
  108978. }
  108979. /**
  108980. * Define the code related to the BRDF parameters of the pbr material.
  108981. */
  108982. export class PBRBRDFConfiguration {
  108983. /**
  108984. * Default value used for the energy conservation.
  108985. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  108986. */
  108987. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  108988. /**
  108989. * Default value used for the Smith Visibility Height Correlated mode.
  108990. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  108991. */
  108992. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  108993. /**
  108994. * Default value used for the IBL diffuse part.
  108995. * This can help switching back to the polynomials mode globally which is a tiny bit
  108996. * less GPU intensive at the drawback of a lower quality.
  108997. */
  108998. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  108999. private _useEnergyConservation;
  109000. /**
  109001. * Defines if the material uses energy conservation.
  109002. */
  109003. useEnergyConservation: boolean;
  109004. private _useSmithVisibilityHeightCorrelated;
  109005. /**
  109006. * LEGACY Mode set to false
  109007. * Defines if the material uses height smith correlated visibility term.
  109008. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  109009. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109010. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  109011. * Not relying on height correlated will also disable energy conservation.
  109012. */
  109013. useSmithVisibilityHeightCorrelated: boolean;
  109014. private _useSphericalHarmonics;
  109015. /**
  109016. * LEGACY Mode set to false
  109017. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  109018. * diffuse part of the IBL.
  109019. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  109020. * to the ground truth.
  109021. */
  109022. useSphericalHarmonics: boolean;
  109023. /** @hidden */
  109024. private _internalMarkAllSubMeshesAsMiscDirty;
  109025. /** @hidden */
  109026. _markAllSubMeshesAsMiscDirty(): void;
  109027. /**
  109028. * Instantiate a new istance of clear coat configuration.
  109029. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  109030. */
  109031. constructor(markAllSubMeshesAsMiscDirty: () => void);
  109032. /**
  109033. * Checks to see if a texture is used in the material.
  109034. * @param defines the list of "defines" to update.
  109035. */
  109036. prepareDefines(defines: IMaterialBRDFDefines): void;
  109037. /**
  109038. * Get the current class name of the texture useful for serialization or dynamic coding.
  109039. * @returns "PBRClearCoatConfiguration"
  109040. */
  109041. getClassName(): string;
  109042. /**
  109043. * Makes a duplicate of the current configuration into another one.
  109044. * @param brdfConfiguration define the config where to copy the info
  109045. */
  109046. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  109047. /**
  109048. * Serializes this BRDF configuration.
  109049. * @returns - An object with the serialized config.
  109050. */
  109051. serialize(): any;
  109052. /**
  109053. * Parses a anisotropy Configuration from a serialized object.
  109054. * @param source - Serialized object.
  109055. * @param scene Defines the scene we are parsing for
  109056. * @param rootUrl Defines the rootUrl to load from
  109057. */
  109058. parse(source: any, scene: Scene, rootUrl: string): void;
  109059. }
  109060. }
  109061. declare module BABYLON {
  109062. /**
  109063. * @hidden
  109064. */
  109065. export interface IMaterialSheenDefines {
  109066. SHEEN: boolean;
  109067. SHEEN_TEXTURE: boolean;
  109068. SHEEN_TEXTUREDIRECTUV: number;
  109069. SHEEN_LINKWITHALBEDO: boolean;
  109070. /** @hidden */
  109071. _areTexturesDirty: boolean;
  109072. }
  109073. /**
  109074. * Define the code related to the Sheen parameters of the pbr material.
  109075. */
  109076. export class PBRSheenConfiguration {
  109077. private _isEnabled;
  109078. /**
  109079. * Defines if the material uses sheen.
  109080. */
  109081. isEnabled: boolean;
  109082. private _linkSheenWithAlbedo;
  109083. /**
  109084. * Defines if the sheen is linked to the sheen color.
  109085. */
  109086. linkSheenWithAlbedo: boolean;
  109087. /**
  109088. * Defines the sheen intensity.
  109089. */
  109090. intensity: number;
  109091. /**
  109092. * Defines the sheen color.
  109093. */
  109094. color: Color3;
  109095. private _texture;
  109096. /**
  109097. * Stores the sheen tint values in a texture.
  109098. * rgb is tint
  109099. * a is a intensity
  109100. */
  109101. texture: Nullable<BaseTexture>;
  109102. /** @hidden */
  109103. private _internalMarkAllSubMeshesAsTexturesDirty;
  109104. /** @hidden */
  109105. _markAllSubMeshesAsTexturesDirty(): void;
  109106. /**
  109107. * Instantiate a new istance of clear coat configuration.
  109108. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109109. */
  109110. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109111. /**
  109112. * Specifies that the submesh is ready to be used.
  109113. * @param defines the list of "defines" to update.
  109114. * @param scene defines the scene the material belongs to.
  109115. * @returns - boolean indicating that the submesh is ready or not.
  109116. */
  109117. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  109118. /**
  109119. * Checks to see if a texture is used in the material.
  109120. * @param defines the list of "defines" to update.
  109121. * @param scene defines the scene the material belongs to.
  109122. */
  109123. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  109124. /**
  109125. * Binds the material data.
  109126. * @param uniformBuffer defines the Uniform buffer to fill in.
  109127. * @param scene defines the scene the material belongs to.
  109128. * @param isFrozen defines wether the material is frozen or not.
  109129. */
  109130. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109131. /**
  109132. * Checks to see if a texture is used in the material.
  109133. * @param texture - Base texture to use.
  109134. * @returns - Boolean specifying if a texture is used in the material.
  109135. */
  109136. hasTexture(texture: BaseTexture): boolean;
  109137. /**
  109138. * Returns an array of the actively used textures.
  109139. * @param activeTextures Array of BaseTextures
  109140. */
  109141. getActiveTextures(activeTextures: BaseTexture[]): void;
  109142. /**
  109143. * Returns the animatable textures.
  109144. * @param animatables Array of animatable textures.
  109145. */
  109146. getAnimatables(animatables: IAnimatable[]): void;
  109147. /**
  109148. * Disposes the resources of the material.
  109149. * @param forceDisposeTextures - Forces the disposal of all textures.
  109150. */
  109151. dispose(forceDisposeTextures?: boolean): void;
  109152. /**
  109153. * Get the current class name of the texture useful for serialization or dynamic coding.
  109154. * @returns "PBRSheenConfiguration"
  109155. */
  109156. getClassName(): string;
  109157. /**
  109158. * Add fallbacks to the effect fallbacks list.
  109159. * @param defines defines the Base texture to use.
  109160. * @param fallbacks defines the current fallback list.
  109161. * @param currentRank defines the current fallback rank.
  109162. * @returns the new fallback rank.
  109163. */
  109164. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109165. /**
  109166. * Add the required uniforms to the current list.
  109167. * @param uniforms defines the current uniform list.
  109168. */
  109169. static AddUniforms(uniforms: string[]): void;
  109170. /**
  109171. * Add the required uniforms to the current buffer.
  109172. * @param uniformBuffer defines the current uniform buffer.
  109173. */
  109174. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109175. /**
  109176. * Add the required samplers to the current list.
  109177. * @param samplers defines the current sampler list.
  109178. */
  109179. static AddSamplers(samplers: string[]): void;
  109180. /**
  109181. * Makes a duplicate of the current configuration into another one.
  109182. * @param sheenConfiguration define the config where to copy the info
  109183. */
  109184. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  109185. /**
  109186. * Serializes this BRDF configuration.
  109187. * @returns - An object with the serialized config.
  109188. */
  109189. serialize(): any;
  109190. /**
  109191. * Parses a anisotropy Configuration from a serialized object.
  109192. * @param source - Serialized object.
  109193. * @param scene Defines the scene we are parsing for
  109194. * @param rootUrl Defines the rootUrl to load from
  109195. */
  109196. parse(source: any, scene: Scene, rootUrl: string): void;
  109197. }
  109198. }
  109199. declare module BABYLON {
  109200. /**
  109201. * @hidden
  109202. */
  109203. export interface IMaterialSubSurfaceDefines {
  109204. SUBSURFACE: boolean;
  109205. SS_REFRACTION: boolean;
  109206. SS_TRANSLUCENCY: boolean;
  109207. SS_SCATERRING: boolean;
  109208. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109209. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109210. SS_REFRACTIONMAP_3D: boolean;
  109211. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109212. SS_LODINREFRACTIONALPHA: boolean;
  109213. SS_GAMMAREFRACTION: boolean;
  109214. SS_RGBDREFRACTION: boolean;
  109215. SS_LINEARSPECULARREFRACTION: boolean;
  109216. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109217. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109218. /** @hidden */
  109219. _areTexturesDirty: boolean;
  109220. }
  109221. /**
  109222. * Define the code related to the sub surface parameters of the pbr material.
  109223. */
  109224. export class PBRSubSurfaceConfiguration {
  109225. private _isRefractionEnabled;
  109226. /**
  109227. * Defines if the refraction is enabled in the material.
  109228. */
  109229. isRefractionEnabled: boolean;
  109230. private _isTranslucencyEnabled;
  109231. /**
  109232. * Defines if the translucency is enabled in the material.
  109233. */
  109234. isTranslucencyEnabled: boolean;
  109235. private _isScatteringEnabled;
  109236. /**
  109237. * Defines the refraction intensity of the material.
  109238. * The refraction when enabled replaces the Diffuse part of the material.
  109239. * The intensity helps transitionning between diffuse and refraction.
  109240. */
  109241. refractionIntensity: number;
  109242. /**
  109243. * Defines the translucency intensity of the material.
  109244. * When translucency has been enabled, this defines how much of the "translucency"
  109245. * is addded to the diffuse part of the material.
  109246. */
  109247. translucencyIntensity: number;
  109248. /**
  109249. * Defines the scattering intensity of the material.
  109250. * When scattering has been enabled, this defines how much of the "scattered light"
  109251. * is addded to the diffuse part of the material.
  109252. */
  109253. scatteringIntensity: number;
  109254. private _thicknessTexture;
  109255. /**
  109256. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  109257. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  109258. * 0 would mean minimumThickness
  109259. * 1 would mean maximumThickness
  109260. * The other channels might be use as a mask to vary the different effects intensity.
  109261. */
  109262. thicknessTexture: Nullable<BaseTexture>;
  109263. private _refractionTexture;
  109264. /**
  109265. * Defines the texture to use for refraction.
  109266. */
  109267. refractionTexture: Nullable<BaseTexture>;
  109268. private _indexOfRefraction;
  109269. /**
  109270. * Defines the index of refraction used in the material.
  109271. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  109272. */
  109273. indexOfRefraction: number;
  109274. private _invertRefractionY;
  109275. /**
  109276. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109277. */
  109278. invertRefractionY: boolean;
  109279. private _linkRefractionWithTransparency;
  109280. /**
  109281. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109282. * Materials half opaque for instance using refraction could benefit from this control.
  109283. */
  109284. linkRefractionWithTransparency: boolean;
  109285. /**
  109286. * Defines the minimum thickness stored in the thickness map.
  109287. * If no thickness map is defined, this value will be used to simulate thickness.
  109288. */
  109289. minimumThickness: number;
  109290. /**
  109291. * Defines the maximum thickness stored in the thickness map.
  109292. */
  109293. maximumThickness: number;
  109294. /**
  109295. * Defines the volume tint of the material.
  109296. * This is used for both translucency and scattering.
  109297. */
  109298. tintColor: Color3;
  109299. /**
  109300. * Defines the distance at which the tint color should be found in the media.
  109301. * This is used for refraction only.
  109302. */
  109303. tintColorAtDistance: number;
  109304. /**
  109305. * Defines how far each channel transmit through the media.
  109306. * It is defined as a color to simplify it selection.
  109307. */
  109308. diffusionDistance: Color3;
  109309. private _useMaskFromThicknessTexture;
  109310. /**
  109311. * Stores the intensity of the different subsurface effects in the thickness texture.
  109312. * * the green channel is the translucency intensity.
  109313. * * the blue channel is the scattering intensity.
  109314. * * the alpha channel is the refraction intensity.
  109315. */
  109316. useMaskFromThicknessTexture: boolean;
  109317. /** @hidden */
  109318. private _internalMarkAllSubMeshesAsTexturesDirty;
  109319. /** @hidden */
  109320. _markAllSubMeshesAsTexturesDirty(): void;
  109321. /**
  109322. * Instantiate a new istance of sub surface configuration.
  109323. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109324. */
  109325. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109326. /**
  109327. * Gets wehter the submesh is ready to be used or not.
  109328. * @param defines the list of "defines" to update.
  109329. * @param scene defines the scene the material belongs to.
  109330. * @returns - boolean indicating that the submesh is ready or not.
  109331. */
  109332. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  109333. /**
  109334. * Checks to see if a texture is used in the material.
  109335. * @param defines the list of "defines" to update.
  109336. * @param scene defines the scene to the material belongs to.
  109337. */
  109338. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  109339. /**
  109340. * Binds the material data.
  109341. * @param uniformBuffer defines the Uniform buffer to fill in.
  109342. * @param scene defines the scene the material belongs to.
  109343. * @param engine defines the engine the material belongs to.
  109344. * @param isFrozen defines wether the material is frozen or not.
  109345. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  109346. */
  109347. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  109348. /**
  109349. * Unbinds the material from the mesh.
  109350. * @param activeEffect defines the effect that should be unbound from.
  109351. * @returns true if unbound, otherwise false
  109352. */
  109353. unbind(activeEffect: Effect): boolean;
  109354. /**
  109355. * Returns the texture used for refraction or null if none is used.
  109356. * @param scene defines the scene the material belongs to.
  109357. * @returns - Refraction texture if present. If no refraction texture and refraction
  109358. * is linked with transparency, returns environment texture. Otherwise, returns null.
  109359. */
  109360. private _getRefractionTexture;
  109361. /**
  109362. * Returns true if alpha blending should be disabled.
  109363. */
  109364. readonly disableAlphaBlending: boolean;
  109365. /**
  109366. * Fills the list of render target textures.
  109367. * @param renderTargets the list of render targets to update
  109368. */
  109369. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  109370. /**
  109371. * Checks to see if a texture is used in the material.
  109372. * @param texture - Base texture to use.
  109373. * @returns - Boolean specifying if a texture is used in the material.
  109374. */
  109375. hasTexture(texture: BaseTexture): boolean;
  109376. /**
  109377. * Gets a boolean indicating that current material needs to register RTT
  109378. * @returns true if this uses a render target otherwise false.
  109379. */
  109380. hasRenderTargetTextures(): boolean;
  109381. /**
  109382. * Returns an array of the actively used textures.
  109383. * @param activeTextures Array of BaseTextures
  109384. */
  109385. getActiveTextures(activeTextures: BaseTexture[]): void;
  109386. /**
  109387. * Returns the animatable textures.
  109388. * @param animatables Array of animatable textures.
  109389. */
  109390. getAnimatables(animatables: IAnimatable[]): void;
  109391. /**
  109392. * Disposes the resources of the material.
  109393. * @param forceDisposeTextures - Forces the disposal of all textures.
  109394. */
  109395. dispose(forceDisposeTextures?: boolean): void;
  109396. /**
  109397. * Get the current class name of the texture useful for serialization or dynamic coding.
  109398. * @returns "PBRSubSurfaceConfiguration"
  109399. */
  109400. getClassName(): string;
  109401. /**
  109402. * Add fallbacks to the effect fallbacks list.
  109403. * @param defines defines the Base texture to use.
  109404. * @param fallbacks defines the current fallback list.
  109405. * @param currentRank defines the current fallback rank.
  109406. * @returns the new fallback rank.
  109407. */
  109408. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109409. /**
  109410. * Add the required uniforms to the current list.
  109411. * @param uniforms defines the current uniform list.
  109412. */
  109413. static AddUniforms(uniforms: string[]): void;
  109414. /**
  109415. * Add the required samplers to the current list.
  109416. * @param samplers defines the current sampler list.
  109417. */
  109418. static AddSamplers(samplers: string[]): void;
  109419. /**
  109420. * Add the required uniforms to the current buffer.
  109421. * @param uniformBuffer defines the current uniform buffer.
  109422. */
  109423. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109424. /**
  109425. * Makes a duplicate of the current configuration into another one.
  109426. * @param configuration define the config where to copy the info
  109427. */
  109428. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  109429. /**
  109430. * Serializes this Sub Surface configuration.
  109431. * @returns - An object with the serialized config.
  109432. */
  109433. serialize(): any;
  109434. /**
  109435. * Parses a anisotropy Configuration from a serialized object.
  109436. * @param source - Serialized object.
  109437. * @param scene Defines the scene we are parsing for
  109438. * @param rootUrl Defines the rootUrl to load from
  109439. */
  109440. parse(source: any, scene: Scene, rootUrl: string): void;
  109441. }
  109442. }
  109443. declare module BABYLON {
  109444. /** @hidden */
  109445. export var pbrFragmentDeclaration: {
  109446. name: string;
  109447. shader: string;
  109448. };
  109449. }
  109450. declare module BABYLON {
  109451. /** @hidden */
  109452. export var pbrUboDeclaration: {
  109453. name: string;
  109454. shader: string;
  109455. };
  109456. }
  109457. declare module BABYLON {
  109458. /** @hidden */
  109459. export var pbrFragmentExtraDeclaration: {
  109460. name: string;
  109461. shader: string;
  109462. };
  109463. }
  109464. declare module BABYLON {
  109465. /** @hidden */
  109466. export var pbrFragmentSamplersDeclaration: {
  109467. name: string;
  109468. shader: string;
  109469. };
  109470. }
  109471. declare module BABYLON {
  109472. /** @hidden */
  109473. export var pbrHelperFunctions: {
  109474. name: string;
  109475. shader: string;
  109476. };
  109477. }
  109478. declare module BABYLON {
  109479. /** @hidden */
  109480. export var harmonicsFunctions: {
  109481. name: string;
  109482. shader: string;
  109483. };
  109484. }
  109485. declare module BABYLON {
  109486. /** @hidden */
  109487. export var pbrDirectLightingSetupFunctions: {
  109488. name: string;
  109489. shader: string;
  109490. };
  109491. }
  109492. declare module BABYLON {
  109493. /** @hidden */
  109494. export var pbrDirectLightingFalloffFunctions: {
  109495. name: string;
  109496. shader: string;
  109497. };
  109498. }
  109499. declare module BABYLON {
  109500. /** @hidden */
  109501. export var pbrBRDFFunctions: {
  109502. name: string;
  109503. shader: string;
  109504. };
  109505. }
  109506. declare module BABYLON {
  109507. /** @hidden */
  109508. export var pbrDirectLightingFunctions: {
  109509. name: string;
  109510. shader: string;
  109511. };
  109512. }
  109513. declare module BABYLON {
  109514. /** @hidden */
  109515. export var pbrIBLFunctions: {
  109516. name: string;
  109517. shader: string;
  109518. };
  109519. }
  109520. declare module BABYLON {
  109521. /** @hidden */
  109522. export var pbrDebug: {
  109523. name: string;
  109524. shader: string;
  109525. };
  109526. }
  109527. declare module BABYLON {
  109528. /** @hidden */
  109529. export var pbrPixelShader: {
  109530. name: string;
  109531. shader: string;
  109532. };
  109533. }
  109534. declare module BABYLON {
  109535. /** @hidden */
  109536. export var pbrVertexDeclaration: {
  109537. name: string;
  109538. shader: string;
  109539. };
  109540. }
  109541. declare module BABYLON {
  109542. /** @hidden */
  109543. export var pbrVertexShader: {
  109544. name: string;
  109545. shader: string;
  109546. };
  109547. }
  109548. declare module BABYLON {
  109549. /**
  109550. * Manages the defines for the PBR Material.
  109551. * @hidden
  109552. */
  109553. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  109554. PBR: boolean;
  109555. MAINUV1: boolean;
  109556. MAINUV2: boolean;
  109557. UV1: boolean;
  109558. UV2: boolean;
  109559. ALBEDO: boolean;
  109560. ALBEDODIRECTUV: number;
  109561. VERTEXCOLOR: boolean;
  109562. AMBIENT: boolean;
  109563. AMBIENTDIRECTUV: number;
  109564. AMBIENTINGRAYSCALE: boolean;
  109565. OPACITY: boolean;
  109566. VERTEXALPHA: boolean;
  109567. OPACITYDIRECTUV: number;
  109568. OPACITYRGB: boolean;
  109569. ALPHATEST: boolean;
  109570. DEPTHPREPASS: boolean;
  109571. ALPHABLEND: boolean;
  109572. ALPHAFROMALBEDO: boolean;
  109573. ALPHATESTVALUE: string;
  109574. SPECULAROVERALPHA: boolean;
  109575. RADIANCEOVERALPHA: boolean;
  109576. ALPHAFRESNEL: boolean;
  109577. LINEARALPHAFRESNEL: boolean;
  109578. PREMULTIPLYALPHA: boolean;
  109579. EMISSIVE: boolean;
  109580. EMISSIVEDIRECTUV: number;
  109581. REFLECTIVITY: boolean;
  109582. REFLECTIVITYDIRECTUV: number;
  109583. SPECULARTERM: boolean;
  109584. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  109585. MICROSURFACEAUTOMATIC: boolean;
  109586. LODBASEDMICROSFURACE: boolean;
  109587. MICROSURFACEMAP: boolean;
  109588. MICROSURFACEMAPDIRECTUV: number;
  109589. METALLICWORKFLOW: boolean;
  109590. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  109591. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  109592. METALLNESSSTOREINMETALMAPBLUE: boolean;
  109593. AOSTOREINMETALMAPRED: boolean;
  109594. ENVIRONMENTBRDF: boolean;
  109595. ENVIRONMENTBRDF_RGBD: boolean;
  109596. NORMAL: boolean;
  109597. TANGENT: boolean;
  109598. BUMP: boolean;
  109599. BUMPDIRECTUV: number;
  109600. OBJECTSPACE_NORMALMAP: boolean;
  109601. PARALLAX: boolean;
  109602. PARALLAXOCCLUSION: boolean;
  109603. NORMALXYSCALE: boolean;
  109604. LIGHTMAP: boolean;
  109605. LIGHTMAPDIRECTUV: number;
  109606. USELIGHTMAPASSHADOWMAP: boolean;
  109607. GAMMALIGHTMAP: boolean;
  109608. REFLECTION: boolean;
  109609. REFLECTIONMAP_3D: boolean;
  109610. REFLECTIONMAP_SPHERICAL: boolean;
  109611. REFLECTIONMAP_PLANAR: boolean;
  109612. REFLECTIONMAP_CUBIC: boolean;
  109613. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109614. REFLECTIONMAP_PROJECTION: boolean;
  109615. REFLECTIONMAP_SKYBOX: boolean;
  109616. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  109617. REFLECTIONMAP_EXPLICIT: boolean;
  109618. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109619. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109620. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109621. INVERTCUBICMAP: boolean;
  109622. USESPHERICALFROMREFLECTIONMAP: boolean;
  109623. USEIRRADIANCEMAP: boolean;
  109624. SPHERICAL_HARMONICS: boolean;
  109625. USESPHERICALINVERTEX: boolean;
  109626. REFLECTIONMAP_OPPOSITEZ: boolean;
  109627. LODINREFLECTIONALPHA: boolean;
  109628. GAMMAREFLECTION: boolean;
  109629. RGBDREFLECTION: boolean;
  109630. LINEARSPECULARREFLECTION: boolean;
  109631. RADIANCEOCCLUSION: boolean;
  109632. HORIZONOCCLUSION: boolean;
  109633. INSTANCES: boolean;
  109634. NUM_BONE_INFLUENCERS: number;
  109635. BonesPerMesh: number;
  109636. BONETEXTURE: boolean;
  109637. NONUNIFORMSCALING: boolean;
  109638. MORPHTARGETS: boolean;
  109639. MORPHTARGETS_NORMAL: boolean;
  109640. MORPHTARGETS_TANGENT: boolean;
  109641. MORPHTARGETS_UV: boolean;
  109642. NUM_MORPH_INFLUENCERS: number;
  109643. IMAGEPROCESSING: boolean;
  109644. VIGNETTE: boolean;
  109645. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109646. VIGNETTEBLENDMODEOPAQUE: boolean;
  109647. TONEMAPPING: boolean;
  109648. TONEMAPPING_ACES: boolean;
  109649. CONTRAST: boolean;
  109650. COLORCURVES: boolean;
  109651. COLORGRADING: boolean;
  109652. COLORGRADING3D: boolean;
  109653. SAMPLER3DGREENDEPTH: boolean;
  109654. SAMPLER3DBGRMAP: boolean;
  109655. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109656. EXPOSURE: boolean;
  109657. MULTIVIEW: boolean;
  109658. USEPHYSICALLIGHTFALLOFF: boolean;
  109659. USEGLTFLIGHTFALLOFF: boolean;
  109660. TWOSIDEDLIGHTING: boolean;
  109661. SHADOWFLOAT: boolean;
  109662. CLIPPLANE: boolean;
  109663. CLIPPLANE2: boolean;
  109664. CLIPPLANE3: boolean;
  109665. CLIPPLANE4: boolean;
  109666. POINTSIZE: boolean;
  109667. FOG: boolean;
  109668. LOGARITHMICDEPTH: boolean;
  109669. FORCENORMALFORWARD: boolean;
  109670. SPECULARAA: boolean;
  109671. CLEARCOAT: boolean;
  109672. CLEARCOAT_DEFAULTIOR: boolean;
  109673. CLEARCOAT_TEXTURE: boolean;
  109674. CLEARCOAT_TEXTUREDIRECTUV: number;
  109675. CLEARCOAT_BUMP: boolean;
  109676. CLEARCOAT_BUMPDIRECTUV: number;
  109677. CLEARCOAT_TINT: boolean;
  109678. CLEARCOAT_TINT_TEXTURE: boolean;
  109679. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109680. ANISOTROPIC: boolean;
  109681. ANISOTROPIC_TEXTURE: boolean;
  109682. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109683. BRDF_V_HEIGHT_CORRELATED: boolean;
  109684. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109685. SHEEN: boolean;
  109686. SHEEN_TEXTURE: boolean;
  109687. SHEEN_TEXTUREDIRECTUV: number;
  109688. SHEEN_LINKWITHALBEDO: boolean;
  109689. SUBSURFACE: boolean;
  109690. SS_REFRACTION: boolean;
  109691. SS_TRANSLUCENCY: boolean;
  109692. SS_SCATERRING: boolean;
  109693. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109694. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109695. SS_REFRACTIONMAP_3D: boolean;
  109696. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109697. SS_LODINREFRACTIONALPHA: boolean;
  109698. SS_GAMMAREFRACTION: boolean;
  109699. SS_RGBDREFRACTION: boolean;
  109700. SS_LINEARSPECULARREFRACTION: boolean;
  109701. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109702. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109703. UNLIT: boolean;
  109704. DEBUGMODE: number;
  109705. /**
  109706. * Initializes the PBR Material defines.
  109707. */
  109708. constructor();
  109709. /**
  109710. * Resets the PBR Material defines.
  109711. */
  109712. reset(): void;
  109713. }
  109714. /**
  109715. * The Physically based material base class of BJS.
  109716. *
  109717. * This offers the main features of a standard PBR material.
  109718. * For more information, please refer to the documentation :
  109719. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109720. */
  109721. export abstract class PBRBaseMaterial extends PushMaterial {
  109722. /**
  109723. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109724. */
  109725. static readonly PBRMATERIAL_OPAQUE: number;
  109726. /**
  109727. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109728. */
  109729. static readonly PBRMATERIAL_ALPHATEST: number;
  109730. /**
  109731. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109732. */
  109733. static readonly PBRMATERIAL_ALPHABLEND: number;
  109734. /**
  109735. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109736. * They are also discarded below the alpha cutoff threshold to improve performances.
  109737. */
  109738. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109739. /**
  109740. * Defines the default value of how much AO map is occluding the analytical lights
  109741. * (point spot...).
  109742. */
  109743. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109744. /**
  109745. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  109746. */
  109747. static readonly LIGHTFALLOFF_PHYSICAL: number;
  109748. /**
  109749. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  109750. * to enhance interoperability with other engines.
  109751. */
  109752. static readonly LIGHTFALLOFF_GLTF: number;
  109753. /**
  109754. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  109755. * to enhance interoperability with other materials.
  109756. */
  109757. static readonly LIGHTFALLOFF_STANDARD: number;
  109758. /**
  109759. * Intensity of the direct lights e.g. the four lights available in your scene.
  109760. * This impacts both the direct diffuse and specular highlights.
  109761. */
  109762. protected _directIntensity: number;
  109763. /**
  109764. * Intensity of the emissive part of the material.
  109765. * This helps controlling the emissive effect without modifying the emissive color.
  109766. */
  109767. protected _emissiveIntensity: number;
  109768. /**
  109769. * Intensity of the environment e.g. how much the environment will light the object
  109770. * either through harmonics for rough material or through the refelction for shiny ones.
  109771. */
  109772. protected _environmentIntensity: number;
  109773. /**
  109774. * This is a special control allowing the reduction of the specular highlights coming from the
  109775. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109776. */
  109777. protected _specularIntensity: number;
  109778. /**
  109779. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  109780. */
  109781. private _lightingInfos;
  109782. /**
  109783. * Debug Control allowing disabling the bump map on this material.
  109784. */
  109785. protected _disableBumpMap: boolean;
  109786. /**
  109787. * AKA Diffuse Texture in standard nomenclature.
  109788. */
  109789. protected _albedoTexture: Nullable<BaseTexture>;
  109790. /**
  109791. * AKA Occlusion Texture in other nomenclature.
  109792. */
  109793. protected _ambientTexture: Nullable<BaseTexture>;
  109794. /**
  109795. * AKA Occlusion Texture Intensity in other nomenclature.
  109796. */
  109797. protected _ambientTextureStrength: number;
  109798. /**
  109799. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109800. * 1 means it completely occludes it
  109801. * 0 mean it has no impact
  109802. */
  109803. protected _ambientTextureImpactOnAnalyticalLights: number;
  109804. /**
  109805. * Stores the alpha values in a texture.
  109806. */
  109807. protected _opacityTexture: Nullable<BaseTexture>;
  109808. /**
  109809. * Stores the reflection values in a texture.
  109810. */
  109811. protected _reflectionTexture: Nullable<BaseTexture>;
  109812. /**
  109813. * Stores the emissive values in a texture.
  109814. */
  109815. protected _emissiveTexture: Nullable<BaseTexture>;
  109816. /**
  109817. * AKA Specular texture in other nomenclature.
  109818. */
  109819. protected _reflectivityTexture: Nullable<BaseTexture>;
  109820. /**
  109821. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109822. */
  109823. protected _metallicTexture: Nullable<BaseTexture>;
  109824. /**
  109825. * Specifies the metallic scalar of the metallic/roughness workflow.
  109826. * Can also be used to scale the metalness values of the metallic texture.
  109827. */
  109828. protected _metallic: Nullable<number>;
  109829. /**
  109830. * Specifies the roughness scalar of the metallic/roughness workflow.
  109831. * Can also be used to scale the roughness values of the metallic texture.
  109832. */
  109833. protected _roughness: Nullable<number>;
  109834. /**
  109835. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109836. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109837. */
  109838. protected _microSurfaceTexture: Nullable<BaseTexture>;
  109839. /**
  109840. * Stores surface normal data used to displace a mesh in a texture.
  109841. */
  109842. protected _bumpTexture: Nullable<BaseTexture>;
  109843. /**
  109844. * Stores the pre-calculated light information of a mesh in a texture.
  109845. */
  109846. protected _lightmapTexture: Nullable<BaseTexture>;
  109847. /**
  109848. * The color of a material in ambient lighting.
  109849. */
  109850. protected _ambientColor: Color3;
  109851. /**
  109852. * AKA Diffuse Color in other nomenclature.
  109853. */
  109854. protected _albedoColor: Color3;
  109855. /**
  109856. * AKA Specular Color in other nomenclature.
  109857. */
  109858. protected _reflectivityColor: Color3;
  109859. /**
  109860. * The color applied when light is reflected from a material.
  109861. */
  109862. protected _reflectionColor: Color3;
  109863. /**
  109864. * The color applied when light is emitted from a material.
  109865. */
  109866. protected _emissiveColor: Color3;
  109867. /**
  109868. * AKA Glossiness in other nomenclature.
  109869. */
  109870. protected _microSurface: number;
  109871. /**
  109872. * Specifies that the material will use the light map as a show map.
  109873. */
  109874. protected _useLightmapAsShadowmap: boolean;
  109875. /**
  109876. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109877. * makes the reflect vector face the model (under horizon).
  109878. */
  109879. protected _useHorizonOcclusion: boolean;
  109880. /**
  109881. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109882. * too much the area relying on ambient texture to define their ambient occlusion.
  109883. */
  109884. protected _useRadianceOcclusion: boolean;
  109885. /**
  109886. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109887. */
  109888. protected _useAlphaFromAlbedoTexture: boolean;
  109889. /**
  109890. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  109891. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109892. */
  109893. protected _useSpecularOverAlpha: boolean;
  109894. /**
  109895. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109896. */
  109897. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109898. /**
  109899. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109900. */
  109901. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  109902. /**
  109903. * Specifies if the metallic texture contains the roughness information in its green channel.
  109904. */
  109905. protected _useRoughnessFromMetallicTextureGreen: boolean;
  109906. /**
  109907. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109908. */
  109909. protected _useMetallnessFromMetallicTextureBlue: boolean;
  109910. /**
  109911. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109912. */
  109913. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  109914. /**
  109915. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109916. */
  109917. protected _useAmbientInGrayScale: boolean;
  109918. /**
  109919. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109920. * The material will try to infer what glossiness each pixel should be.
  109921. */
  109922. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  109923. /**
  109924. * Defines the falloff type used in this material.
  109925. * It by default is Physical.
  109926. */
  109927. protected _lightFalloff: number;
  109928. /**
  109929. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109930. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109931. */
  109932. protected _useRadianceOverAlpha: boolean;
  109933. /**
  109934. * Allows using an object space normal map (instead of tangent space).
  109935. */
  109936. protected _useObjectSpaceNormalMap: boolean;
  109937. /**
  109938. * Allows using the bump map in parallax mode.
  109939. */
  109940. protected _useParallax: boolean;
  109941. /**
  109942. * Allows using the bump map in parallax occlusion mode.
  109943. */
  109944. protected _useParallaxOcclusion: boolean;
  109945. /**
  109946. * Controls the scale bias of the parallax mode.
  109947. */
  109948. protected _parallaxScaleBias: number;
  109949. /**
  109950. * If sets to true, disables all the lights affecting the material.
  109951. */
  109952. protected _disableLighting: boolean;
  109953. /**
  109954. * Number of Simultaneous lights allowed on the material.
  109955. */
  109956. protected _maxSimultaneousLights: number;
  109957. /**
  109958. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  109959. */
  109960. protected _invertNormalMapX: boolean;
  109961. /**
  109962. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  109963. */
  109964. protected _invertNormalMapY: boolean;
  109965. /**
  109966. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109967. */
  109968. protected _twoSidedLighting: boolean;
  109969. /**
  109970. * Defines the alpha limits in alpha test mode.
  109971. */
  109972. protected _alphaCutOff: number;
  109973. /**
  109974. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109975. */
  109976. protected _forceAlphaTest: boolean;
  109977. /**
  109978. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109979. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109980. */
  109981. protected _useAlphaFresnel: boolean;
  109982. /**
  109983. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109984. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109985. */
  109986. protected _useLinearAlphaFresnel: boolean;
  109987. /**
  109988. * The transparency mode of the material.
  109989. */
  109990. protected _transparencyMode: Nullable<number>;
  109991. /**
  109992. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  109993. * from cos thetav and roughness:
  109994. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  109995. */
  109996. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  109997. /**
  109998. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109999. */
  110000. protected _forceIrradianceInFragment: boolean;
  110001. /**
  110002. * Force normal to face away from face.
  110003. */
  110004. protected _forceNormalForward: boolean;
  110005. /**
  110006. * Enables specular anti aliasing in the PBR shader.
  110007. * It will both interacts on the Geometry for analytical and IBL lighting.
  110008. * It also prefilter the roughness map based on the bump values.
  110009. */
  110010. protected _enableSpecularAntiAliasing: boolean;
  110011. /**
  110012. * Default configuration related to image processing available in the PBR Material.
  110013. */
  110014. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110015. /**
  110016. * Keep track of the image processing observer to allow dispose and replace.
  110017. */
  110018. private _imageProcessingObserver;
  110019. /**
  110020. * Attaches a new image processing configuration to the PBR Material.
  110021. * @param configuration
  110022. */
  110023. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110024. /**
  110025. * Stores the available render targets.
  110026. */
  110027. private _renderTargets;
  110028. /**
  110029. * Sets the global ambient color for the material used in lighting calculations.
  110030. */
  110031. private _globalAmbientColor;
  110032. /**
  110033. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  110034. */
  110035. private _useLogarithmicDepth;
  110036. /**
  110037. * If set to true, no lighting calculations will be applied.
  110038. */
  110039. private _unlit;
  110040. private _debugMode;
  110041. /**
  110042. * @hidden
  110043. * This is reserved for the inspector.
  110044. * Defines the material debug mode.
  110045. * It helps seeing only some components of the material while troubleshooting.
  110046. */
  110047. debugMode: number;
  110048. /**
  110049. * @hidden
  110050. * This is reserved for the inspector.
  110051. * Specify from where on screen the debug mode should start.
  110052. * The value goes from -1 (full screen) to 1 (not visible)
  110053. * It helps with side by side comparison against the final render
  110054. * This defaults to -1
  110055. */
  110056. private debugLimit;
  110057. /**
  110058. * @hidden
  110059. * This is reserved for the inspector.
  110060. * As the default viewing range might not be enough (if the ambient is really small for instance)
  110061. * You can use the factor to better multiply the final value.
  110062. */
  110063. private debugFactor;
  110064. /**
  110065. * Defines the clear coat layer parameters for the material.
  110066. */
  110067. readonly clearCoat: PBRClearCoatConfiguration;
  110068. /**
  110069. * Defines the anisotropic parameters for the material.
  110070. */
  110071. readonly anisotropy: PBRAnisotropicConfiguration;
  110072. /**
  110073. * Defines the BRDF parameters for the material.
  110074. */
  110075. readonly brdf: PBRBRDFConfiguration;
  110076. /**
  110077. * Defines the Sheen parameters for the material.
  110078. */
  110079. readonly sheen: PBRSheenConfiguration;
  110080. /**
  110081. * Defines the SubSurface parameters for the material.
  110082. */
  110083. readonly subSurface: PBRSubSurfaceConfiguration;
  110084. /**
  110085. * Custom callback helping to override the default shader used in the material.
  110086. */
  110087. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  110088. /**
  110089. * Instantiates a new PBRMaterial instance.
  110090. *
  110091. * @param name The material name
  110092. * @param scene The scene the material will be use in.
  110093. */
  110094. constructor(name: string, scene: Scene);
  110095. /**
  110096. * Gets a boolean indicating that current material needs to register RTT
  110097. */
  110098. readonly hasRenderTargetTextures: boolean;
  110099. /**
  110100. * Gets the name of the material class.
  110101. */
  110102. getClassName(): string;
  110103. /**
  110104. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110105. */
  110106. /**
  110107. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110108. */
  110109. useLogarithmicDepth: boolean;
  110110. /**
  110111. * Gets the current transparency mode.
  110112. */
  110113. /**
  110114. * Sets the transparency mode of the material.
  110115. *
  110116. * | Value | Type | Description |
  110117. * | ----- | ----------------------------------- | ----------- |
  110118. * | 0 | OPAQUE | |
  110119. * | 1 | ALPHATEST | |
  110120. * | 2 | ALPHABLEND | |
  110121. * | 3 | ALPHATESTANDBLEND | |
  110122. *
  110123. */
  110124. transparencyMode: Nullable<number>;
  110125. /**
  110126. * Returns true if alpha blending should be disabled.
  110127. */
  110128. private readonly _disableAlphaBlending;
  110129. /**
  110130. * Specifies whether or not this material should be rendered in alpha blend mode.
  110131. */
  110132. needAlphaBlending(): boolean;
  110133. /**
  110134. * Specifies if the mesh will require alpha blending.
  110135. * @param mesh - BJS mesh.
  110136. */
  110137. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110138. /**
  110139. * Specifies whether or not this material should be rendered in alpha test mode.
  110140. */
  110141. needAlphaTesting(): boolean;
  110142. /**
  110143. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  110144. */
  110145. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  110146. /**
  110147. * Gets the texture used for the alpha test.
  110148. */
  110149. getAlphaTestTexture(): Nullable<BaseTexture>;
  110150. /**
  110151. * Specifies that the submesh is ready to be used.
  110152. * @param mesh - BJS mesh.
  110153. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  110154. * @param useInstances - Specifies that instances should be used.
  110155. * @returns - boolean indicating that the submesh is ready or not.
  110156. */
  110157. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110158. /**
  110159. * Specifies if the material uses metallic roughness workflow.
  110160. * @returns boolean specifiying if the material uses metallic roughness workflow.
  110161. */
  110162. isMetallicWorkflow(): boolean;
  110163. private _prepareEffect;
  110164. private _prepareDefines;
  110165. /**
  110166. * Force shader compilation
  110167. */
  110168. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  110169. clipPlane: boolean;
  110170. }>): void;
  110171. /**
  110172. * Initializes the uniform buffer layout for the shader.
  110173. */
  110174. buildUniformLayout(): void;
  110175. /**
  110176. * Unbinds the material from the mesh
  110177. */
  110178. unbind(): void;
  110179. /**
  110180. * Binds the submesh data.
  110181. * @param world - The world matrix.
  110182. * @param mesh - The BJS mesh.
  110183. * @param subMesh - A submesh of the BJS mesh.
  110184. */
  110185. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110186. /**
  110187. * Returns the animatable textures.
  110188. * @returns - Array of animatable textures.
  110189. */
  110190. getAnimatables(): IAnimatable[];
  110191. /**
  110192. * Returns the texture used for reflections.
  110193. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  110194. */
  110195. private _getReflectionTexture;
  110196. /**
  110197. * Returns an array of the actively used textures.
  110198. * @returns - Array of BaseTextures
  110199. */
  110200. getActiveTextures(): BaseTexture[];
  110201. /**
  110202. * Checks to see if a texture is used in the material.
  110203. * @param texture - Base texture to use.
  110204. * @returns - Boolean specifying if a texture is used in the material.
  110205. */
  110206. hasTexture(texture: BaseTexture): boolean;
  110207. /**
  110208. * Disposes the resources of the material.
  110209. * @param forceDisposeEffect - Forces the disposal of effects.
  110210. * @param forceDisposeTextures - Forces the disposal of all textures.
  110211. */
  110212. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110213. }
  110214. }
  110215. declare module BABYLON {
  110216. /**
  110217. * The Physically based material of BJS.
  110218. *
  110219. * This offers the main features of a standard PBR material.
  110220. * For more information, please refer to the documentation :
  110221. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110222. */
  110223. export class PBRMaterial extends PBRBaseMaterial {
  110224. /**
  110225. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110226. */
  110227. static readonly PBRMATERIAL_OPAQUE: number;
  110228. /**
  110229. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110230. */
  110231. static readonly PBRMATERIAL_ALPHATEST: number;
  110232. /**
  110233. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110234. */
  110235. static readonly PBRMATERIAL_ALPHABLEND: number;
  110236. /**
  110237. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110238. * They are also discarded below the alpha cutoff threshold to improve performances.
  110239. */
  110240. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110241. /**
  110242. * Defines the default value of how much AO map is occluding the analytical lights
  110243. * (point spot...).
  110244. */
  110245. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110246. /**
  110247. * Intensity of the direct lights e.g. the four lights available in your scene.
  110248. * This impacts both the direct diffuse and specular highlights.
  110249. */
  110250. directIntensity: number;
  110251. /**
  110252. * Intensity of the emissive part of the material.
  110253. * This helps controlling the emissive effect without modifying the emissive color.
  110254. */
  110255. emissiveIntensity: number;
  110256. /**
  110257. * Intensity of the environment e.g. how much the environment will light the object
  110258. * either through harmonics for rough material or through the refelction for shiny ones.
  110259. */
  110260. environmentIntensity: number;
  110261. /**
  110262. * This is a special control allowing the reduction of the specular highlights coming from the
  110263. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110264. */
  110265. specularIntensity: number;
  110266. /**
  110267. * Debug Control allowing disabling the bump map on this material.
  110268. */
  110269. disableBumpMap: boolean;
  110270. /**
  110271. * AKA Diffuse Texture in standard nomenclature.
  110272. */
  110273. albedoTexture: BaseTexture;
  110274. /**
  110275. * AKA Occlusion Texture in other nomenclature.
  110276. */
  110277. ambientTexture: BaseTexture;
  110278. /**
  110279. * AKA Occlusion Texture Intensity in other nomenclature.
  110280. */
  110281. ambientTextureStrength: number;
  110282. /**
  110283. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110284. * 1 means it completely occludes it
  110285. * 0 mean it has no impact
  110286. */
  110287. ambientTextureImpactOnAnalyticalLights: number;
  110288. /**
  110289. * Stores the alpha values in a texture.
  110290. */
  110291. opacityTexture: BaseTexture;
  110292. /**
  110293. * Stores the reflection values in a texture.
  110294. */
  110295. reflectionTexture: Nullable<BaseTexture>;
  110296. /**
  110297. * Stores the emissive values in a texture.
  110298. */
  110299. emissiveTexture: BaseTexture;
  110300. /**
  110301. * AKA Specular texture in other nomenclature.
  110302. */
  110303. reflectivityTexture: BaseTexture;
  110304. /**
  110305. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110306. */
  110307. metallicTexture: BaseTexture;
  110308. /**
  110309. * Specifies the metallic scalar of the metallic/roughness workflow.
  110310. * Can also be used to scale the metalness values of the metallic texture.
  110311. */
  110312. metallic: Nullable<number>;
  110313. /**
  110314. * Specifies the roughness scalar of the metallic/roughness workflow.
  110315. * Can also be used to scale the roughness values of the metallic texture.
  110316. */
  110317. roughness: Nullable<number>;
  110318. /**
  110319. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110320. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110321. */
  110322. microSurfaceTexture: BaseTexture;
  110323. /**
  110324. * Stores surface normal data used to displace a mesh in a texture.
  110325. */
  110326. bumpTexture: BaseTexture;
  110327. /**
  110328. * Stores the pre-calculated light information of a mesh in a texture.
  110329. */
  110330. lightmapTexture: BaseTexture;
  110331. /**
  110332. * Stores the refracted light information in a texture.
  110333. */
  110334. refractionTexture: Nullable<BaseTexture>;
  110335. /**
  110336. * The color of a material in ambient lighting.
  110337. */
  110338. ambientColor: Color3;
  110339. /**
  110340. * AKA Diffuse Color in other nomenclature.
  110341. */
  110342. albedoColor: Color3;
  110343. /**
  110344. * AKA Specular Color in other nomenclature.
  110345. */
  110346. reflectivityColor: Color3;
  110347. /**
  110348. * The color reflected from the material.
  110349. */
  110350. reflectionColor: Color3;
  110351. /**
  110352. * The color emitted from the material.
  110353. */
  110354. emissiveColor: Color3;
  110355. /**
  110356. * AKA Glossiness in other nomenclature.
  110357. */
  110358. microSurface: number;
  110359. /**
  110360. * source material index of refraction (IOR)' / 'destination material IOR.
  110361. */
  110362. indexOfRefraction: number;
  110363. /**
  110364. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110365. */
  110366. invertRefractionY: boolean;
  110367. /**
  110368. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110369. * Materials half opaque for instance using refraction could benefit from this control.
  110370. */
  110371. linkRefractionWithTransparency: boolean;
  110372. /**
  110373. * If true, the light map contains occlusion information instead of lighting info.
  110374. */
  110375. useLightmapAsShadowmap: boolean;
  110376. /**
  110377. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110378. */
  110379. useAlphaFromAlbedoTexture: boolean;
  110380. /**
  110381. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110382. */
  110383. forceAlphaTest: boolean;
  110384. /**
  110385. * Defines the alpha limits in alpha test mode.
  110386. */
  110387. alphaCutOff: number;
  110388. /**
  110389. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110390. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110391. */
  110392. useSpecularOverAlpha: boolean;
  110393. /**
  110394. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110395. */
  110396. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110397. /**
  110398. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110399. */
  110400. useRoughnessFromMetallicTextureAlpha: boolean;
  110401. /**
  110402. * Specifies if the metallic texture contains the roughness information in its green channel.
  110403. */
  110404. useRoughnessFromMetallicTextureGreen: boolean;
  110405. /**
  110406. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110407. */
  110408. useMetallnessFromMetallicTextureBlue: boolean;
  110409. /**
  110410. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110411. */
  110412. useAmbientOcclusionFromMetallicTextureRed: boolean;
  110413. /**
  110414. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110415. */
  110416. useAmbientInGrayScale: boolean;
  110417. /**
  110418. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110419. * The material will try to infer what glossiness each pixel should be.
  110420. */
  110421. useAutoMicroSurfaceFromReflectivityMap: boolean;
  110422. /**
  110423. * BJS is using an harcoded light falloff based on a manually sets up range.
  110424. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110425. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110426. */
  110427. /**
  110428. * BJS is using an harcoded light falloff based on a manually sets up range.
  110429. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110430. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110431. */
  110432. usePhysicalLightFalloff: boolean;
  110433. /**
  110434. * In order to support the falloff compatibility with gltf, a special mode has been added
  110435. * to reproduce the gltf light falloff.
  110436. */
  110437. /**
  110438. * In order to support the falloff compatibility with gltf, a special mode has been added
  110439. * to reproduce the gltf light falloff.
  110440. */
  110441. useGLTFLightFalloff: boolean;
  110442. /**
  110443. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110444. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110445. */
  110446. useRadianceOverAlpha: boolean;
  110447. /**
  110448. * Allows using an object space normal map (instead of tangent space).
  110449. */
  110450. useObjectSpaceNormalMap: boolean;
  110451. /**
  110452. * Allows using the bump map in parallax mode.
  110453. */
  110454. useParallax: boolean;
  110455. /**
  110456. * Allows using the bump map in parallax occlusion mode.
  110457. */
  110458. useParallaxOcclusion: boolean;
  110459. /**
  110460. * Controls the scale bias of the parallax mode.
  110461. */
  110462. parallaxScaleBias: number;
  110463. /**
  110464. * If sets to true, disables all the lights affecting the material.
  110465. */
  110466. disableLighting: boolean;
  110467. /**
  110468. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110469. */
  110470. forceIrradianceInFragment: boolean;
  110471. /**
  110472. * Number of Simultaneous lights allowed on the material.
  110473. */
  110474. maxSimultaneousLights: number;
  110475. /**
  110476. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110477. */
  110478. invertNormalMapX: boolean;
  110479. /**
  110480. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110481. */
  110482. invertNormalMapY: boolean;
  110483. /**
  110484. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110485. */
  110486. twoSidedLighting: boolean;
  110487. /**
  110488. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110489. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110490. */
  110491. useAlphaFresnel: boolean;
  110492. /**
  110493. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110494. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110495. */
  110496. useLinearAlphaFresnel: boolean;
  110497. /**
  110498. * Let user defines the brdf lookup texture used for IBL.
  110499. * A default 8bit version is embedded but you could point at :
  110500. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  110501. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  110502. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  110503. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  110504. */
  110505. environmentBRDFTexture: Nullable<BaseTexture>;
  110506. /**
  110507. * Force normal to face away from face.
  110508. */
  110509. forceNormalForward: boolean;
  110510. /**
  110511. * Enables specular anti aliasing in the PBR shader.
  110512. * It will both interacts on the Geometry for analytical and IBL lighting.
  110513. * It also prefilter the roughness map based on the bump values.
  110514. */
  110515. enableSpecularAntiAliasing: boolean;
  110516. /**
  110517. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110518. * makes the reflect vector face the model (under horizon).
  110519. */
  110520. useHorizonOcclusion: boolean;
  110521. /**
  110522. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110523. * too much the area relying on ambient texture to define their ambient occlusion.
  110524. */
  110525. useRadianceOcclusion: boolean;
  110526. /**
  110527. * If set to true, no lighting calculations will be applied.
  110528. */
  110529. unlit: boolean;
  110530. /**
  110531. * Gets the image processing configuration used either in this material.
  110532. */
  110533. /**
  110534. * Sets the Default image processing configuration used either in the this material.
  110535. *
  110536. * If sets to null, the scene one is in use.
  110537. */
  110538. imageProcessingConfiguration: ImageProcessingConfiguration;
  110539. /**
  110540. * Gets wether the color curves effect is enabled.
  110541. */
  110542. /**
  110543. * Sets wether the color curves effect is enabled.
  110544. */
  110545. cameraColorCurvesEnabled: boolean;
  110546. /**
  110547. * Gets wether the color grading effect is enabled.
  110548. */
  110549. /**
  110550. * Gets wether the color grading effect is enabled.
  110551. */
  110552. cameraColorGradingEnabled: boolean;
  110553. /**
  110554. * Gets wether tonemapping is enabled or not.
  110555. */
  110556. /**
  110557. * Sets wether tonemapping is enabled or not
  110558. */
  110559. cameraToneMappingEnabled: boolean;
  110560. /**
  110561. * The camera exposure used on this material.
  110562. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110563. * This corresponds to a photographic exposure.
  110564. */
  110565. /**
  110566. * The camera exposure used on this material.
  110567. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110568. * This corresponds to a photographic exposure.
  110569. */
  110570. cameraExposure: number;
  110571. /**
  110572. * Gets The camera contrast used on this material.
  110573. */
  110574. /**
  110575. * Sets The camera contrast used on this material.
  110576. */
  110577. cameraContrast: number;
  110578. /**
  110579. * Gets the Color Grading 2D Lookup Texture.
  110580. */
  110581. /**
  110582. * Sets the Color Grading 2D Lookup Texture.
  110583. */
  110584. cameraColorGradingTexture: Nullable<BaseTexture>;
  110585. /**
  110586. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110587. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110588. * 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;
  110589. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110590. */
  110591. /**
  110592. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110593. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110594. * 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;
  110595. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110596. */
  110597. cameraColorCurves: Nullable<ColorCurves>;
  110598. /**
  110599. * Instantiates a new PBRMaterial instance.
  110600. *
  110601. * @param name The material name
  110602. * @param scene The scene the material will be use in.
  110603. */
  110604. constructor(name: string, scene: Scene);
  110605. /**
  110606. * Returns the name of this material class.
  110607. */
  110608. getClassName(): string;
  110609. /**
  110610. * Makes a duplicate of the current material.
  110611. * @param name - name to use for the new material.
  110612. */
  110613. clone(name: string): PBRMaterial;
  110614. /**
  110615. * Serializes this PBR Material.
  110616. * @returns - An object with the serialized material.
  110617. */
  110618. serialize(): any;
  110619. /**
  110620. * Parses a PBR Material from a serialized object.
  110621. * @param source - Serialized object.
  110622. * @param scene - BJS scene instance.
  110623. * @param rootUrl - url for the scene object
  110624. * @returns - PBRMaterial
  110625. */
  110626. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  110627. }
  110628. }
  110629. declare module BABYLON {
  110630. /**
  110631. * Direct draw surface info
  110632. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  110633. */
  110634. export interface DDSInfo {
  110635. /**
  110636. * Width of the texture
  110637. */
  110638. width: number;
  110639. /**
  110640. * Width of the texture
  110641. */
  110642. height: number;
  110643. /**
  110644. * Number of Mipmaps for the texture
  110645. * @see https://en.wikipedia.org/wiki/Mipmap
  110646. */
  110647. mipmapCount: number;
  110648. /**
  110649. * If the textures format is a known fourCC format
  110650. * @see https://www.fourcc.org/
  110651. */
  110652. isFourCC: boolean;
  110653. /**
  110654. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  110655. */
  110656. isRGB: boolean;
  110657. /**
  110658. * If the texture is a lumincance format
  110659. */
  110660. isLuminance: boolean;
  110661. /**
  110662. * If this is a cube texture
  110663. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  110664. */
  110665. isCube: boolean;
  110666. /**
  110667. * If the texture is a compressed format eg. FOURCC_DXT1
  110668. */
  110669. isCompressed: boolean;
  110670. /**
  110671. * The dxgiFormat of the texture
  110672. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  110673. */
  110674. dxgiFormat: number;
  110675. /**
  110676. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  110677. */
  110678. textureType: number;
  110679. /**
  110680. * Sphericle polynomial created for the dds texture
  110681. */
  110682. sphericalPolynomial?: SphericalPolynomial;
  110683. }
  110684. /**
  110685. * Class used to provide DDS decompression tools
  110686. */
  110687. export class DDSTools {
  110688. /**
  110689. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  110690. */
  110691. static StoreLODInAlphaChannel: boolean;
  110692. /**
  110693. * Gets DDS information from an array buffer
  110694. * @param arrayBuffer defines the array buffer to read data from
  110695. * @returns the DDS information
  110696. */
  110697. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  110698. private static _FloatView;
  110699. private static _Int32View;
  110700. private static _ToHalfFloat;
  110701. private static _FromHalfFloat;
  110702. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  110703. private static _GetHalfFloatRGBAArrayBuffer;
  110704. private static _GetFloatRGBAArrayBuffer;
  110705. private static _GetFloatAsUIntRGBAArrayBuffer;
  110706. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  110707. private static _GetRGBAArrayBuffer;
  110708. private static _ExtractLongWordOrder;
  110709. private static _GetRGBArrayBuffer;
  110710. private static _GetLuminanceArrayBuffer;
  110711. /**
  110712. * Uploads DDS Levels to a Babylon Texture
  110713. * @hidden
  110714. */
  110715. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  110716. }
  110717. interface Engine {
  110718. /**
  110719. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  110720. * @param rootUrl defines the url where the file to load is located
  110721. * @param scene defines the current scene
  110722. * @param lodScale defines scale to apply to the mip map selection
  110723. * @param lodOffset defines offset to apply to the mip map selection
  110724. * @param onLoad defines an optional callback raised when the texture is loaded
  110725. * @param onError defines an optional callback raised if there is an issue to load the texture
  110726. * @param format defines the format of the data
  110727. * @param forcedExtension defines the extension to use to pick the right loader
  110728. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  110729. * @returns the cube texture as an InternalTexture
  110730. */
  110731. 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;
  110732. }
  110733. }
  110734. declare module BABYLON {
  110735. /**
  110736. * Implementation of the DDS Texture Loader.
  110737. * @hidden
  110738. */
  110739. export class _DDSTextureLoader implements IInternalTextureLoader {
  110740. /**
  110741. * Defines wether the loader supports cascade loading the different faces.
  110742. */
  110743. readonly supportCascades: boolean;
  110744. /**
  110745. * This returns if the loader support the current file information.
  110746. * @param extension defines the file extension of the file being loaded
  110747. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110748. * @param fallback defines the fallback internal texture if any
  110749. * @param isBase64 defines whether the texture is encoded as a base64
  110750. * @param isBuffer defines whether the texture data are stored as a buffer
  110751. * @returns true if the loader can load the specified file
  110752. */
  110753. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110754. /**
  110755. * Transform the url before loading if required.
  110756. * @param rootUrl the url of the texture
  110757. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110758. * @returns the transformed texture
  110759. */
  110760. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110761. /**
  110762. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110763. * @param rootUrl the url of the texture
  110764. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110765. * @returns the fallback texture
  110766. */
  110767. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110768. /**
  110769. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110770. * @param data contains the texture data
  110771. * @param texture defines the BabylonJS internal texture
  110772. * @param createPolynomials will be true if polynomials have been requested
  110773. * @param onLoad defines the callback to trigger once the texture is ready
  110774. * @param onError defines the callback to trigger in case of error
  110775. */
  110776. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110777. /**
  110778. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110779. * @param data contains the texture data
  110780. * @param texture defines the BabylonJS internal texture
  110781. * @param callback defines the method to call once ready to upload
  110782. */
  110783. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  110784. }
  110785. }
  110786. declare module BABYLON {
  110787. /** @hidden */
  110788. export var rgbdEncodePixelShader: {
  110789. name: string;
  110790. shader: string;
  110791. };
  110792. }
  110793. declare module BABYLON {
  110794. /**
  110795. * Raw texture data and descriptor sufficient for WebGL texture upload
  110796. */
  110797. export interface EnvironmentTextureInfo {
  110798. /**
  110799. * Version of the environment map
  110800. */
  110801. version: number;
  110802. /**
  110803. * Width of image
  110804. */
  110805. width: number;
  110806. /**
  110807. * Irradiance information stored in the file.
  110808. */
  110809. irradiance: any;
  110810. /**
  110811. * Specular information stored in the file.
  110812. */
  110813. specular: any;
  110814. }
  110815. /**
  110816. * Sets of helpers addressing the serialization and deserialization of environment texture
  110817. * stored in a BabylonJS env file.
  110818. * Those files are usually stored as .env files.
  110819. */
  110820. export class EnvironmentTextureTools {
  110821. /**
  110822. * Magic number identifying the env file.
  110823. */
  110824. private static _MagicBytes;
  110825. /**
  110826. * Gets the environment info from an env file.
  110827. * @param data The array buffer containing the .env bytes.
  110828. * @returns the environment file info (the json header) if successfully parsed.
  110829. */
  110830. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  110831. /**
  110832. * Creates an environment texture from a loaded cube texture.
  110833. * @param texture defines the cube texture to convert in env file
  110834. * @return a promise containing the environment data if succesfull.
  110835. */
  110836. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  110837. /**
  110838. * Creates a JSON representation of the spherical data.
  110839. * @param texture defines the texture containing the polynomials
  110840. * @return the JSON representation of the spherical info
  110841. */
  110842. private static _CreateEnvTextureIrradiance;
  110843. /**
  110844. * Uploads the texture info contained in the env file to the GPU.
  110845. * @param texture defines the internal texture to upload to
  110846. * @param arrayBuffer defines the buffer cotaining the data to load
  110847. * @param info defines the texture info retrieved through the GetEnvInfo method
  110848. * @returns a promise
  110849. */
  110850. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  110851. /**
  110852. * Uploads the levels of image data to the GPU.
  110853. * @param texture defines the internal texture to upload to
  110854. * @param imageData defines the array buffer views of image data [mipmap][face]
  110855. * @returns a promise
  110856. */
  110857. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  110858. /**
  110859. * Uploads spherical polynomials information to the texture.
  110860. * @param texture defines the texture we are trying to upload the information to
  110861. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  110862. */
  110863. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  110864. /** @hidden */
  110865. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  110866. }
  110867. }
  110868. declare module BABYLON {
  110869. /**
  110870. * Implementation of the ENV Texture Loader.
  110871. * @hidden
  110872. */
  110873. export class _ENVTextureLoader implements IInternalTextureLoader {
  110874. /**
  110875. * Defines wether the loader supports cascade loading the different faces.
  110876. */
  110877. readonly supportCascades: boolean;
  110878. /**
  110879. * This returns if the loader support the current file information.
  110880. * @param extension defines the file extension of the file being loaded
  110881. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110882. * @param fallback defines the fallback internal texture if any
  110883. * @param isBase64 defines whether the texture is encoded as a base64
  110884. * @param isBuffer defines whether the texture data are stored as a buffer
  110885. * @returns true if the loader can load the specified file
  110886. */
  110887. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110888. /**
  110889. * Transform the url before loading if required.
  110890. * @param rootUrl the url of the texture
  110891. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110892. * @returns the transformed texture
  110893. */
  110894. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110895. /**
  110896. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110897. * @param rootUrl the url of the texture
  110898. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110899. * @returns the fallback texture
  110900. */
  110901. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110902. /**
  110903. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110904. * @param data contains the texture data
  110905. * @param texture defines the BabylonJS internal texture
  110906. * @param createPolynomials will be true if polynomials have been requested
  110907. * @param onLoad defines the callback to trigger once the texture is ready
  110908. * @param onError defines the callback to trigger in case of error
  110909. */
  110910. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110911. /**
  110912. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110913. * @param data contains the texture data
  110914. * @param texture defines the BabylonJS internal texture
  110915. * @param callback defines the method to call once ready to upload
  110916. */
  110917. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  110918. }
  110919. }
  110920. declare module BABYLON {
  110921. /**
  110922. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  110923. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  110924. */
  110925. export class KhronosTextureContainer {
  110926. /** contents of the KTX container file */
  110927. arrayBuffer: any;
  110928. private static HEADER_LEN;
  110929. private static COMPRESSED_2D;
  110930. private static COMPRESSED_3D;
  110931. private static TEX_2D;
  110932. private static TEX_3D;
  110933. /**
  110934. * Gets the openGL type
  110935. */
  110936. glType: number;
  110937. /**
  110938. * Gets the openGL type size
  110939. */
  110940. glTypeSize: number;
  110941. /**
  110942. * Gets the openGL format
  110943. */
  110944. glFormat: number;
  110945. /**
  110946. * Gets the openGL internal format
  110947. */
  110948. glInternalFormat: number;
  110949. /**
  110950. * Gets the base internal format
  110951. */
  110952. glBaseInternalFormat: number;
  110953. /**
  110954. * Gets image width in pixel
  110955. */
  110956. pixelWidth: number;
  110957. /**
  110958. * Gets image height in pixel
  110959. */
  110960. pixelHeight: number;
  110961. /**
  110962. * Gets image depth in pixels
  110963. */
  110964. pixelDepth: number;
  110965. /**
  110966. * Gets the number of array elements
  110967. */
  110968. numberOfArrayElements: number;
  110969. /**
  110970. * Gets the number of faces
  110971. */
  110972. numberOfFaces: number;
  110973. /**
  110974. * Gets the number of mipmap levels
  110975. */
  110976. numberOfMipmapLevels: number;
  110977. /**
  110978. * Gets the bytes of key value data
  110979. */
  110980. bytesOfKeyValueData: number;
  110981. /**
  110982. * Gets the load type
  110983. */
  110984. loadType: number;
  110985. /**
  110986. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  110987. */
  110988. isInvalid: boolean;
  110989. /**
  110990. * Creates a new KhronosTextureContainer
  110991. * @param arrayBuffer contents of the KTX container file
  110992. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  110993. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  110994. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  110995. */
  110996. constructor(
  110997. /** contents of the KTX container file */
  110998. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  110999. /**
  111000. * Uploads KTX content to a Babylon Texture.
  111001. * It is assumed that the texture has already been created & is currently bound
  111002. * @hidden
  111003. */
  111004. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  111005. private _upload2DCompressedLevels;
  111006. }
  111007. }
  111008. declare module BABYLON {
  111009. /**
  111010. * Implementation of the KTX Texture Loader.
  111011. * @hidden
  111012. */
  111013. export class _KTXTextureLoader implements IInternalTextureLoader {
  111014. /**
  111015. * Defines wether the loader supports cascade loading the different faces.
  111016. */
  111017. readonly supportCascades: boolean;
  111018. /**
  111019. * This returns if the loader support the current file information.
  111020. * @param extension defines the file extension of the file being loaded
  111021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111022. * @param fallback defines the fallback internal texture if any
  111023. * @param isBase64 defines whether the texture is encoded as a base64
  111024. * @param isBuffer defines whether the texture data are stored as a buffer
  111025. * @returns true if the loader can load the specified file
  111026. */
  111027. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111028. /**
  111029. * Transform the url before loading if required.
  111030. * @param rootUrl the url of the texture
  111031. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111032. * @returns the transformed texture
  111033. */
  111034. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111035. /**
  111036. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111037. * @param rootUrl the url of the texture
  111038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111039. * @returns the fallback texture
  111040. */
  111041. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111042. /**
  111043. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111044. * @param data contains the texture data
  111045. * @param texture defines the BabylonJS internal texture
  111046. * @param createPolynomials will be true if polynomials have been requested
  111047. * @param onLoad defines the callback to trigger once the texture is ready
  111048. * @param onError defines the callback to trigger in case of error
  111049. */
  111050. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111051. /**
  111052. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111053. * @param data contains the texture data
  111054. * @param texture defines the BabylonJS internal texture
  111055. * @param callback defines the method to call once ready to upload
  111056. */
  111057. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  111058. }
  111059. }
  111060. declare module BABYLON {
  111061. /**
  111062. * Options for the default xr helper
  111063. */
  111064. export class WebXRDefaultExperienceOptions {
  111065. /**
  111066. * Floor meshes that should be used for teleporting
  111067. */
  111068. floorMeshes: Array<AbstractMesh>;
  111069. }
  111070. /**
  111071. * Default experience which provides a similar setup to the previous webVRExperience
  111072. */
  111073. export class WebXRDefaultExperience {
  111074. /**
  111075. * Base experience
  111076. */
  111077. baseExperience: WebXRExperienceHelper;
  111078. /**
  111079. * Input experience extension
  111080. */
  111081. input: WebXRInput;
  111082. /**
  111083. * Loads the controller models
  111084. */
  111085. controllerModelLoader: WebXRControllerModelLoader;
  111086. /**
  111087. * Enables laser pointer and selection
  111088. */
  111089. pointerSelection: WebXRControllerPointerSelection;
  111090. /**
  111091. * Enables teleportation
  111092. */
  111093. teleportation: WebXRControllerTeleportation;
  111094. /**
  111095. * Enables ui for enetering/exiting xr
  111096. */
  111097. enterExitUI: WebXREnterExitUI;
  111098. /**
  111099. * Default output canvas xr should render to
  111100. */
  111101. outputCanvas: WebXRManagedOutputCanvas;
  111102. /**
  111103. * Creates the default xr experience
  111104. * @param scene scene
  111105. * @param options options for basic configuration
  111106. * @returns resulting WebXRDefaultExperience
  111107. */
  111108. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111109. private constructor();
  111110. /**
  111111. * DIsposes of the experience helper
  111112. */
  111113. dispose(): void;
  111114. }
  111115. }
  111116. declare module BABYLON {
  111117. /** @hidden */
  111118. export var _forceSceneHelpersToBundle: boolean;
  111119. interface Scene {
  111120. /**
  111121. * Creates a default light for the scene.
  111122. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  111123. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  111124. */
  111125. createDefaultLight(replace?: boolean): void;
  111126. /**
  111127. * Creates a default camera for the scene.
  111128. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  111129. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111130. * @param replace has default false, when true replaces the active camera in the scene
  111131. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  111132. */
  111133. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111134. /**
  111135. * Creates a default camera and a default light.
  111136. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  111137. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111138. * @param replace has the default false, when true replaces the active camera/light in the scene
  111139. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  111140. */
  111141. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111142. /**
  111143. * Creates a new sky box
  111144. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  111145. * @param environmentTexture defines the texture to use as environment texture
  111146. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  111147. * @param scale defines the overall scale of the skybox
  111148. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  111149. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  111150. * @returns a new mesh holding the sky box
  111151. */
  111152. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  111153. /**
  111154. * Creates a new environment
  111155. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  111156. * @param options defines the options you can use to configure the environment
  111157. * @returns the new EnvironmentHelper
  111158. */
  111159. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  111160. /**
  111161. * Creates a new VREXperienceHelper
  111162. * @see http://doc.babylonjs.com/how_to/webvr_helper
  111163. * @param webVROptions defines the options used to create the new VREXperienceHelper
  111164. * @returns a new VREXperienceHelper
  111165. */
  111166. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  111167. /**
  111168. * Creates a new WebXRDefaultExperience
  111169. * @see http://doc.babylonjs.com/how_to/webxr
  111170. * @param options experience options
  111171. * @returns a promise for a new WebXRDefaultExperience
  111172. */
  111173. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111174. }
  111175. }
  111176. declare module BABYLON {
  111177. /**
  111178. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  111179. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  111180. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  111181. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111182. */
  111183. export class VideoDome extends TransformNode {
  111184. /**
  111185. * Define the video source as a Monoscopic panoramic 360 video.
  111186. */
  111187. static readonly MODE_MONOSCOPIC: number;
  111188. /**
  111189. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111190. */
  111191. static readonly MODE_TOPBOTTOM: number;
  111192. /**
  111193. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111194. */
  111195. static readonly MODE_SIDEBYSIDE: number;
  111196. private _useDirectMapping;
  111197. /**
  111198. * The video texture being displayed on the sphere
  111199. */
  111200. protected _videoTexture: VideoTexture;
  111201. /**
  111202. * Gets the video texture being displayed on the sphere
  111203. */
  111204. readonly videoTexture: VideoTexture;
  111205. /**
  111206. * The skybox material
  111207. */
  111208. protected _material: BackgroundMaterial;
  111209. /**
  111210. * The surface used for the skybox
  111211. */
  111212. protected _mesh: Mesh;
  111213. /**
  111214. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111215. * Also see the options.resolution property.
  111216. */
  111217. fovMultiplier: number;
  111218. private _videoMode;
  111219. /**
  111220. * Gets or set the current video mode for the video. It can be:
  111221. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  111222. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111223. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111224. */
  111225. videoMode: number;
  111226. /**
  111227. * Oberserver used in Stereoscopic VR Mode.
  111228. */
  111229. private _onBeforeCameraRenderObserver;
  111230. /**
  111231. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  111232. * @param name Element's name, child elements will append suffixes for their own names.
  111233. * @param urlsOrVideo defines the url(s) or the video element to use
  111234. * @param options An object containing optional or exposed sub element properties
  111235. */
  111236. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  111237. resolution?: number;
  111238. clickToPlay?: boolean;
  111239. autoPlay?: boolean;
  111240. loop?: boolean;
  111241. size?: number;
  111242. poster?: string;
  111243. faceForward?: boolean;
  111244. useDirectMapping?: boolean;
  111245. }, scene: Scene);
  111246. private _changeVideoMode;
  111247. /**
  111248. * Releases resources associated with this node.
  111249. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111250. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111251. */
  111252. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111253. }
  111254. }
  111255. declare module BABYLON {
  111256. /**
  111257. * This class can be used to get instrumentation data from a Babylon engine
  111258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111259. */
  111260. export class EngineInstrumentation implements IDisposable {
  111261. /**
  111262. * Define the instrumented engine.
  111263. */
  111264. engine: Engine;
  111265. private _captureGPUFrameTime;
  111266. private _gpuFrameTimeToken;
  111267. private _gpuFrameTime;
  111268. private _captureShaderCompilationTime;
  111269. private _shaderCompilationTime;
  111270. private _onBeginFrameObserver;
  111271. private _onEndFrameObserver;
  111272. private _onBeforeShaderCompilationObserver;
  111273. private _onAfterShaderCompilationObserver;
  111274. /**
  111275. * Gets the perf counter used for GPU frame time
  111276. */
  111277. readonly gpuFrameTimeCounter: PerfCounter;
  111278. /**
  111279. * Gets the GPU frame time capture status
  111280. */
  111281. /**
  111282. * Enable or disable the GPU frame time capture
  111283. */
  111284. captureGPUFrameTime: boolean;
  111285. /**
  111286. * Gets the perf counter used for shader compilation time
  111287. */
  111288. readonly shaderCompilationTimeCounter: PerfCounter;
  111289. /**
  111290. * Gets the shader compilation time capture status
  111291. */
  111292. /**
  111293. * Enable or disable the shader compilation time capture
  111294. */
  111295. captureShaderCompilationTime: boolean;
  111296. /**
  111297. * Instantiates a new engine instrumentation.
  111298. * This class can be used to get instrumentation data from a Babylon engine
  111299. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111300. * @param engine Defines the engine to instrument
  111301. */
  111302. constructor(
  111303. /**
  111304. * Define the instrumented engine.
  111305. */
  111306. engine: Engine);
  111307. /**
  111308. * Dispose and release associated resources.
  111309. */
  111310. dispose(): void;
  111311. }
  111312. }
  111313. declare module BABYLON {
  111314. /**
  111315. * This class can be used to get instrumentation data from a Babylon engine
  111316. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111317. */
  111318. export class SceneInstrumentation implements IDisposable {
  111319. /**
  111320. * Defines the scene to instrument
  111321. */
  111322. scene: Scene;
  111323. private _captureActiveMeshesEvaluationTime;
  111324. private _activeMeshesEvaluationTime;
  111325. private _captureRenderTargetsRenderTime;
  111326. private _renderTargetsRenderTime;
  111327. private _captureFrameTime;
  111328. private _frameTime;
  111329. private _captureRenderTime;
  111330. private _renderTime;
  111331. private _captureInterFrameTime;
  111332. private _interFrameTime;
  111333. private _captureParticlesRenderTime;
  111334. private _particlesRenderTime;
  111335. private _captureSpritesRenderTime;
  111336. private _spritesRenderTime;
  111337. private _capturePhysicsTime;
  111338. private _physicsTime;
  111339. private _captureAnimationsTime;
  111340. private _animationsTime;
  111341. private _captureCameraRenderTime;
  111342. private _cameraRenderTime;
  111343. private _onBeforeActiveMeshesEvaluationObserver;
  111344. private _onAfterActiveMeshesEvaluationObserver;
  111345. private _onBeforeRenderTargetsRenderObserver;
  111346. private _onAfterRenderTargetsRenderObserver;
  111347. private _onAfterRenderObserver;
  111348. private _onBeforeDrawPhaseObserver;
  111349. private _onAfterDrawPhaseObserver;
  111350. private _onBeforeAnimationsObserver;
  111351. private _onBeforeParticlesRenderingObserver;
  111352. private _onAfterParticlesRenderingObserver;
  111353. private _onBeforeSpritesRenderingObserver;
  111354. private _onAfterSpritesRenderingObserver;
  111355. private _onBeforePhysicsObserver;
  111356. private _onAfterPhysicsObserver;
  111357. private _onAfterAnimationsObserver;
  111358. private _onBeforeCameraRenderObserver;
  111359. private _onAfterCameraRenderObserver;
  111360. /**
  111361. * Gets the perf counter used for active meshes evaluation time
  111362. */
  111363. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  111364. /**
  111365. * Gets the active meshes evaluation time capture status
  111366. */
  111367. /**
  111368. * Enable or disable the active meshes evaluation time capture
  111369. */
  111370. captureActiveMeshesEvaluationTime: boolean;
  111371. /**
  111372. * Gets the perf counter used for render targets render time
  111373. */
  111374. readonly renderTargetsRenderTimeCounter: PerfCounter;
  111375. /**
  111376. * Gets the render targets render time capture status
  111377. */
  111378. /**
  111379. * Enable or disable the render targets render time capture
  111380. */
  111381. captureRenderTargetsRenderTime: boolean;
  111382. /**
  111383. * Gets the perf counter used for particles render time
  111384. */
  111385. readonly particlesRenderTimeCounter: PerfCounter;
  111386. /**
  111387. * Gets the particles render time capture status
  111388. */
  111389. /**
  111390. * Enable or disable the particles render time capture
  111391. */
  111392. captureParticlesRenderTime: boolean;
  111393. /**
  111394. * Gets the perf counter used for sprites render time
  111395. */
  111396. readonly spritesRenderTimeCounter: PerfCounter;
  111397. /**
  111398. * Gets the sprites render time capture status
  111399. */
  111400. /**
  111401. * Enable or disable the sprites render time capture
  111402. */
  111403. captureSpritesRenderTime: boolean;
  111404. /**
  111405. * Gets the perf counter used for physics time
  111406. */
  111407. readonly physicsTimeCounter: PerfCounter;
  111408. /**
  111409. * Gets the physics time capture status
  111410. */
  111411. /**
  111412. * Enable or disable the physics time capture
  111413. */
  111414. capturePhysicsTime: boolean;
  111415. /**
  111416. * Gets the perf counter used for animations time
  111417. */
  111418. readonly animationsTimeCounter: PerfCounter;
  111419. /**
  111420. * Gets the animations time capture status
  111421. */
  111422. /**
  111423. * Enable or disable the animations time capture
  111424. */
  111425. captureAnimationsTime: boolean;
  111426. /**
  111427. * Gets the perf counter used for frame time capture
  111428. */
  111429. readonly frameTimeCounter: PerfCounter;
  111430. /**
  111431. * Gets the frame time capture status
  111432. */
  111433. /**
  111434. * Enable or disable the frame time capture
  111435. */
  111436. captureFrameTime: boolean;
  111437. /**
  111438. * Gets the perf counter used for inter-frames time capture
  111439. */
  111440. readonly interFrameTimeCounter: PerfCounter;
  111441. /**
  111442. * Gets the inter-frames time capture status
  111443. */
  111444. /**
  111445. * Enable or disable the inter-frames time capture
  111446. */
  111447. captureInterFrameTime: boolean;
  111448. /**
  111449. * Gets the perf counter used for render time capture
  111450. */
  111451. readonly renderTimeCounter: PerfCounter;
  111452. /**
  111453. * Gets the render time capture status
  111454. */
  111455. /**
  111456. * Enable or disable the render time capture
  111457. */
  111458. captureRenderTime: boolean;
  111459. /**
  111460. * Gets the perf counter used for camera render time capture
  111461. */
  111462. readonly cameraRenderTimeCounter: PerfCounter;
  111463. /**
  111464. * Gets the camera render time capture status
  111465. */
  111466. /**
  111467. * Enable or disable the camera render time capture
  111468. */
  111469. captureCameraRenderTime: boolean;
  111470. /**
  111471. * Gets the perf counter used for draw calls
  111472. */
  111473. readonly drawCallsCounter: PerfCounter;
  111474. /**
  111475. * Instantiates a new scene instrumentation.
  111476. * This class can be used to get instrumentation data from a Babylon engine
  111477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111478. * @param scene Defines the scene to instrument
  111479. */
  111480. constructor(
  111481. /**
  111482. * Defines the scene to instrument
  111483. */
  111484. scene: Scene);
  111485. /**
  111486. * Dispose and release associated resources.
  111487. */
  111488. dispose(): void;
  111489. }
  111490. }
  111491. declare module BABYLON {
  111492. /** @hidden */
  111493. export var glowMapGenerationPixelShader: {
  111494. name: string;
  111495. shader: string;
  111496. };
  111497. }
  111498. declare module BABYLON {
  111499. /** @hidden */
  111500. export var glowMapGenerationVertexShader: {
  111501. name: string;
  111502. shader: string;
  111503. };
  111504. }
  111505. declare module BABYLON {
  111506. /**
  111507. * Effect layer options. This helps customizing the behaviour
  111508. * of the effect layer.
  111509. */
  111510. export interface IEffectLayerOptions {
  111511. /**
  111512. * Multiplication factor apply to the canvas size to compute the render target size
  111513. * used to generated the objects (the smaller the faster).
  111514. */
  111515. mainTextureRatio: number;
  111516. /**
  111517. * Enforces a fixed size texture to ensure effect stability across devices.
  111518. */
  111519. mainTextureFixedSize?: number;
  111520. /**
  111521. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  111522. */
  111523. alphaBlendingMode: number;
  111524. /**
  111525. * The camera attached to the layer.
  111526. */
  111527. camera: Nullable<Camera>;
  111528. /**
  111529. * The rendering group to draw the layer in.
  111530. */
  111531. renderingGroupId: number;
  111532. }
  111533. /**
  111534. * The effect layer Helps adding post process effect blended with the main pass.
  111535. *
  111536. * This can be for instance use to generate glow or higlight effects on the scene.
  111537. *
  111538. * The effect layer class can not be used directly and is intented to inherited from to be
  111539. * customized per effects.
  111540. */
  111541. export abstract class EffectLayer {
  111542. private _vertexBuffers;
  111543. private _indexBuffer;
  111544. private _cachedDefines;
  111545. private _effectLayerMapGenerationEffect;
  111546. private _effectLayerOptions;
  111547. private _mergeEffect;
  111548. protected _scene: Scene;
  111549. protected _engine: Engine;
  111550. protected _maxSize: number;
  111551. protected _mainTextureDesiredSize: ISize;
  111552. protected _mainTexture: RenderTargetTexture;
  111553. protected _shouldRender: boolean;
  111554. protected _postProcesses: PostProcess[];
  111555. protected _textures: BaseTexture[];
  111556. protected _emissiveTextureAndColor: {
  111557. texture: Nullable<BaseTexture>;
  111558. color: Color4;
  111559. };
  111560. /**
  111561. * The name of the layer
  111562. */
  111563. name: string;
  111564. /**
  111565. * The clear color of the texture used to generate the glow map.
  111566. */
  111567. neutralColor: Color4;
  111568. /**
  111569. * Specifies wether the highlight layer is enabled or not.
  111570. */
  111571. isEnabled: boolean;
  111572. /**
  111573. * Gets the camera attached to the layer.
  111574. */
  111575. readonly camera: Nullable<Camera>;
  111576. /**
  111577. * Gets the rendering group id the layer should render in.
  111578. */
  111579. renderingGroupId: number;
  111580. /**
  111581. * An event triggered when the effect layer has been disposed.
  111582. */
  111583. onDisposeObservable: Observable<EffectLayer>;
  111584. /**
  111585. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  111586. */
  111587. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  111588. /**
  111589. * An event triggered when the generated texture is being merged in the scene.
  111590. */
  111591. onBeforeComposeObservable: Observable<EffectLayer>;
  111592. /**
  111593. * An event triggered when the generated texture has been merged in the scene.
  111594. */
  111595. onAfterComposeObservable: Observable<EffectLayer>;
  111596. /**
  111597. * An event triggered when the efffect layer changes its size.
  111598. */
  111599. onSizeChangedObservable: Observable<EffectLayer>;
  111600. /** @hidden */
  111601. static _SceneComponentInitialization: (scene: Scene) => void;
  111602. /**
  111603. * Instantiates a new effect Layer and references it in the scene.
  111604. * @param name The name of the layer
  111605. * @param scene The scene to use the layer in
  111606. */
  111607. constructor(
  111608. /** The Friendly of the effect in the scene */
  111609. name: string, scene: Scene);
  111610. /**
  111611. * Get the effect name of the layer.
  111612. * @return The effect name
  111613. */
  111614. abstract getEffectName(): string;
  111615. /**
  111616. * Checks for the readiness of the element composing the layer.
  111617. * @param subMesh the mesh to check for
  111618. * @param useInstances specify wether or not to use instances to render the mesh
  111619. * @return true if ready otherwise, false
  111620. */
  111621. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111622. /**
  111623. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111624. * @returns true if the effect requires stencil during the main canvas render pass.
  111625. */
  111626. abstract needStencil(): boolean;
  111627. /**
  111628. * Create the merge effect. This is the shader use to blit the information back
  111629. * to the main canvas at the end of the scene rendering.
  111630. * @returns The effect containing the shader used to merge the effect on the main canvas
  111631. */
  111632. protected abstract _createMergeEffect(): Effect;
  111633. /**
  111634. * Creates the render target textures and post processes used in the effect layer.
  111635. */
  111636. protected abstract _createTextureAndPostProcesses(): void;
  111637. /**
  111638. * Implementation specific of rendering the generating effect on the main canvas.
  111639. * @param effect The effect used to render through
  111640. */
  111641. protected abstract _internalRender(effect: Effect): void;
  111642. /**
  111643. * Sets the required values for both the emissive texture and and the main color.
  111644. */
  111645. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111646. /**
  111647. * Free any resources and references associated to a mesh.
  111648. * Internal use
  111649. * @param mesh The mesh to free.
  111650. */
  111651. abstract _disposeMesh(mesh: Mesh): void;
  111652. /**
  111653. * Serializes this layer (Glow or Highlight for example)
  111654. * @returns a serialized layer object
  111655. */
  111656. abstract serialize?(): any;
  111657. /**
  111658. * Initializes the effect layer with the required options.
  111659. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  111660. */
  111661. protected _init(options: Partial<IEffectLayerOptions>): void;
  111662. /**
  111663. * Generates the index buffer of the full screen quad blending to the main canvas.
  111664. */
  111665. private _generateIndexBuffer;
  111666. /**
  111667. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  111668. */
  111669. private _generateVertexBuffer;
  111670. /**
  111671. * Sets the main texture desired size which is the closest power of two
  111672. * of the engine canvas size.
  111673. */
  111674. private _setMainTextureSize;
  111675. /**
  111676. * Creates the main texture for the effect layer.
  111677. */
  111678. protected _createMainTexture(): void;
  111679. /**
  111680. * Adds specific effects defines.
  111681. * @param defines The defines to add specifics to.
  111682. */
  111683. protected _addCustomEffectDefines(defines: string[]): void;
  111684. /**
  111685. * Checks for the readiness of the element composing the layer.
  111686. * @param subMesh the mesh to check for
  111687. * @param useInstances specify wether or not to use instances to render the mesh
  111688. * @param emissiveTexture the associated emissive texture used to generate the glow
  111689. * @return true if ready otherwise, false
  111690. */
  111691. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  111692. /**
  111693. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  111694. */
  111695. render(): void;
  111696. /**
  111697. * Determine if a given mesh will be used in the current effect.
  111698. * @param mesh mesh to test
  111699. * @returns true if the mesh will be used
  111700. */
  111701. hasMesh(mesh: AbstractMesh): boolean;
  111702. /**
  111703. * Returns true if the layer contains information to display, otherwise false.
  111704. * @returns true if the glow layer should be rendered
  111705. */
  111706. shouldRender(): boolean;
  111707. /**
  111708. * Returns true if the mesh should render, otherwise false.
  111709. * @param mesh The mesh to render
  111710. * @returns true if it should render otherwise false
  111711. */
  111712. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  111713. /**
  111714. * Returns true if the mesh can be rendered, otherwise false.
  111715. * @param mesh The mesh to render
  111716. * @param material The material used on the mesh
  111717. * @returns true if it can be rendered otherwise false
  111718. */
  111719. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  111720. /**
  111721. * Returns true if the mesh should render, otherwise false.
  111722. * @param mesh The mesh to render
  111723. * @returns true if it should render otherwise false
  111724. */
  111725. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  111726. /**
  111727. * Renders the submesh passed in parameter to the generation map.
  111728. */
  111729. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  111730. /**
  111731. * Rebuild the required buffers.
  111732. * @hidden Internal use only.
  111733. */
  111734. _rebuild(): void;
  111735. /**
  111736. * Dispose only the render target textures and post process.
  111737. */
  111738. private _disposeTextureAndPostProcesses;
  111739. /**
  111740. * Dispose the highlight layer and free resources.
  111741. */
  111742. dispose(): void;
  111743. /**
  111744. * Gets the class name of the effect layer
  111745. * @returns the string with the class name of the effect layer
  111746. */
  111747. getClassName(): string;
  111748. /**
  111749. * Creates an effect layer from parsed effect layer data
  111750. * @param parsedEffectLayer defines effect layer data
  111751. * @param scene defines the current scene
  111752. * @param rootUrl defines the root URL containing the effect layer information
  111753. * @returns a parsed effect Layer
  111754. */
  111755. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  111756. }
  111757. }
  111758. declare module BABYLON {
  111759. interface AbstractScene {
  111760. /**
  111761. * The list of effect layers (highlights/glow) added to the scene
  111762. * @see http://doc.babylonjs.com/how_to/highlight_layer
  111763. * @see http://doc.babylonjs.com/how_to/glow_layer
  111764. */
  111765. effectLayers: Array<EffectLayer>;
  111766. /**
  111767. * Removes the given effect layer from this scene.
  111768. * @param toRemove defines the effect layer to remove
  111769. * @returns the index of the removed effect layer
  111770. */
  111771. removeEffectLayer(toRemove: EffectLayer): number;
  111772. /**
  111773. * Adds the given effect layer to this scene
  111774. * @param newEffectLayer defines the effect layer to add
  111775. */
  111776. addEffectLayer(newEffectLayer: EffectLayer): void;
  111777. }
  111778. /**
  111779. * Defines the layer scene component responsible to manage any effect layers
  111780. * in a given scene.
  111781. */
  111782. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  111783. /**
  111784. * The component name helpfull to identify the component in the list of scene components.
  111785. */
  111786. readonly name: string;
  111787. /**
  111788. * The scene the component belongs to.
  111789. */
  111790. scene: Scene;
  111791. private _engine;
  111792. private _renderEffects;
  111793. private _needStencil;
  111794. private _previousStencilState;
  111795. /**
  111796. * Creates a new instance of the component for the given scene
  111797. * @param scene Defines the scene to register the component in
  111798. */
  111799. constructor(scene: Scene);
  111800. /**
  111801. * Registers the component in a given scene
  111802. */
  111803. register(): void;
  111804. /**
  111805. * Rebuilds the elements related to this component in case of
  111806. * context lost for instance.
  111807. */
  111808. rebuild(): void;
  111809. /**
  111810. * Serializes the component data to the specified json object
  111811. * @param serializationObject The object to serialize to
  111812. */
  111813. serialize(serializationObject: any): void;
  111814. /**
  111815. * Adds all the elements from the container to the scene
  111816. * @param container the container holding the elements
  111817. */
  111818. addFromContainer(container: AbstractScene): void;
  111819. /**
  111820. * Removes all the elements in the container from the scene
  111821. * @param container contains the elements to remove
  111822. * @param dispose if the removed element should be disposed (default: false)
  111823. */
  111824. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111825. /**
  111826. * Disposes the component and the associated ressources.
  111827. */
  111828. dispose(): void;
  111829. private _isReadyForMesh;
  111830. private _renderMainTexture;
  111831. private _setStencil;
  111832. private _setStencilBack;
  111833. private _draw;
  111834. private _drawCamera;
  111835. private _drawRenderingGroup;
  111836. }
  111837. }
  111838. declare module BABYLON {
  111839. /** @hidden */
  111840. export var glowMapMergePixelShader: {
  111841. name: string;
  111842. shader: string;
  111843. };
  111844. }
  111845. declare module BABYLON {
  111846. /** @hidden */
  111847. export var glowMapMergeVertexShader: {
  111848. name: string;
  111849. shader: string;
  111850. };
  111851. }
  111852. declare module BABYLON {
  111853. interface AbstractScene {
  111854. /**
  111855. * Return a the first highlight layer of the scene with a given name.
  111856. * @param name The name of the highlight layer to look for.
  111857. * @return The highlight layer if found otherwise null.
  111858. */
  111859. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  111860. }
  111861. /**
  111862. * Glow layer options. This helps customizing the behaviour
  111863. * of the glow layer.
  111864. */
  111865. export interface IGlowLayerOptions {
  111866. /**
  111867. * Multiplication factor apply to the canvas size to compute the render target size
  111868. * used to generated the glowing objects (the smaller the faster).
  111869. */
  111870. mainTextureRatio: number;
  111871. /**
  111872. * Enforces a fixed size texture to ensure resize independant blur.
  111873. */
  111874. mainTextureFixedSize?: number;
  111875. /**
  111876. * How big is the kernel of the blur texture.
  111877. */
  111878. blurKernelSize: number;
  111879. /**
  111880. * The camera attached to the layer.
  111881. */
  111882. camera: Nullable<Camera>;
  111883. /**
  111884. * Enable MSAA by chosing the number of samples.
  111885. */
  111886. mainTextureSamples?: number;
  111887. /**
  111888. * The rendering group to draw the layer in.
  111889. */
  111890. renderingGroupId: number;
  111891. }
  111892. /**
  111893. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  111894. *
  111895. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  111896. * glowy meshes to your scene.
  111897. *
  111898. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  111899. */
  111900. export class GlowLayer extends EffectLayer {
  111901. /**
  111902. * Effect Name of the layer.
  111903. */
  111904. static readonly EffectName: string;
  111905. /**
  111906. * The default blur kernel size used for the glow.
  111907. */
  111908. static DefaultBlurKernelSize: number;
  111909. /**
  111910. * The default texture size ratio used for the glow.
  111911. */
  111912. static DefaultTextureRatio: number;
  111913. /**
  111914. * Sets the kernel size of the blur.
  111915. */
  111916. /**
  111917. * Gets the kernel size of the blur.
  111918. */
  111919. blurKernelSize: number;
  111920. /**
  111921. * Sets the glow intensity.
  111922. */
  111923. /**
  111924. * Gets the glow intensity.
  111925. */
  111926. intensity: number;
  111927. private _options;
  111928. private _intensity;
  111929. private _horizontalBlurPostprocess1;
  111930. private _verticalBlurPostprocess1;
  111931. private _horizontalBlurPostprocess2;
  111932. private _verticalBlurPostprocess2;
  111933. private _blurTexture1;
  111934. private _blurTexture2;
  111935. private _postProcesses1;
  111936. private _postProcesses2;
  111937. private _includedOnlyMeshes;
  111938. private _excludedMeshes;
  111939. /**
  111940. * Callback used to let the user override the color selection on a per mesh basis
  111941. */
  111942. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  111943. /**
  111944. * Callback used to let the user override the texture selection on a per mesh basis
  111945. */
  111946. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  111947. /**
  111948. * Instantiates a new glow Layer and references it to the scene.
  111949. * @param name The name of the layer
  111950. * @param scene The scene to use the layer in
  111951. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  111952. */
  111953. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  111954. /**
  111955. * Get the effect name of the layer.
  111956. * @return The effect name
  111957. */
  111958. getEffectName(): string;
  111959. /**
  111960. * Create the merge effect. This is the shader use to blit the information back
  111961. * to the main canvas at the end of the scene rendering.
  111962. */
  111963. protected _createMergeEffect(): Effect;
  111964. /**
  111965. * Creates the render target textures and post processes used in the glow layer.
  111966. */
  111967. protected _createTextureAndPostProcesses(): void;
  111968. /**
  111969. * Checks for the readiness of the element composing the layer.
  111970. * @param subMesh the mesh to check for
  111971. * @param useInstances specify wether or not to use instances to render the mesh
  111972. * @param emissiveTexture the associated emissive texture used to generate the glow
  111973. * @return true if ready otherwise, false
  111974. */
  111975. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111976. /**
  111977. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111978. */
  111979. needStencil(): boolean;
  111980. /**
  111981. * Returns true if the mesh can be rendered, otherwise false.
  111982. * @param mesh The mesh to render
  111983. * @param material The material used on the mesh
  111984. * @returns true if it can be rendered otherwise false
  111985. */
  111986. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  111987. /**
  111988. * Implementation specific of rendering the generating effect on the main canvas.
  111989. * @param effect The effect used to render through
  111990. */
  111991. protected _internalRender(effect: Effect): void;
  111992. /**
  111993. * Sets the required values for both the emissive texture and and the main color.
  111994. */
  111995. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111996. /**
  111997. * Returns true if the mesh should render, otherwise false.
  111998. * @param mesh The mesh to render
  111999. * @returns true if it should render otherwise false
  112000. */
  112001. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112002. /**
  112003. * Adds specific effects defines.
  112004. * @param defines The defines to add specifics to.
  112005. */
  112006. protected _addCustomEffectDefines(defines: string[]): void;
  112007. /**
  112008. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  112009. * @param mesh The mesh to exclude from the glow layer
  112010. */
  112011. addExcludedMesh(mesh: Mesh): void;
  112012. /**
  112013. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  112014. * @param mesh The mesh to remove
  112015. */
  112016. removeExcludedMesh(mesh: Mesh): void;
  112017. /**
  112018. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  112019. * @param mesh The mesh to include in the glow layer
  112020. */
  112021. addIncludedOnlyMesh(mesh: Mesh): void;
  112022. /**
  112023. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  112024. * @param mesh The mesh to remove
  112025. */
  112026. removeIncludedOnlyMesh(mesh: Mesh): void;
  112027. /**
  112028. * Determine if a given mesh will be used in the glow layer
  112029. * @param mesh The mesh to test
  112030. * @returns true if the mesh will be highlighted by the current glow layer
  112031. */
  112032. hasMesh(mesh: AbstractMesh): boolean;
  112033. /**
  112034. * Free any resources and references associated to a mesh.
  112035. * Internal use
  112036. * @param mesh The mesh to free.
  112037. * @hidden
  112038. */
  112039. _disposeMesh(mesh: Mesh): void;
  112040. /**
  112041. * Gets the class name of the effect layer
  112042. * @returns the string with the class name of the effect layer
  112043. */
  112044. getClassName(): string;
  112045. /**
  112046. * Serializes this glow layer
  112047. * @returns a serialized glow layer object
  112048. */
  112049. serialize(): any;
  112050. /**
  112051. * Creates a Glow Layer from parsed glow layer data
  112052. * @param parsedGlowLayer defines glow layer data
  112053. * @param scene defines the current scene
  112054. * @param rootUrl defines the root URL containing the glow layer information
  112055. * @returns a parsed Glow Layer
  112056. */
  112057. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  112058. }
  112059. }
  112060. declare module BABYLON {
  112061. /** @hidden */
  112062. export var glowBlurPostProcessPixelShader: {
  112063. name: string;
  112064. shader: string;
  112065. };
  112066. }
  112067. declare module BABYLON {
  112068. interface AbstractScene {
  112069. /**
  112070. * Return a the first highlight layer of the scene with a given name.
  112071. * @param name The name of the highlight layer to look for.
  112072. * @return The highlight layer if found otherwise null.
  112073. */
  112074. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  112075. }
  112076. /**
  112077. * Highlight layer options. This helps customizing the behaviour
  112078. * of the highlight layer.
  112079. */
  112080. export interface IHighlightLayerOptions {
  112081. /**
  112082. * Multiplication factor apply to the canvas size to compute the render target size
  112083. * used to generated the glowing objects (the smaller the faster).
  112084. */
  112085. mainTextureRatio: number;
  112086. /**
  112087. * Enforces a fixed size texture to ensure resize independant blur.
  112088. */
  112089. mainTextureFixedSize?: number;
  112090. /**
  112091. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  112092. * of the picture to blur (the smaller the faster).
  112093. */
  112094. blurTextureSizeRatio: number;
  112095. /**
  112096. * How big in texel of the blur texture is the vertical blur.
  112097. */
  112098. blurVerticalSize: number;
  112099. /**
  112100. * How big in texel of the blur texture is the horizontal blur.
  112101. */
  112102. blurHorizontalSize: number;
  112103. /**
  112104. * Alpha blending mode used to apply the blur. Default is combine.
  112105. */
  112106. alphaBlendingMode: number;
  112107. /**
  112108. * The camera attached to the layer.
  112109. */
  112110. camera: Nullable<Camera>;
  112111. /**
  112112. * Should we display highlight as a solid stroke?
  112113. */
  112114. isStroke?: boolean;
  112115. /**
  112116. * The rendering group to draw the layer in.
  112117. */
  112118. renderingGroupId: number;
  112119. }
  112120. /**
  112121. * The highlight layer Helps adding a glow effect around a mesh.
  112122. *
  112123. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112124. * glowy meshes to your scene.
  112125. *
  112126. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  112127. */
  112128. export class HighlightLayer extends EffectLayer {
  112129. name: string;
  112130. /**
  112131. * Effect Name of the highlight layer.
  112132. */
  112133. static readonly EffectName: string;
  112134. /**
  112135. * The neutral color used during the preparation of the glow effect.
  112136. * This is black by default as the blend operation is a blend operation.
  112137. */
  112138. static NeutralColor: Color4;
  112139. /**
  112140. * Stencil value used for glowing meshes.
  112141. */
  112142. static GlowingMeshStencilReference: number;
  112143. /**
  112144. * Stencil value used for the other meshes in the scene.
  112145. */
  112146. static NormalMeshStencilReference: number;
  112147. /**
  112148. * Specifies whether or not the inner glow is ACTIVE in the layer.
  112149. */
  112150. innerGlow: boolean;
  112151. /**
  112152. * Specifies whether or not the outer glow is ACTIVE in the layer.
  112153. */
  112154. outerGlow: boolean;
  112155. /**
  112156. * Specifies the horizontal size of the blur.
  112157. */
  112158. /**
  112159. * Gets the horizontal size of the blur.
  112160. */
  112161. blurHorizontalSize: number;
  112162. /**
  112163. * Specifies the vertical size of the blur.
  112164. */
  112165. /**
  112166. * Gets the vertical size of the blur.
  112167. */
  112168. blurVerticalSize: number;
  112169. /**
  112170. * An event triggered when the highlight layer is being blurred.
  112171. */
  112172. onBeforeBlurObservable: Observable<HighlightLayer>;
  112173. /**
  112174. * An event triggered when the highlight layer has been blurred.
  112175. */
  112176. onAfterBlurObservable: Observable<HighlightLayer>;
  112177. private _instanceGlowingMeshStencilReference;
  112178. private _options;
  112179. private _downSamplePostprocess;
  112180. private _horizontalBlurPostprocess;
  112181. private _verticalBlurPostprocess;
  112182. private _blurTexture;
  112183. private _meshes;
  112184. private _excludedMeshes;
  112185. /**
  112186. * Instantiates a new highlight Layer and references it to the scene..
  112187. * @param name The name of the layer
  112188. * @param scene The scene to use the layer in
  112189. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  112190. */
  112191. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  112192. /**
  112193. * Get the effect name of the layer.
  112194. * @return The effect name
  112195. */
  112196. getEffectName(): string;
  112197. /**
  112198. * Create the merge effect. This is the shader use to blit the information back
  112199. * to the main canvas at the end of the scene rendering.
  112200. */
  112201. protected _createMergeEffect(): Effect;
  112202. /**
  112203. * Creates the render target textures and post processes used in the highlight layer.
  112204. */
  112205. protected _createTextureAndPostProcesses(): void;
  112206. /**
  112207. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112208. */
  112209. needStencil(): boolean;
  112210. /**
  112211. * Checks for the readiness of the element composing the layer.
  112212. * @param subMesh the mesh to check for
  112213. * @param useInstances specify wether or not to use instances to render the mesh
  112214. * @param emissiveTexture the associated emissive texture used to generate the glow
  112215. * @return true if ready otherwise, false
  112216. */
  112217. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112218. /**
  112219. * Implementation specific of rendering the generating effect on the main canvas.
  112220. * @param effect The effect used to render through
  112221. */
  112222. protected _internalRender(effect: Effect): void;
  112223. /**
  112224. * Returns true if the layer contains information to display, otherwise false.
  112225. */
  112226. shouldRender(): boolean;
  112227. /**
  112228. * Returns true if the mesh should render, otherwise false.
  112229. * @param mesh The mesh to render
  112230. * @returns true if it should render otherwise false
  112231. */
  112232. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112233. /**
  112234. * Sets the required values for both the emissive texture and and the main color.
  112235. */
  112236. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112237. /**
  112238. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  112239. * @param mesh The mesh to exclude from the highlight layer
  112240. */
  112241. addExcludedMesh(mesh: Mesh): void;
  112242. /**
  112243. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  112244. * @param mesh The mesh to highlight
  112245. */
  112246. removeExcludedMesh(mesh: Mesh): void;
  112247. /**
  112248. * Determine if a given mesh will be highlighted by the current HighlightLayer
  112249. * @param mesh mesh to test
  112250. * @returns true if the mesh will be highlighted by the current HighlightLayer
  112251. */
  112252. hasMesh(mesh: AbstractMesh): boolean;
  112253. /**
  112254. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  112255. * @param mesh The mesh to highlight
  112256. * @param color The color of the highlight
  112257. * @param glowEmissiveOnly Extract the glow from the emissive texture
  112258. */
  112259. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  112260. /**
  112261. * Remove a mesh from the highlight layer in order to make it stop glowing.
  112262. * @param mesh The mesh to highlight
  112263. */
  112264. removeMesh(mesh: Mesh): void;
  112265. /**
  112266. * Force the stencil to the normal expected value for none glowing parts
  112267. */
  112268. private _defaultStencilReference;
  112269. /**
  112270. * Free any resources and references associated to a mesh.
  112271. * Internal use
  112272. * @param mesh The mesh to free.
  112273. * @hidden
  112274. */
  112275. _disposeMesh(mesh: Mesh): void;
  112276. /**
  112277. * Dispose the highlight layer and free resources.
  112278. */
  112279. dispose(): void;
  112280. /**
  112281. * Gets the class name of the effect layer
  112282. * @returns the string with the class name of the effect layer
  112283. */
  112284. getClassName(): string;
  112285. /**
  112286. * Serializes this Highlight layer
  112287. * @returns a serialized Highlight layer object
  112288. */
  112289. serialize(): any;
  112290. /**
  112291. * Creates a Highlight layer from parsed Highlight layer data
  112292. * @param parsedHightlightLayer defines the Highlight layer data
  112293. * @param scene defines the current scene
  112294. * @param rootUrl defines the root URL containing the Highlight layer information
  112295. * @returns a parsed Highlight layer
  112296. */
  112297. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  112298. }
  112299. }
  112300. declare module BABYLON {
  112301. interface AbstractScene {
  112302. /**
  112303. * The list of layers (background and foreground) of the scene
  112304. */
  112305. layers: Array<Layer>;
  112306. }
  112307. /**
  112308. * Defines the layer scene component responsible to manage any layers
  112309. * in a given scene.
  112310. */
  112311. export class LayerSceneComponent implements ISceneComponent {
  112312. /**
  112313. * The component name helpfull to identify the component in the list of scene components.
  112314. */
  112315. readonly name: string;
  112316. /**
  112317. * The scene the component belongs to.
  112318. */
  112319. scene: Scene;
  112320. private _engine;
  112321. /**
  112322. * Creates a new instance of the component for the given scene
  112323. * @param scene Defines the scene to register the component in
  112324. */
  112325. constructor(scene: Scene);
  112326. /**
  112327. * Registers the component in a given scene
  112328. */
  112329. register(): void;
  112330. /**
  112331. * Rebuilds the elements related to this component in case of
  112332. * context lost for instance.
  112333. */
  112334. rebuild(): void;
  112335. /**
  112336. * Disposes the component and the associated ressources.
  112337. */
  112338. dispose(): void;
  112339. private _draw;
  112340. private _drawCameraPredicate;
  112341. private _drawCameraBackground;
  112342. private _drawCameraForeground;
  112343. private _drawRenderTargetPredicate;
  112344. private _drawRenderTargetBackground;
  112345. private _drawRenderTargetForeground;
  112346. /**
  112347. * Adds all the elements from the container to the scene
  112348. * @param container the container holding the elements
  112349. */
  112350. addFromContainer(container: AbstractScene): void;
  112351. /**
  112352. * Removes all the elements in the container from the scene
  112353. * @param container contains the elements to remove
  112354. * @param dispose if the removed element should be disposed (default: false)
  112355. */
  112356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112357. }
  112358. }
  112359. declare module BABYLON {
  112360. /** @hidden */
  112361. export var layerPixelShader: {
  112362. name: string;
  112363. shader: string;
  112364. };
  112365. }
  112366. declare module BABYLON {
  112367. /** @hidden */
  112368. export var layerVertexShader: {
  112369. name: string;
  112370. shader: string;
  112371. };
  112372. }
  112373. declare module BABYLON {
  112374. /**
  112375. * This represents a full screen 2d layer.
  112376. * This can be useful to display a picture in the background of your scene for instance.
  112377. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112378. */
  112379. export class Layer {
  112380. /**
  112381. * Define the name of the layer.
  112382. */
  112383. name: string;
  112384. /**
  112385. * Define the texture the layer should display.
  112386. */
  112387. texture: Nullable<Texture>;
  112388. /**
  112389. * Is the layer in background or foreground.
  112390. */
  112391. isBackground: boolean;
  112392. /**
  112393. * Define the color of the layer (instead of texture).
  112394. */
  112395. color: Color4;
  112396. /**
  112397. * Define the scale of the layer in order to zoom in out of the texture.
  112398. */
  112399. scale: Vector2;
  112400. /**
  112401. * Define an offset for the layer in order to shift the texture.
  112402. */
  112403. offset: Vector2;
  112404. /**
  112405. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  112406. */
  112407. alphaBlendingMode: number;
  112408. /**
  112409. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  112410. * Alpha test will not mix with the background color in case of transparency.
  112411. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  112412. */
  112413. alphaTest: boolean;
  112414. /**
  112415. * Define a mask to restrict the layer to only some of the scene cameras.
  112416. */
  112417. layerMask: number;
  112418. /**
  112419. * Define the list of render target the layer is visible into.
  112420. */
  112421. renderTargetTextures: RenderTargetTexture[];
  112422. /**
  112423. * Define if the layer is only used in renderTarget or if it also
  112424. * renders in the main frame buffer of the canvas.
  112425. */
  112426. renderOnlyInRenderTargetTextures: boolean;
  112427. private _scene;
  112428. private _vertexBuffers;
  112429. private _indexBuffer;
  112430. private _effect;
  112431. private _alphaTestEffect;
  112432. /**
  112433. * An event triggered when the layer is disposed.
  112434. */
  112435. onDisposeObservable: Observable<Layer>;
  112436. private _onDisposeObserver;
  112437. /**
  112438. * Back compatibility with callback before the onDisposeObservable existed.
  112439. * The set callback will be triggered when the layer has been disposed.
  112440. */
  112441. onDispose: () => void;
  112442. /**
  112443. * An event triggered before rendering the scene
  112444. */
  112445. onBeforeRenderObservable: Observable<Layer>;
  112446. private _onBeforeRenderObserver;
  112447. /**
  112448. * Back compatibility with callback before the onBeforeRenderObservable existed.
  112449. * The set callback will be triggered just before rendering the layer.
  112450. */
  112451. onBeforeRender: () => void;
  112452. /**
  112453. * An event triggered after rendering the scene
  112454. */
  112455. onAfterRenderObservable: Observable<Layer>;
  112456. private _onAfterRenderObserver;
  112457. /**
  112458. * Back compatibility with callback before the onAfterRenderObservable existed.
  112459. * The set callback will be triggered just after rendering the layer.
  112460. */
  112461. onAfterRender: () => void;
  112462. /**
  112463. * Instantiates a new layer.
  112464. * This represents a full screen 2d layer.
  112465. * This can be useful to display a picture in the background of your scene for instance.
  112466. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112467. * @param name Define the name of the layer in the scene
  112468. * @param imgUrl Define the url of the texture to display in the layer
  112469. * @param scene Define the scene the layer belongs to
  112470. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  112471. * @param color Defines a color for the layer
  112472. */
  112473. constructor(
  112474. /**
  112475. * Define the name of the layer.
  112476. */
  112477. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  112478. private _createIndexBuffer;
  112479. /** @hidden */
  112480. _rebuild(): void;
  112481. /**
  112482. * Renders the layer in the scene.
  112483. */
  112484. render(): void;
  112485. /**
  112486. * Disposes and releases the associated ressources.
  112487. */
  112488. dispose(): void;
  112489. }
  112490. }
  112491. declare module BABYLON {
  112492. /** @hidden */
  112493. export var lensFlarePixelShader: {
  112494. name: string;
  112495. shader: string;
  112496. };
  112497. }
  112498. declare module BABYLON {
  112499. /** @hidden */
  112500. export var lensFlareVertexShader: {
  112501. name: string;
  112502. shader: string;
  112503. };
  112504. }
  112505. declare module BABYLON {
  112506. /**
  112507. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112508. * It is usually composed of several `lensFlare`.
  112509. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112510. */
  112511. export class LensFlareSystem {
  112512. /**
  112513. * Define the name of the lens flare system
  112514. */
  112515. name: string;
  112516. /**
  112517. * List of lens flares used in this system.
  112518. */
  112519. lensFlares: LensFlare[];
  112520. /**
  112521. * Define a limit from the border the lens flare can be visible.
  112522. */
  112523. borderLimit: number;
  112524. /**
  112525. * Define a viewport border we do not want to see the lens flare in.
  112526. */
  112527. viewportBorder: number;
  112528. /**
  112529. * Define a predicate which could limit the list of meshes able to occlude the effect.
  112530. */
  112531. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112532. /**
  112533. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  112534. */
  112535. layerMask: number;
  112536. /**
  112537. * Define the id of the lens flare system in the scene.
  112538. * (equal to name by default)
  112539. */
  112540. id: string;
  112541. private _scene;
  112542. private _emitter;
  112543. private _vertexBuffers;
  112544. private _indexBuffer;
  112545. private _effect;
  112546. private _positionX;
  112547. private _positionY;
  112548. private _isEnabled;
  112549. /** @hidden */
  112550. static _SceneComponentInitialization: (scene: Scene) => void;
  112551. /**
  112552. * Instantiates a lens flare system.
  112553. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112554. * It is usually composed of several `lensFlare`.
  112555. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112556. * @param name Define the name of the lens flare system in the scene
  112557. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  112558. * @param scene Define the scene the lens flare system belongs to
  112559. */
  112560. constructor(
  112561. /**
  112562. * Define the name of the lens flare system
  112563. */
  112564. name: string, emitter: any, scene: Scene);
  112565. /**
  112566. * Define if the lens flare system is enabled.
  112567. */
  112568. isEnabled: boolean;
  112569. /**
  112570. * Get the scene the effects belongs to.
  112571. * @returns the scene holding the lens flare system
  112572. */
  112573. getScene(): Scene;
  112574. /**
  112575. * Get the emitter of the lens flare system.
  112576. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112577. * @returns the emitter of the lens flare system
  112578. */
  112579. getEmitter(): any;
  112580. /**
  112581. * Set the emitter of the lens flare system.
  112582. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112583. * @param newEmitter Define the new emitter of the system
  112584. */
  112585. setEmitter(newEmitter: any): void;
  112586. /**
  112587. * Get the lens flare system emitter position.
  112588. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  112589. * @returns the position
  112590. */
  112591. getEmitterPosition(): Vector3;
  112592. /**
  112593. * @hidden
  112594. */
  112595. computeEffectivePosition(globalViewport: Viewport): boolean;
  112596. /** @hidden */
  112597. _isVisible(): boolean;
  112598. /**
  112599. * @hidden
  112600. */
  112601. render(): boolean;
  112602. /**
  112603. * Dispose and release the lens flare with its associated resources.
  112604. */
  112605. dispose(): void;
  112606. /**
  112607. * Parse a lens flare system from a JSON repressentation
  112608. * @param parsedLensFlareSystem Define the JSON to parse
  112609. * @param scene Define the scene the parsed system should be instantiated in
  112610. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  112611. * @returns the parsed system
  112612. */
  112613. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  112614. /**
  112615. * Serialize the current Lens Flare System into a JSON representation.
  112616. * @returns the serialized JSON
  112617. */
  112618. serialize(): any;
  112619. }
  112620. }
  112621. declare module BABYLON {
  112622. /**
  112623. * This represents one of the lens effect in a `lensFlareSystem`.
  112624. * It controls one of the indiviual texture used in the effect.
  112625. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112626. */
  112627. export class LensFlare {
  112628. /**
  112629. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112630. */
  112631. size: number;
  112632. /**
  112633. * 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.
  112634. */
  112635. position: number;
  112636. /**
  112637. * Define the lens color.
  112638. */
  112639. color: Color3;
  112640. /**
  112641. * Define the lens texture.
  112642. */
  112643. texture: Nullable<Texture>;
  112644. /**
  112645. * Define the alpha mode to render this particular lens.
  112646. */
  112647. alphaMode: number;
  112648. private _system;
  112649. /**
  112650. * Creates a new Lens Flare.
  112651. * This represents one of the lens effect in a `lensFlareSystem`.
  112652. * It controls one of the indiviual texture used in the effect.
  112653. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112654. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  112655. * @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.
  112656. * @param color Define the lens color
  112657. * @param imgUrl Define the lens texture url
  112658. * @param system Define the `lensFlareSystem` this flare is part of
  112659. * @returns The newly created Lens Flare
  112660. */
  112661. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  112662. /**
  112663. * Instantiates a new Lens Flare.
  112664. * This represents one of the lens effect in a `lensFlareSystem`.
  112665. * It controls one of the indiviual texture used in the effect.
  112666. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112667. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  112668. * @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.
  112669. * @param color Define the lens color
  112670. * @param imgUrl Define the lens texture url
  112671. * @param system Define the `lensFlareSystem` this flare is part of
  112672. */
  112673. constructor(
  112674. /**
  112675. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112676. */
  112677. size: number,
  112678. /**
  112679. * 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.
  112680. */
  112681. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  112682. /**
  112683. * Dispose and release the lens flare with its associated resources.
  112684. */
  112685. dispose(): void;
  112686. }
  112687. }
  112688. declare module BABYLON {
  112689. interface AbstractScene {
  112690. /**
  112691. * The list of lens flare system added to the scene
  112692. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112693. */
  112694. lensFlareSystems: Array<LensFlareSystem>;
  112695. /**
  112696. * Removes the given lens flare system from this scene.
  112697. * @param toRemove The lens flare system to remove
  112698. * @returns The index of the removed lens flare system
  112699. */
  112700. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  112701. /**
  112702. * Adds the given lens flare system to this scene
  112703. * @param newLensFlareSystem The lens flare system to add
  112704. */
  112705. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  112706. /**
  112707. * Gets a lens flare system using its name
  112708. * @param name defines the name to look for
  112709. * @returns the lens flare system or null if not found
  112710. */
  112711. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  112712. /**
  112713. * Gets a lens flare system using its id
  112714. * @param id defines the id to look for
  112715. * @returns the lens flare system or null if not found
  112716. */
  112717. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  112718. }
  112719. /**
  112720. * Defines the lens flare scene component responsible to manage any lens flares
  112721. * in a given scene.
  112722. */
  112723. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  112724. /**
  112725. * The component name helpfull to identify the component in the list of scene components.
  112726. */
  112727. readonly name: string;
  112728. /**
  112729. * The scene the component belongs to.
  112730. */
  112731. scene: Scene;
  112732. /**
  112733. * Creates a new instance of the component for the given scene
  112734. * @param scene Defines the scene to register the component in
  112735. */
  112736. constructor(scene: Scene);
  112737. /**
  112738. * Registers the component in a given scene
  112739. */
  112740. register(): void;
  112741. /**
  112742. * Rebuilds the elements related to this component in case of
  112743. * context lost for instance.
  112744. */
  112745. rebuild(): void;
  112746. /**
  112747. * Adds all the elements from the container to the scene
  112748. * @param container the container holding the elements
  112749. */
  112750. addFromContainer(container: AbstractScene): void;
  112751. /**
  112752. * Removes all the elements in the container from the scene
  112753. * @param container contains the elements to remove
  112754. * @param dispose if the removed element should be disposed (default: false)
  112755. */
  112756. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112757. /**
  112758. * Serializes the component data to the specified json object
  112759. * @param serializationObject The object to serialize to
  112760. */
  112761. serialize(serializationObject: any): void;
  112762. /**
  112763. * Disposes the component and the associated ressources.
  112764. */
  112765. dispose(): void;
  112766. private _draw;
  112767. }
  112768. }
  112769. declare module BABYLON {
  112770. /**
  112771. * Defines the shadow generator component responsible to manage any shadow generators
  112772. * in a given scene.
  112773. */
  112774. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  112775. /**
  112776. * The component name helpfull to identify the component in the list of scene components.
  112777. */
  112778. readonly name: string;
  112779. /**
  112780. * The scene the component belongs to.
  112781. */
  112782. scene: Scene;
  112783. /**
  112784. * Creates a new instance of the component for the given scene
  112785. * @param scene Defines the scene to register the component in
  112786. */
  112787. constructor(scene: Scene);
  112788. /**
  112789. * Registers the component in a given scene
  112790. */
  112791. register(): void;
  112792. /**
  112793. * Rebuilds the elements related to this component in case of
  112794. * context lost for instance.
  112795. */
  112796. rebuild(): void;
  112797. /**
  112798. * Serializes the component data to the specified json object
  112799. * @param serializationObject The object to serialize to
  112800. */
  112801. serialize(serializationObject: any): void;
  112802. /**
  112803. * Adds all the elements from the container to the scene
  112804. * @param container the container holding the elements
  112805. */
  112806. addFromContainer(container: AbstractScene): void;
  112807. /**
  112808. * Removes all the elements in the container from the scene
  112809. * @param container contains the elements to remove
  112810. * @param dispose if the removed element should be disposed (default: false)
  112811. */
  112812. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112813. /**
  112814. * Rebuilds the elements related to this component in case of
  112815. * context lost for instance.
  112816. */
  112817. dispose(): void;
  112818. private _gatherRenderTargets;
  112819. }
  112820. }
  112821. declare module BABYLON {
  112822. /**
  112823. * A point light is a light defined by an unique point in world space.
  112824. * The light is emitted in every direction from this point.
  112825. * A good example of a point light is a standard light bulb.
  112826. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112827. */
  112828. export class PointLight extends ShadowLight {
  112829. private _shadowAngle;
  112830. /**
  112831. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112832. * This specifies what angle the shadow will use to be created.
  112833. *
  112834. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  112835. */
  112836. /**
  112837. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112838. * This specifies what angle the shadow will use to be created.
  112839. *
  112840. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  112841. */
  112842. shadowAngle: number;
  112843. /**
  112844. * Gets the direction if it has been set.
  112845. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112846. */
  112847. /**
  112848. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112849. */
  112850. direction: Vector3;
  112851. /**
  112852. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  112853. * A PointLight emits the light in every direction.
  112854. * It can cast shadows.
  112855. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  112856. * ```javascript
  112857. * var pointLight = new PointLight("pl", camera.position, scene);
  112858. * ```
  112859. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112860. * @param name The light friendly name
  112861. * @param position The position of the point light in the scene
  112862. * @param scene The scene the lights belongs to
  112863. */
  112864. constructor(name: string, position: Vector3, scene: Scene);
  112865. /**
  112866. * Returns the string "PointLight"
  112867. * @returns the class name
  112868. */
  112869. getClassName(): string;
  112870. /**
  112871. * Returns the integer 0.
  112872. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112873. */
  112874. getTypeID(): number;
  112875. /**
  112876. * Specifies wether or not the shadowmap should be a cube texture.
  112877. * @returns true if the shadowmap needs to be a cube texture.
  112878. */
  112879. needCube(): boolean;
  112880. /**
  112881. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  112882. * @param faceIndex The index of the face we are computed the direction to generate shadow
  112883. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  112884. */
  112885. getShadowDirection(faceIndex?: number): Vector3;
  112886. /**
  112887. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  112888. * - fov = PI / 2
  112889. * - aspect ratio : 1.0
  112890. * - z-near and far equal to the active camera minZ and maxZ.
  112891. * Returns the PointLight.
  112892. */
  112893. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112894. protected _buildUniformLayout(): void;
  112895. /**
  112896. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  112897. * @param effect The effect to update
  112898. * @param lightIndex The index of the light in the effect to update
  112899. * @returns The point light
  112900. */
  112901. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  112902. /**
  112903. * Prepares the list of defines specific to the light type.
  112904. * @param defines the list of defines
  112905. * @param lightIndex defines the index of the light for the effect
  112906. */
  112907. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112908. }
  112909. }
  112910. declare module BABYLON {
  112911. /**
  112912. * Header information of HDR texture files.
  112913. */
  112914. export interface HDRInfo {
  112915. /**
  112916. * The height of the texture in pixels.
  112917. */
  112918. height: number;
  112919. /**
  112920. * The width of the texture in pixels.
  112921. */
  112922. width: number;
  112923. /**
  112924. * The index of the beginning of the data in the binary file.
  112925. */
  112926. dataPosition: number;
  112927. }
  112928. /**
  112929. * This groups tools to convert HDR texture to native colors array.
  112930. */
  112931. export class HDRTools {
  112932. private static Ldexp;
  112933. private static Rgbe2float;
  112934. private static readStringLine;
  112935. /**
  112936. * Reads header information from an RGBE texture stored in a native array.
  112937. * More information on this format are available here:
  112938. * https://en.wikipedia.org/wiki/RGBE_image_format
  112939. *
  112940. * @param uint8array The binary file stored in native array.
  112941. * @return The header information.
  112942. */
  112943. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  112944. /**
  112945. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  112946. * This RGBE texture needs to store the information as a panorama.
  112947. *
  112948. * More information on this format are available here:
  112949. * https://en.wikipedia.org/wiki/RGBE_image_format
  112950. *
  112951. * @param buffer The binary file stored in an array buffer.
  112952. * @param size The expected size of the extracted cubemap.
  112953. * @return The Cube Map information.
  112954. */
  112955. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  112956. /**
  112957. * Returns the pixels data extracted from an RGBE texture.
  112958. * This pixels will be stored left to right up to down in the R G B order in one array.
  112959. *
  112960. * More information on this format are available here:
  112961. * https://en.wikipedia.org/wiki/RGBE_image_format
  112962. *
  112963. * @param uint8array The binary file stored in an array buffer.
  112964. * @param hdrInfo The header information of the file.
  112965. * @return The pixels data in RGB right to left up to down order.
  112966. */
  112967. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  112968. private static RGBE_ReadPixels_RLE;
  112969. }
  112970. }
  112971. declare module BABYLON {
  112972. /**
  112973. * This represents a texture coming from an HDR input.
  112974. *
  112975. * The only supported format is currently panorama picture stored in RGBE format.
  112976. * Example of such files can be found on HDRLib: http://hdrlib.com/
  112977. */
  112978. export class HDRCubeTexture extends BaseTexture {
  112979. private static _facesMapping;
  112980. private _generateHarmonics;
  112981. private _noMipmap;
  112982. private _textureMatrix;
  112983. private _size;
  112984. private _onLoad;
  112985. private _onError;
  112986. /**
  112987. * The texture URL.
  112988. */
  112989. url: string;
  112990. /**
  112991. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  112992. */
  112993. coordinatesMode: number;
  112994. protected _isBlocking: boolean;
  112995. /**
  112996. * Sets wether or not the texture is blocking during loading.
  112997. */
  112998. /**
  112999. * Gets wether or not the texture is blocking during loading.
  113000. */
  113001. isBlocking: boolean;
  113002. protected _rotationY: number;
  113003. /**
  113004. * Sets texture matrix rotation angle around Y axis in radians.
  113005. */
  113006. /**
  113007. * Gets texture matrix rotation angle around Y axis radians.
  113008. */
  113009. rotationY: number;
  113010. /**
  113011. * Gets or sets the center of the bounding box associated with the cube texture
  113012. * It must define where the camera used to render the texture was set
  113013. */
  113014. boundingBoxPosition: Vector3;
  113015. private _boundingBoxSize;
  113016. /**
  113017. * Gets or sets the size of the bounding box associated with the cube texture
  113018. * When defined, the cubemap will switch to local mode
  113019. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  113020. * @example https://www.babylonjs-playground.com/#RNASML
  113021. */
  113022. boundingBoxSize: Vector3;
  113023. /**
  113024. * Instantiates an HDRTexture from the following parameters.
  113025. *
  113026. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  113027. * @param scene The scene the texture will be used in
  113028. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113029. * @param noMipmap Forces to not generate the mipmap if true
  113030. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  113031. * @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)
  113032. * @param reserved Reserved flag for internal use.
  113033. */
  113034. 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>);
  113035. /**
  113036. * Get the current class name of the texture useful for serialization or dynamic coding.
  113037. * @returns "HDRCubeTexture"
  113038. */
  113039. getClassName(): string;
  113040. /**
  113041. * Occurs when the file is raw .hdr file.
  113042. */
  113043. private loadTexture;
  113044. clone(): HDRCubeTexture;
  113045. delayLoad(): void;
  113046. /**
  113047. * Get the texture reflection matrix used to rotate/transform the reflection.
  113048. * @returns the reflection matrix
  113049. */
  113050. getReflectionTextureMatrix(): Matrix;
  113051. /**
  113052. * Set the texture reflection matrix used to rotate/transform the reflection.
  113053. * @param value Define the reflection matrix to set
  113054. */
  113055. setReflectionTextureMatrix(value: Matrix): void;
  113056. /**
  113057. * Parses a JSON representation of an HDR Texture in order to create the texture
  113058. * @param parsedTexture Define the JSON representation
  113059. * @param scene Define the scene the texture should be created in
  113060. * @param rootUrl Define the root url in case we need to load relative dependencies
  113061. * @returns the newly created texture after parsing
  113062. */
  113063. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  113064. serialize(): any;
  113065. }
  113066. }
  113067. declare module BABYLON {
  113068. /**
  113069. * Class used to control physics engine
  113070. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  113071. */
  113072. export class PhysicsEngine implements IPhysicsEngine {
  113073. private _physicsPlugin;
  113074. /**
  113075. * Global value used to control the smallest number supported by the simulation
  113076. */
  113077. static Epsilon: number;
  113078. private _impostors;
  113079. private _joints;
  113080. /**
  113081. * Gets the gravity vector used by the simulation
  113082. */
  113083. gravity: Vector3;
  113084. /**
  113085. * Factory used to create the default physics plugin.
  113086. * @returns The default physics plugin
  113087. */
  113088. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  113089. /**
  113090. * Creates a new Physics Engine
  113091. * @param gravity defines the gravity vector used by the simulation
  113092. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  113093. */
  113094. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  113095. /**
  113096. * Sets the gravity vector used by the simulation
  113097. * @param gravity defines the gravity vector to use
  113098. */
  113099. setGravity(gravity: Vector3): void;
  113100. /**
  113101. * Set the time step of the physics engine.
  113102. * Default is 1/60.
  113103. * To slow it down, enter 1/600 for example.
  113104. * To speed it up, 1/30
  113105. * @param newTimeStep defines the new timestep to apply to this world.
  113106. */
  113107. setTimeStep(newTimeStep?: number): void;
  113108. /**
  113109. * Get the time step of the physics engine.
  113110. * @returns the current time step
  113111. */
  113112. getTimeStep(): number;
  113113. /**
  113114. * Release all resources
  113115. */
  113116. dispose(): void;
  113117. /**
  113118. * Gets the name of the current physics plugin
  113119. * @returns the name of the plugin
  113120. */
  113121. getPhysicsPluginName(): string;
  113122. /**
  113123. * Adding a new impostor for the impostor tracking.
  113124. * This will be done by the impostor itself.
  113125. * @param impostor the impostor to add
  113126. */
  113127. addImpostor(impostor: PhysicsImpostor): void;
  113128. /**
  113129. * Remove an impostor from the engine.
  113130. * This impostor and its mesh will not longer be updated by the physics engine.
  113131. * @param impostor the impostor to remove
  113132. */
  113133. removeImpostor(impostor: PhysicsImpostor): void;
  113134. /**
  113135. * Add a joint to the physics engine
  113136. * @param mainImpostor defines the main impostor to which the joint is added.
  113137. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113138. * @param joint defines the joint that will connect both impostors.
  113139. */
  113140. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113141. /**
  113142. * Removes a joint from the simulation
  113143. * @param mainImpostor defines the impostor used with the joint
  113144. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113145. * @param joint defines the joint to remove
  113146. */
  113147. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113148. /**
  113149. * Called by the scene. No need to call it.
  113150. * @param delta defines the timespam between frames
  113151. */
  113152. _step(delta: number): void;
  113153. /**
  113154. * Gets the current plugin used to run the simulation
  113155. * @returns current plugin
  113156. */
  113157. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113158. /**
  113159. * Gets the list of physic impostors
  113160. * @returns an array of PhysicsImpostor
  113161. */
  113162. getImpostors(): Array<PhysicsImpostor>;
  113163. /**
  113164. * Gets the impostor for a physics enabled object
  113165. * @param object defines the object impersonated by the impostor
  113166. * @returns the PhysicsImpostor or null if not found
  113167. */
  113168. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113169. /**
  113170. * Gets the impostor for a physics body object
  113171. * @param body defines physics body used by the impostor
  113172. * @returns the PhysicsImpostor or null if not found
  113173. */
  113174. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113175. /**
  113176. * Does a raycast in the physics world
  113177. * @param from when should the ray start?
  113178. * @param to when should the ray end?
  113179. * @returns PhysicsRaycastResult
  113180. */
  113181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113182. }
  113183. }
  113184. declare module BABYLON {
  113185. /** @hidden */
  113186. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  113187. private _useDeltaForWorldStep;
  113188. world: any;
  113189. name: string;
  113190. private _physicsMaterials;
  113191. private _fixedTimeStep;
  113192. private _cannonRaycastResult;
  113193. private _raycastResult;
  113194. private _physicsBodysToRemoveAfterStep;
  113195. BJSCANNON: any;
  113196. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  113197. setGravity(gravity: Vector3): void;
  113198. setTimeStep(timeStep: number): void;
  113199. getTimeStep(): number;
  113200. executeStep(delta: number): void;
  113201. private _removeMarkedPhysicsBodiesFromWorld;
  113202. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113203. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113204. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113205. private _processChildMeshes;
  113206. removePhysicsBody(impostor: PhysicsImpostor): void;
  113207. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113208. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113209. private _addMaterial;
  113210. private _checkWithEpsilon;
  113211. private _createShape;
  113212. private _createHeightmap;
  113213. private _minus90X;
  113214. private _plus90X;
  113215. private _tmpPosition;
  113216. private _tmpDeltaPosition;
  113217. private _tmpUnityRotation;
  113218. private _updatePhysicsBodyTransformation;
  113219. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113220. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113221. isSupported(): boolean;
  113222. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113223. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113224. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113225. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113226. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113227. getBodyMass(impostor: PhysicsImpostor): number;
  113228. getBodyFriction(impostor: PhysicsImpostor): number;
  113229. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113230. getBodyRestitution(impostor: PhysicsImpostor): number;
  113231. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113232. sleepBody(impostor: PhysicsImpostor): void;
  113233. wakeUpBody(impostor: PhysicsImpostor): void;
  113234. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  113235. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113236. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113237. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113238. getRadius(impostor: PhysicsImpostor): number;
  113239. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113240. dispose(): void;
  113241. private _extendNamespace;
  113242. /**
  113243. * Does a raycast in the physics world
  113244. * @param from when should the ray start?
  113245. * @param to when should the ray end?
  113246. * @returns PhysicsRaycastResult
  113247. */
  113248. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113249. }
  113250. }
  113251. declare module BABYLON {
  113252. /** @hidden */
  113253. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  113254. world: any;
  113255. name: string;
  113256. BJSOIMO: any;
  113257. private _raycastResult;
  113258. constructor(iterations?: number, oimoInjection?: any);
  113259. setGravity(gravity: Vector3): void;
  113260. setTimeStep(timeStep: number): void;
  113261. getTimeStep(): number;
  113262. private _tmpImpostorsArray;
  113263. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113267. private _tmpPositionVector;
  113268. removePhysicsBody(impostor: PhysicsImpostor): void;
  113269. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113270. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113271. isSupported(): boolean;
  113272. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113273. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113274. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113275. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113276. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113277. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113278. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113279. getBodyMass(impostor: PhysicsImpostor): number;
  113280. getBodyFriction(impostor: PhysicsImpostor): number;
  113281. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113282. getBodyRestitution(impostor: PhysicsImpostor): number;
  113283. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113284. sleepBody(impostor: PhysicsImpostor): void;
  113285. wakeUpBody(impostor: PhysicsImpostor): void;
  113286. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113287. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  113288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113289. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113290. getRadius(impostor: PhysicsImpostor): number;
  113291. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113292. dispose(): void;
  113293. /**
  113294. * Does a raycast in the physics world
  113295. * @param from when should the ray start?
  113296. * @param to when should the ray end?
  113297. * @returns PhysicsRaycastResult
  113298. */
  113299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113300. }
  113301. }
  113302. declare module BABYLON {
  113303. /**
  113304. * Class containing static functions to help procedurally build meshes
  113305. */
  113306. export class RibbonBuilder {
  113307. /**
  113308. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  113309. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  113310. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  113311. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  113312. * * 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
  113313. * * 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
  113314. * * 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
  113315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113317. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113318. * * 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
  113319. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  113320. * * 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
  113321. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  113322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113323. * @param name defines the name of the mesh
  113324. * @param options defines the options used to create the mesh
  113325. * @param scene defines the hosting scene
  113326. * @returns the ribbon mesh
  113327. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  113328. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113329. */
  113330. static CreateRibbon(name: string, options: {
  113331. pathArray: Vector3[][];
  113332. closeArray?: boolean;
  113333. closePath?: boolean;
  113334. offset?: number;
  113335. updatable?: boolean;
  113336. sideOrientation?: number;
  113337. frontUVs?: Vector4;
  113338. backUVs?: Vector4;
  113339. instance?: Mesh;
  113340. invertUV?: boolean;
  113341. uvs?: Vector2[];
  113342. colors?: Color4[];
  113343. }, scene?: Nullable<Scene>): Mesh;
  113344. }
  113345. }
  113346. declare module BABYLON {
  113347. /**
  113348. * Class containing static functions to help procedurally build meshes
  113349. */
  113350. export class ShapeBuilder {
  113351. /**
  113352. * 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.
  113353. * * 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.
  113354. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113355. * * 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.
  113356. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  113357. * * 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
  113358. * * 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
  113359. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  113360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113362. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  113363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113364. * @param name defines the name of the mesh
  113365. * @param options defines the options used to create the mesh
  113366. * @param scene defines the hosting scene
  113367. * @returns the extruded shape mesh
  113368. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113370. */
  113371. static ExtrudeShape(name: string, options: {
  113372. shape: Vector3[];
  113373. path: Vector3[];
  113374. scale?: number;
  113375. rotation?: number;
  113376. cap?: number;
  113377. updatable?: boolean;
  113378. sideOrientation?: number;
  113379. frontUVs?: Vector4;
  113380. backUVs?: Vector4;
  113381. instance?: Mesh;
  113382. invertUV?: boolean;
  113383. }, scene?: Nullable<Scene>): Mesh;
  113384. /**
  113385. * Creates an custom extruded shape mesh.
  113386. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  113387. * * 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.
  113388. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113389. * * 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
  113390. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  113391. * * 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
  113392. * * It must returns a float value that will be the scale value applied to the shape on each path point
  113393. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  113394. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  113395. * * 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
  113396. * * 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
  113397. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  113398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113400. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113402. * @param name defines the name of the mesh
  113403. * @param options defines the options used to create the mesh
  113404. * @param scene defines the hosting scene
  113405. * @returns the custom extruded shape mesh
  113406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  113407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113409. */
  113410. static ExtrudeShapeCustom(name: string, options: {
  113411. shape: Vector3[];
  113412. path: Vector3[];
  113413. scaleFunction?: any;
  113414. rotationFunction?: any;
  113415. ribbonCloseArray?: boolean;
  113416. ribbonClosePath?: boolean;
  113417. cap?: number;
  113418. updatable?: boolean;
  113419. sideOrientation?: number;
  113420. frontUVs?: Vector4;
  113421. backUVs?: Vector4;
  113422. instance?: Mesh;
  113423. invertUV?: boolean;
  113424. }, scene?: Nullable<Scene>): Mesh;
  113425. private static _ExtrudeShapeGeneric;
  113426. }
  113427. }
  113428. declare module BABYLON {
  113429. /**
  113430. * AmmoJS Physics plugin
  113431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113432. * @see https://github.com/kripken/ammo.js/
  113433. */
  113434. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  113435. private _useDeltaForWorldStep;
  113436. /**
  113437. * Reference to the Ammo library
  113438. */
  113439. bjsAMMO: any;
  113440. /**
  113441. * Created ammoJS world which physics bodies are added to
  113442. */
  113443. world: any;
  113444. /**
  113445. * Name of the plugin
  113446. */
  113447. name: string;
  113448. private _timeStep;
  113449. private _fixedTimeStep;
  113450. private _maxSteps;
  113451. private _tmpQuaternion;
  113452. private _tmpAmmoTransform;
  113453. private _tmpAmmoQuaternion;
  113454. private _tmpAmmoConcreteContactResultCallback;
  113455. private _collisionConfiguration;
  113456. private _dispatcher;
  113457. private _overlappingPairCache;
  113458. private _solver;
  113459. private _softBodySolver;
  113460. private _tmpAmmoVectorA;
  113461. private _tmpAmmoVectorB;
  113462. private _tmpAmmoVectorC;
  113463. private _tmpAmmoVectorD;
  113464. private _tmpContactCallbackResult;
  113465. private _tmpAmmoVectorRCA;
  113466. private _tmpAmmoVectorRCB;
  113467. private _raycastResult;
  113468. private static readonly DISABLE_COLLISION_FLAG;
  113469. private static readonly KINEMATIC_FLAG;
  113470. private static readonly DISABLE_DEACTIVATION_FLAG;
  113471. /**
  113472. * Initializes the ammoJS plugin
  113473. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  113474. * @param ammoInjection can be used to inject your own ammo reference
  113475. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  113476. */
  113477. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  113478. /**
  113479. * Sets the gravity of the physics world (m/(s^2))
  113480. * @param gravity Gravity to set
  113481. */
  113482. setGravity(gravity: Vector3): void;
  113483. /**
  113484. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  113485. * @param timeStep timestep to use in seconds
  113486. */
  113487. setTimeStep(timeStep: number): void;
  113488. /**
  113489. * 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)
  113490. * @param fixedTimeStep fixedTimeStep to use in seconds
  113491. */
  113492. setFixedTimeStep(fixedTimeStep: number): void;
  113493. /**
  113494. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113495. * @param maxSteps the maximum number of steps by the physics engine per frame
  113496. */
  113497. setMaxSteps(maxSteps: number): void;
  113498. /**
  113499. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113500. * @returns the current timestep in seconds
  113501. */
  113502. getTimeStep(): number;
  113503. private _isImpostorInContact;
  113504. private _isImpostorPairInContact;
  113505. private _stepSimulation;
  113506. /**
  113507. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113508. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113509. * After the step the babylon meshes are set to the position of the physics imposters
  113510. * @param delta amount of time to step forward
  113511. * @param impostors array of imposters to update before/after the step
  113512. */
  113513. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113514. /**
  113515. * Update babylon mesh to match physics world object
  113516. * @param impostor imposter to match
  113517. */
  113518. private _afterSoftStep;
  113519. /**
  113520. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113521. * @param impostor imposter to match
  113522. */
  113523. private _ropeStep;
  113524. /**
  113525. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113526. * @param impostor imposter to match
  113527. */
  113528. private _softbodyOrClothStep;
  113529. private _tmpVector;
  113530. private _tmpMatrix;
  113531. /**
  113532. * Applies an impulse on the imposter
  113533. * @param impostor imposter to apply impulse to
  113534. * @param force amount of force to be applied to the imposter
  113535. * @param contactPoint the location to apply the impulse on the imposter
  113536. */
  113537. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113538. /**
  113539. * Applies a force on the imposter
  113540. * @param impostor imposter to apply force
  113541. * @param force amount of force to be applied to the imposter
  113542. * @param contactPoint the location to apply the force on the imposter
  113543. */
  113544. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113545. /**
  113546. * Creates a physics body using the plugin
  113547. * @param impostor the imposter to create the physics body on
  113548. */
  113549. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113550. /**
  113551. * Removes the physics body from the imposter and disposes of the body's memory
  113552. * @param impostor imposter to remove the physics body from
  113553. */
  113554. removePhysicsBody(impostor: PhysicsImpostor): void;
  113555. /**
  113556. * Generates a joint
  113557. * @param impostorJoint the imposter joint to create the joint with
  113558. */
  113559. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113560. /**
  113561. * Removes a joint
  113562. * @param impostorJoint the imposter joint to remove the joint from
  113563. */
  113564. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113565. private _addMeshVerts;
  113566. /**
  113567. * Initialise the soft body vertices to match its object's (mesh) vertices
  113568. * Softbody vertices (nodes) are in world space and to match this
  113569. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  113570. * @param impostor to create the softbody for
  113571. */
  113572. private _softVertexData;
  113573. /**
  113574. * Create an impostor's soft body
  113575. * @param impostor to create the softbody for
  113576. */
  113577. private _createSoftbody;
  113578. /**
  113579. * Create cloth for an impostor
  113580. * @param impostor to create the softbody for
  113581. */
  113582. private _createCloth;
  113583. /**
  113584. * Create rope for an impostor
  113585. * @param impostor to create the softbody for
  113586. */
  113587. private _createRope;
  113588. private _addHullVerts;
  113589. private _createShape;
  113590. /**
  113591. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  113592. * @param impostor imposter containing the physics body and babylon object
  113593. */
  113594. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113595. /**
  113596. * Sets the babylon object's position/rotation from the physics body's position/rotation
  113597. * @param impostor imposter containing the physics body and babylon object
  113598. * @param newPosition new position
  113599. * @param newRotation new rotation
  113600. */
  113601. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113602. /**
  113603. * If this plugin is supported
  113604. * @returns true if its supported
  113605. */
  113606. isSupported(): boolean;
  113607. /**
  113608. * Sets the linear velocity of the physics body
  113609. * @param impostor imposter to set the velocity on
  113610. * @param velocity velocity to set
  113611. */
  113612. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113613. /**
  113614. * Sets the angular velocity of the physics body
  113615. * @param impostor imposter to set the velocity on
  113616. * @param velocity velocity to set
  113617. */
  113618. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113619. /**
  113620. * gets the linear velocity
  113621. * @param impostor imposter to get linear velocity from
  113622. * @returns linear velocity
  113623. */
  113624. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113625. /**
  113626. * gets the angular velocity
  113627. * @param impostor imposter to get angular velocity from
  113628. * @returns angular velocity
  113629. */
  113630. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113631. /**
  113632. * Sets the mass of physics body
  113633. * @param impostor imposter to set the mass on
  113634. * @param mass mass to set
  113635. */
  113636. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113637. /**
  113638. * Gets the mass of the physics body
  113639. * @param impostor imposter to get the mass from
  113640. * @returns mass
  113641. */
  113642. getBodyMass(impostor: PhysicsImpostor): number;
  113643. /**
  113644. * Gets friction of the impostor
  113645. * @param impostor impostor to get friction from
  113646. * @returns friction value
  113647. */
  113648. getBodyFriction(impostor: PhysicsImpostor): number;
  113649. /**
  113650. * Sets friction of the impostor
  113651. * @param impostor impostor to set friction on
  113652. * @param friction friction value
  113653. */
  113654. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113655. /**
  113656. * Gets restitution of the impostor
  113657. * @param impostor impostor to get restitution from
  113658. * @returns restitution value
  113659. */
  113660. getBodyRestitution(impostor: PhysicsImpostor): number;
  113661. /**
  113662. * Sets resitution of the impostor
  113663. * @param impostor impostor to set resitution on
  113664. * @param restitution resitution value
  113665. */
  113666. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113667. /**
  113668. * Gets pressure inside the impostor
  113669. * @param impostor impostor to get pressure from
  113670. * @returns pressure value
  113671. */
  113672. getBodyPressure(impostor: PhysicsImpostor): number;
  113673. /**
  113674. * Sets pressure inside a soft body impostor
  113675. * Cloth and rope must remain 0 pressure
  113676. * @param impostor impostor to set pressure on
  113677. * @param pressure pressure value
  113678. */
  113679. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  113680. /**
  113681. * Gets stiffness of the impostor
  113682. * @param impostor impostor to get stiffness from
  113683. * @returns pressure value
  113684. */
  113685. getBodyStiffness(impostor: PhysicsImpostor): number;
  113686. /**
  113687. * Sets stiffness of the impostor
  113688. * @param impostor impostor to set stiffness on
  113689. * @param stiffness stiffness value from 0 to 1
  113690. */
  113691. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  113692. /**
  113693. * Gets velocityIterations of the impostor
  113694. * @param impostor impostor to get velocity iterations from
  113695. * @returns velocityIterations value
  113696. */
  113697. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  113698. /**
  113699. * Sets velocityIterations of the impostor
  113700. * @param impostor impostor to set velocity iterations on
  113701. * @param velocityIterations velocityIterations value
  113702. */
  113703. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  113704. /**
  113705. * Gets positionIterations of the impostor
  113706. * @param impostor impostor to get position iterations from
  113707. * @returns positionIterations value
  113708. */
  113709. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  113710. /**
  113711. * Sets positionIterations of the impostor
  113712. * @param impostor impostor to set position on
  113713. * @param positionIterations positionIterations value
  113714. */
  113715. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  113716. /**
  113717. * Append an anchor to a cloth object
  113718. * @param impostor is the cloth impostor to add anchor to
  113719. * @param otherImpostor is the rigid impostor to anchor to
  113720. * @param width ratio across width from 0 to 1
  113721. * @param height ratio up height from 0 to 1
  113722. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113723. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113724. */
  113725. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  113726. /**
  113727. * Append an hook to a rope object
  113728. * @param impostor is the rope impostor to add hook to
  113729. * @param otherImpostor is the rigid impostor to hook to
  113730. * @param length ratio along the rope from 0 to 1
  113731. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  113732. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113733. */
  113734. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  113735. /**
  113736. * Sleeps the physics body and stops it from being active
  113737. * @param impostor impostor to sleep
  113738. */
  113739. sleepBody(impostor: PhysicsImpostor): void;
  113740. /**
  113741. * Activates the physics body
  113742. * @param impostor impostor to activate
  113743. */
  113744. wakeUpBody(impostor: PhysicsImpostor): void;
  113745. /**
  113746. * Updates the distance parameters of the joint
  113747. * @param joint joint to update
  113748. * @param maxDistance maximum distance of the joint
  113749. * @param minDistance minimum distance of the joint
  113750. */
  113751. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113752. /**
  113753. * Sets a motor on the joint
  113754. * @param joint joint to set motor on
  113755. * @param speed speed of the motor
  113756. * @param maxForce maximum force of the motor
  113757. * @param motorIndex index of the motor
  113758. */
  113759. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113760. /**
  113761. * Sets the motors limit
  113762. * @param joint joint to set limit on
  113763. * @param upperLimit upper limit
  113764. * @param lowerLimit lower limit
  113765. */
  113766. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113767. /**
  113768. * Syncs the position and rotation of a mesh with the impostor
  113769. * @param mesh mesh to sync
  113770. * @param impostor impostor to update the mesh with
  113771. */
  113772. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113773. /**
  113774. * Gets the radius of the impostor
  113775. * @param impostor impostor to get radius from
  113776. * @returns the radius
  113777. */
  113778. getRadius(impostor: PhysicsImpostor): number;
  113779. /**
  113780. * Gets the box size of the impostor
  113781. * @param impostor impostor to get box size from
  113782. * @param result the resulting box size
  113783. */
  113784. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113785. /**
  113786. * Disposes of the impostor
  113787. */
  113788. dispose(): void;
  113789. /**
  113790. * Does a raycast in the physics world
  113791. * @param from when should the ray start?
  113792. * @param to when should the ray end?
  113793. * @returns PhysicsRaycastResult
  113794. */
  113795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113796. }
  113797. }
  113798. declare module BABYLON {
  113799. interface AbstractScene {
  113800. /**
  113801. * The list of reflection probes added to the scene
  113802. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  113803. */
  113804. reflectionProbes: Array<ReflectionProbe>;
  113805. /**
  113806. * Removes the given reflection probe from this scene.
  113807. * @param toRemove The reflection probe to remove
  113808. * @returns The index of the removed reflection probe
  113809. */
  113810. removeReflectionProbe(toRemove: ReflectionProbe): number;
  113811. /**
  113812. * Adds the given reflection probe to this scene.
  113813. * @param newReflectionProbe The reflection probe to add
  113814. */
  113815. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  113816. }
  113817. /**
  113818. * Class used to generate realtime reflection / refraction cube textures
  113819. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  113820. */
  113821. export class ReflectionProbe {
  113822. /** defines the name of the probe */
  113823. name: string;
  113824. private _scene;
  113825. private _renderTargetTexture;
  113826. private _projectionMatrix;
  113827. private _viewMatrix;
  113828. private _target;
  113829. private _add;
  113830. private _attachedMesh;
  113831. private _invertYAxis;
  113832. /** Gets or sets probe position (center of the cube map) */
  113833. position: Vector3;
  113834. /**
  113835. * Creates a new reflection probe
  113836. * @param name defines the name of the probe
  113837. * @param size defines the texture resolution (for each face)
  113838. * @param scene defines the hosting scene
  113839. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  113840. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  113841. */
  113842. constructor(
  113843. /** defines the name of the probe */
  113844. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  113845. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  113846. samples: number;
  113847. /** Gets or sets the refresh rate to use (on every frame by default) */
  113848. refreshRate: number;
  113849. /**
  113850. * Gets the hosting scene
  113851. * @returns a Scene
  113852. */
  113853. getScene(): Scene;
  113854. /** Gets the internal CubeTexture used to render to */
  113855. readonly cubeTexture: RenderTargetTexture;
  113856. /** Gets the list of meshes to render */
  113857. readonly renderList: Nullable<AbstractMesh[]>;
  113858. /**
  113859. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  113860. * @param mesh defines the mesh to attach to
  113861. */
  113862. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  113863. /**
  113864. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  113865. * @param renderingGroupId The rendering group id corresponding to its index
  113866. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113867. */
  113868. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  113869. /**
  113870. * Clean all associated resources
  113871. */
  113872. dispose(): void;
  113873. /**
  113874. * Converts the reflection probe information to a readable string for debug purpose.
  113875. * @param fullDetails Supports for multiple levels of logging within scene loading
  113876. * @returns the human readable reflection probe info
  113877. */
  113878. toString(fullDetails?: boolean): string;
  113879. /**
  113880. * Get the class name of the relfection probe.
  113881. * @returns "ReflectionProbe"
  113882. */
  113883. getClassName(): string;
  113884. /**
  113885. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  113886. * @returns The JSON representation of the texture
  113887. */
  113888. serialize(): any;
  113889. /**
  113890. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  113891. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  113892. * @param scene Define the scene the parsed reflection probe should be instantiated in
  113893. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  113894. * @returns The parsed reflection probe if successful
  113895. */
  113896. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  113897. }
  113898. }
  113899. declare module BABYLON {
  113900. /** @hidden */
  113901. export var _BabylonLoaderRegistered: boolean;
  113902. }
  113903. declare module BABYLON {
  113904. /**
  113905. * The Physically based simple base material of BJS.
  113906. *
  113907. * This enables better naming and convention enforcements on top of the pbrMaterial.
  113908. * It is used as the base class for both the specGloss and metalRough conventions.
  113909. */
  113910. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  113911. /**
  113912. * Number of Simultaneous lights allowed on the material.
  113913. */
  113914. maxSimultaneousLights: number;
  113915. /**
  113916. * If sets to true, disables all the lights affecting the material.
  113917. */
  113918. disableLighting: boolean;
  113919. /**
  113920. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  113921. */
  113922. environmentTexture: BaseTexture;
  113923. /**
  113924. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113925. */
  113926. invertNormalMapX: boolean;
  113927. /**
  113928. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113929. */
  113930. invertNormalMapY: boolean;
  113931. /**
  113932. * Normal map used in the model.
  113933. */
  113934. normalTexture: BaseTexture;
  113935. /**
  113936. * Emissivie color used to self-illuminate the model.
  113937. */
  113938. emissiveColor: Color3;
  113939. /**
  113940. * Emissivie texture used to self-illuminate the model.
  113941. */
  113942. emissiveTexture: BaseTexture;
  113943. /**
  113944. * Occlusion Channel Strenght.
  113945. */
  113946. occlusionStrength: number;
  113947. /**
  113948. * Occlusion Texture of the material (adding extra occlusion effects).
  113949. */
  113950. occlusionTexture: BaseTexture;
  113951. /**
  113952. * Defines the alpha limits in alpha test mode.
  113953. */
  113954. alphaCutOff: number;
  113955. /**
  113956. * Gets the current double sided mode.
  113957. */
  113958. /**
  113959. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113960. */
  113961. doubleSided: boolean;
  113962. /**
  113963. * Stores the pre-calculated light information of a mesh in a texture.
  113964. */
  113965. lightmapTexture: BaseTexture;
  113966. /**
  113967. * If true, the light map contains occlusion information instead of lighting info.
  113968. */
  113969. useLightmapAsShadowmap: boolean;
  113970. /**
  113971. * Instantiates a new PBRMaterial instance.
  113972. *
  113973. * @param name The material name
  113974. * @param scene The scene the material will be use in.
  113975. */
  113976. constructor(name: string, scene: Scene);
  113977. getClassName(): string;
  113978. }
  113979. }
  113980. declare module BABYLON {
  113981. /**
  113982. * The PBR material of BJS following the metal roughness convention.
  113983. *
  113984. * This fits to the PBR convention in the GLTF definition:
  113985. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  113986. */
  113987. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  113988. /**
  113989. * The base color has two different interpretations depending on the value of metalness.
  113990. * When the material is a metal, the base color is the specific measured reflectance value
  113991. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  113992. * of the material.
  113993. */
  113994. baseColor: Color3;
  113995. /**
  113996. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  113997. * well as opacity information in the alpha channel.
  113998. */
  113999. baseTexture: BaseTexture;
  114000. /**
  114001. * Specifies the metallic scalar value of the material.
  114002. * Can also be used to scale the metalness values of the metallic texture.
  114003. */
  114004. metallic: number;
  114005. /**
  114006. * Specifies the roughness scalar value of the material.
  114007. * Can also be used to scale the roughness values of the metallic texture.
  114008. */
  114009. roughness: number;
  114010. /**
  114011. * Texture containing both the metallic value in the B channel and the
  114012. * roughness value in the G channel to keep better precision.
  114013. */
  114014. metallicRoughnessTexture: BaseTexture;
  114015. /**
  114016. * Instantiates a new PBRMetalRoughnessMaterial instance.
  114017. *
  114018. * @param name The material name
  114019. * @param scene The scene the material will be use in.
  114020. */
  114021. constructor(name: string, scene: Scene);
  114022. /**
  114023. * Return the currrent class name of the material.
  114024. */
  114025. getClassName(): string;
  114026. /**
  114027. * Makes a duplicate of the current material.
  114028. * @param name - name to use for the new material.
  114029. */
  114030. clone(name: string): PBRMetallicRoughnessMaterial;
  114031. /**
  114032. * Serialize the material to a parsable JSON object.
  114033. */
  114034. serialize(): any;
  114035. /**
  114036. * Parses a JSON object correponding to the serialize function.
  114037. */
  114038. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  114039. }
  114040. }
  114041. declare module BABYLON {
  114042. /**
  114043. * The PBR material of BJS following the specular glossiness convention.
  114044. *
  114045. * This fits to the PBR convention in the GLTF definition:
  114046. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  114047. */
  114048. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  114049. /**
  114050. * Specifies the diffuse color of the material.
  114051. */
  114052. diffuseColor: Color3;
  114053. /**
  114054. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  114055. * channel.
  114056. */
  114057. diffuseTexture: BaseTexture;
  114058. /**
  114059. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  114060. */
  114061. specularColor: Color3;
  114062. /**
  114063. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  114064. */
  114065. glossiness: number;
  114066. /**
  114067. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  114068. */
  114069. specularGlossinessTexture: BaseTexture;
  114070. /**
  114071. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  114072. *
  114073. * @param name The material name
  114074. * @param scene The scene the material will be use in.
  114075. */
  114076. constructor(name: string, scene: Scene);
  114077. /**
  114078. * Return the currrent class name of the material.
  114079. */
  114080. getClassName(): string;
  114081. /**
  114082. * Makes a duplicate of the current material.
  114083. * @param name - name to use for the new material.
  114084. */
  114085. clone(name: string): PBRSpecularGlossinessMaterial;
  114086. /**
  114087. * Serialize the material to a parsable JSON object.
  114088. */
  114089. serialize(): any;
  114090. /**
  114091. * Parses a JSON object correponding to the serialize function.
  114092. */
  114093. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  114094. }
  114095. }
  114096. declare module BABYLON {
  114097. /**
  114098. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  114099. * It can help converting any input color in a desired output one. This can then be used to create effects
  114100. * from sepia, black and white to sixties or futuristic rendering...
  114101. *
  114102. * The only supported format is currently 3dl.
  114103. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  114104. */
  114105. export class ColorGradingTexture extends BaseTexture {
  114106. /**
  114107. * The current texture matrix. (will always be identity in color grading texture)
  114108. */
  114109. private _textureMatrix;
  114110. /**
  114111. * The texture URL.
  114112. */
  114113. url: string;
  114114. /**
  114115. * Empty line regex stored for GC.
  114116. */
  114117. private static _noneEmptyLineRegex;
  114118. private _engine;
  114119. /**
  114120. * Instantiates a ColorGradingTexture from the following parameters.
  114121. *
  114122. * @param url The location of the color gradind data (currently only supporting 3dl)
  114123. * @param scene The scene the texture will be used in
  114124. */
  114125. constructor(url: string, scene: Scene);
  114126. /**
  114127. * Returns the texture matrix used in most of the material.
  114128. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  114129. */
  114130. getTextureMatrix(): Matrix;
  114131. /**
  114132. * Occurs when the file being loaded is a .3dl LUT file.
  114133. */
  114134. private load3dlTexture;
  114135. /**
  114136. * Starts the loading process of the texture.
  114137. */
  114138. private loadTexture;
  114139. /**
  114140. * Clones the color gradind texture.
  114141. */
  114142. clone(): ColorGradingTexture;
  114143. /**
  114144. * Called during delayed load for textures.
  114145. */
  114146. delayLoad(): void;
  114147. /**
  114148. * Parses a color grading texture serialized by Babylon.
  114149. * @param parsedTexture The texture information being parsedTexture
  114150. * @param scene The scene to load the texture in
  114151. * @param rootUrl The root url of the data assets to load
  114152. * @return A color gradind texture
  114153. */
  114154. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  114155. /**
  114156. * Serializes the LUT texture to json format.
  114157. */
  114158. serialize(): any;
  114159. }
  114160. }
  114161. declare module BABYLON {
  114162. /**
  114163. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  114164. */
  114165. export class EquiRectangularCubeTexture extends BaseTexture {
  114166. /** The six faces of the cube. */
  114167. private static _FacesMapping;
  114168. private _noMipmap;
  114169. private _onLoad;
  114170. private _onError;
  114171. /** The size of the cubemap. */
  114172. private _size;
  114173. /** The buffer of the image. */
  114174. private _buffer;
  114175. /** The width of the input image. */
  114176. private _width;
  114177. /** The height of the input image. */
  114178. private _height;
  114179. /** The URL to the image. */
  114180. url: string;
  114181. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  114182. coordinatesMode: number;
  114183. /**
  114184. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  114185. * @param url The location of the image
  114186. * @param scene The scene the texture will be used in
  114187. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114188. * @param noMipmap Forces to not generate the mipmap if true
  114189. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114190. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114191. * @param onLoad — defines a callback called when texture is loaded
  114192. * @param onError — defines a callback called if there is an error
  114193. */
  114194. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  114195. /**
  114196. * Load the image data, by putting the image on a canvas and extracting its buffer.
  114197. */
  114198. private loadImage;
  114199. /**
  114200. * Convert the image buffer into a cubemap and create a CubeTexture.
  114201. */
  114202. private loadTexture;
  114203. /**
  114204. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  114205. * @param buffer The ArrayBuffer that should be converted.
  114206. * @returns The buffer as Float32Array.
  114207. */
  114208. private getFloat32ArrayFromArrayBuffer;
  114209. /**
  114210. * Get the current class name of the texture useful for serialization or dynamic coding.
  114211. * @returns "EquiRectangularCubeTexture"
  114212. */
  114213. getClassName(): string;
  114214. /**
  114215. * Create a clone of the current EquiRectangularCubeTexture and return it.
  114216. * @returns A clone of the current EquiRectangularCubeTexture.
  114217. */
  114218. clone(): EquiRectangularCubeTexture;
  114219. }
  114220. }
  114221. declare module BABYLON {
  114222. /**
  114223. * Based on jsTGALoader - Javascript loader for TGA file
  114224. * By Vincent Thibault
  114225. * @see http://blog.robrowser.com/javascript-tga-loader.html
  114226. */
  114227. export class TGATools {
  114228. private static _TYPE_INDEXED;
  114229. private static _TYPE_RGB;
  114230. private static _TYPE_GREY;
  114231. private static _TYPE_RLE_INDEXED;
  114232. private static _TYPE_RLE_RGB;
  114233. private static _TYPE_RLE_GREY;
  114234. private static _ORIGIN_MASK;
  114235. private static _ORIGIN_SHIFT;
  114236. private static _ORIGIN_BL;
  114237. private static _ORIGIN_BR;
  114238. private static _ORIGIN_UL;
  114239. private static _ORIGIN_UR;
  114240. /**
  114241. * Gets the header of a TGA file
  114242. * @param data defines the TGA data
  114243. * @returns the header
  114244. */
  114245. static GetTGAHeader(data: Uint8Array): any;
  114246. /**
  114247. * Uploads TGA content to a Babylon Texture
  114248. * @hidden
  114249. */
  114250. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  114251. /** @hidden */
  114252. 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;
  114253. /** @hidden */
  114254. 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;
  114255. /** @hidden */
  114256. 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;
  114257. /** @hidden */
  114258. 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;
  114259. /** @hidden */
  114260. 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;
  114261. /** @hidden */
  114262. 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;
  114263. }
  114264. }
  114265. declare module BABYLON {
  114266. /**
  114267. * Implementation of the TGA Texture Loader.
  114268. * @hidden
  114269. */
  114270. export class _TGATextureLoader implements IInternalTextureLoader {
  114271. /**
  114272. * Defines wether the loader supports cascade loading the different faces.
  114273. */
  114274. readonly supportCascades: boolean;
  114275. /**
  114276. * This returns if the loader support the current file information.
  114277. * @param extension defines the file extension of the file being loaded
  114278. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114279. * @param fallback defines the fallback internal texture if any
  114280. * @param isBase64 defines whether the texture is encoded as a base64
  114281. * @param isBuffer defines whether the texture data are stored as a buffer
  114282. * @returns true if the loader can load the specified file
  114283. */
  114284. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114285. /**
  114286. * Transform the url before loading if required.
  114287. * @param rootUrl the url of the texture
  114288. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114289. * @returns the transformed texture
  114290. */
  114291. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114292. /**
  114293. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114294. * @param rootUrl the url of the texture
  114295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114296. * @returns the fallback texture
  114297. */
  114298. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114299. /**
  114300. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114301. * @param data contains the texture data
  114302. * @param texture defines the BabylonJS internal texture
  114303. * @param createPolynomials will be true if polynomials have been requested
  114304. * @param onLoad defines the callback to trigger once the texture is ready
  114305. * @param onError defines the callback to trigger in case of error
  114306. */
  114307. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114308. /**
  114309. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114310. * @param data contains the texture data
  114311. * @param texture defines the BabylonJS internal texture
  114312. * @param callback defines the method to call once ready to upload
  114313. */
  114314. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114315. }
  114316. }
  114317. declare module BABYLON {
  114318. /**
  114319. * Info about the .basis files
  114320. */
  114321. class BasisFileInfo {
  114322. /**
  114323. * If the file has alpha
  114324. */
  114325. hasAlpha: boolean;
  114326. /**
  114327. * Info about each image of the basis file
  114328. */
  114329. images: Array<{
  114330. levels: Array<{
  114331. width: number;
  114332. height: number;
  114333. transcodedPixels: ArrayBufferView;
  114334. }>;
  114335. }>;
  114336. }
  114337. /**
  114338. * Result of transcoding a basis file
  114339. */
  114340. class TranscodeResult {
  114341. /**
  114342. * Info about the .basis file
  114343. */
  114344. fileInfo: BasisFileInfo;
  114345. /**
  114346. * Format to use when loading the file
  114347. */
  114348. format: number;
  114349. }
  114350. /**
  114351. * Configuration options for the Basis transcoder
  114352. */
  114353. export class BasisTranscodeConfiguration {
  114354. /**
  114355. * Supported compression formats used to determine the supported output format of the transcoder
  114356. */
  114357. supportedCompressionFormats?: {
  114358. /**
  114359. * etc1 compression format
  114360. */
  114361. etc1?: boolean;
  114362. /**
  114363. * s3tc compression format
  114364. */
  114365. s3tc?: boolean;
  114366. /**
  114367. * pvrtc compression format
  114368. */
  114369. pvrtc?: boolean;
  114370. /**
  114371. * etc2 compression format
  114372. */
  114373. etc2?: boolean;
  114374. };
  114375. /**
  114376. * If mipmap levels should be loaded for transcoded images (Default: true)
  114377. */
  114378. loadMipmapLevels?: boolean;
  114379. /**
  114380. * Index of a single image to load (Default: all images)
  114381. */
  114382. loadSingleImage?: number;
  114383. }
  114384. /**
  114385. * Used to load .Basis files
  114386. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  114387. */
  114388. export class BasisTools {
  114389. private static _IgnoreSupportedFormats;
  114390. /**
  114391. * URL to use when loading the basis transcoder
  114392. */
  114393. static JSModuleURL: string;
  114394. /**
  114395. * URL to use when loading the wasm module for the transcoder
  114396. */
  114397. static WasmModuleURL: string;
  114398. /**
  114399. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  114400. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  114401. * @returns internal format corresponding to the Basis format
  114402. */
  114403. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  114404. private static _WorkerPromise;
  114405. private static _Worker;
  114406. private static _actionId;
  114407. private static _CreateWorkerAsync;
  114408. /**
  114409. * Transcodes a loaded image file to compressed pixel data
  114410. * @param imageData image data to transcode
  114411. * @param config configuration options for the transcoding
  114412. * @returns a promise resulting in the transcoded image
  114413. */
  114414. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  114415. /**
  114416. * Loads a texture from the transcode result
  114417. * @param texture texture load to
  114418. * @param transcodeResult the result of transcoding the basis file to load from
  114419. */
  114420. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  114421. }
  114422. }
  114423. declare module BABYLON {
  114424. /**
  114425. * Loader for .basis file format
  114426. */
  114427. export class _BasisTextureLoader implements IInternalTextureLoader {
  114428. /**
  114429. * Defines whether the loader supports cascade loading the different faces.
  114430. */
  114431. readonly supportCascades: boolean;
  114432. /**
  114433. * This returns if the loader support the current file information.
  114434. * @param extension defines the file extension of the file being loaded
  114435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114436. * @param fallback defines the fallback internal texture if any
  114437. * @param isBase64 defines whether the texture is encoded as a base64
  114438. * @param isBuffer defines whether the texture data are stored as a buffer
  114439. * @returns true if the loader can load the specified file
  114440. */
  114441. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114442. /**
  114443. * Transform the url before loading if required.
  114444. * @param rootUrl the url of the texture
  114445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114446. * @returns the transformed texture
  114447. */
  114448. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114449. /**
  114450. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114451. * @param rootUrl the url of the texture
  114452. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114453. * @returns the fallback texture
  114454. */
  114455. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114456. /**
  114457. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  114458. * @param data contains the texture data
  114459. * @param texture defines the BabylonJS internal texture
  114460. * @param createPolynomials will be true if polynomials have been requested
  114461. * @param onLoad defines the callback to trigger once the texture is ready
  114462. * @param onError defines the callback to trigger in case of error
  114463. */
  114464. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114465. /**
  114466. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114467. * @param data contains the texture data
  114468. * @param texture defines the BabylonJS internal texture
  114469. * @param callback defines the method to call once ready to upload
  114470. */
  114471. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114472. }
  114473. }
  114474. declare module BABYLON {
  114475. /**
  114476. * 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.
  114477. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114478. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114479. */
  114480. export class CustomProceduralTexture extends ProceduralTexture {
  114481. private _animate;
  114482. private _time;
  114483. private _config;
  114484. private _texturePath;
  114485. /**
  114486. * Instantiates a new Custom Procedural Texture.
  114487. * 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.
  114488. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114489. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114490. * @param name Define the name of the texture
  114491. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  114492. * @param size Define the size of the texture to create
  114493. * @param scene Define the scene the texture belongs to
  114494. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  114495. * @param generateMipMaps Define if the texture should creates mip maps or not
  114496. */
  114497. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114498. private _loadJson;
  114499. /**
  114500. * Is the texture ready to be used ? (rendered at least once)
  114501. * @returns true if ready, otherwise, false.
  114502. */
  114503. isReady(): boolean;
  114504. /**
  114505. * Render the texture to its associated render target.
  114506. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  114507. */
  114508. render(useCameraPostProcess?: boolean): void;
  114509. /**
  114510. * Update the list of dependant textures samplers in the shader.
  114511. */
  114512. updateTextures(): void;
  114513. /**
  114514. * Update the uniform values of the procedural texture in the shader.
  114515. */
  114516. updateShaderUniforms(): void;
  114517. /**
  114518. * Define if the texture animates or not.
  114519. */
  114520. animate: boolean;
  114521. }
  114522. }
  114523. declare module BABYLON {
  114524. /** @hidden */
  114525. export var noisePixelShader: {
  114526. name: string;
  114527. shader: string;
  114528. };
  114529. }
  114530. declare module BABYLON {
  114531. /**
  114532. * Class used to generate noise procedural textures
  114533. */
  114534. export class NoiseProceduralTexture extends ProceduralTexture {
  114535. private _time;
  114536. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  114537. brightness: number;
  114538. /** Defines the number of octaves to process */
  114539. octaves: number;
  114540. /** Defines the level of persistence (0.8 by default) */
  114541. persistence: number;
  114542. /** Gets or sets animation speed factor (default is 1) */
  114543. animationSpeedFactor: number;
  114544. /**
  114545. * Creates a new NoiseProceduralTexture
  114546. * @param name defines the name fo the texture
  114547. * @param size defines the size of the texture (default is 256)
  114548. * @param scene defines the hosting scene
  114549. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  114550. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  114551. */
  114552. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114553. private _updateShaderUniforms;
  114554. protected _getDefines(): string;
  114555. /** Generate the current state of the procedural texture */
  114556. render(useCameraPostProcess?: boolean): void;
  114557. /**
  114558. * Serializes this noise procedural texture
  114559. * @returns a serialized noise procedural texture object
  114560. */
  114561. serialize(): any;
  114562. /**
  114563. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  114564. * @param parsedTexture defines parsed texture data
  114565. * @param scene defines the current scene
  114566. * @param rootUrl defines the root URL containing noise procedural texture information
  114567. * @returns a parsed NoiseProceduralTexture
  114568. */
  114569. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  114570. }
  114571. }
  114572. declare module BABYLON {
  114573. /**
  114574. * Raw cube texture where the raw buffers are passed in
  114575. */
  114576. export class RawCubeTexture extends CubeTexture {
  114577. /**
  114578. * Creates a cube texture where the raw buffers are passed in.
  114579. * @param scene defines the scene the texture is attached to
  114580. * @param data defines the array of data to use to create each face
  114581. * @param size defines the size of the textures
  114582. * @param format defines the format of the data
  114583. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  114584. * @param generateMipMaps defines if the engine should generate the mip levels
  114585. * @param invertY defines if data must be stored with Y axis inverted
  114586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  114587. * @param compression defines the compression used (null by default)
  114588. */
  114589. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  114590. /**
  114591. * Updates the raw cube texture.
  114592. * @param data defines the data to store
  114593. * @param format defines the data format
  114594. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114595. * @param invertY defines if data must be stored with Y axis inverted
  114596. * @param compression defines the compression used (null by default)
  114597. * @param level defines which level of the texture to update
  114598. */
  114599. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  114600. /**
  114601. * Updates a raw cube texture with RGBD encoded data.
  114602. * @param data defines the array of data [mipmap][face] to use to create each face
  114603. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  114604. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114605. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114606. * @returns a promsie that resolves when the operation is complete
  114607. */
  114608. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  114609. /**
  114610. * Clones the raw cube texture.
  114611. * @return a new cube texture
  114612. */
  114613. clone(): CubeTexture;
  114614. /** @hidden */
  114615. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114616. }
  114617. }
  114618. declare module BABYLON {
  114619. /**
  114620. * Class used to store 3D textures containing user data
  114621. */
  114622. export class RawTexture3D extends Texture {
  114623. /** Gets or sets the texture format to use */
  114624. format: number;
  114625. private _engine;
  114626. /**
  114627. * Create a new RawTexture3D
  114628. * @param data defines the data of the texture
  114629. * @param width defines the width of the texture
  114630. * @param height defines the height of the texture
  114631. * @param depth defines the depth of the texture
  114632. * @param format defines the texture format to use
  114633. * @param scene defines the hosting scene
  114634. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  114635. * @param invertY defines if texture must be stored with Y axis inverted
  114636. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114637. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  114638. */
  114639. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  114640. /** Gets or sets the texture format to use */
  114641. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  114642. /**
  114643. * Update the texture with new data
  114644. * @param data defines the data to store in the texture
  114645. */
  114646. update(data: ArrayBufferView): void;
  114647. }
  114648. }
  114649. declare module BABYLON {
  114650. /**
  114651. * Creates a refraction texture used by refraction channel of the standard material.
  114652. * It is like a mirror but to see through a material.
  114653. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114654. */
  114655. export class RefractionTexture extends RenderTargetTexture {
  114656. /**
  114657. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  114658. * 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.
  114659. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114660. */
  114661. refractionPlane: Plane;
  114662. /**
  114663. * Define how deep under the surface we should see.
  114664. */
  114665. depth: number;
  114666. /**
  114667. * Creates a refraction texture used by refraction channel of the standard material.
  114668. * It is like a mirror but to see through a material.
  114669. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114670. * @param name Define the texture name
  114671. * @param size Define the size of the underlying texture
  114672. * @param scene Define the scene the refraction belongs to
  114673. * @param generateMipMaps Define if we need to generate mips level for the refraction
  114674. */
  114675. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  114676. /**
  114677. * Clone the refraction texture.
  114678. * @returns the cloned texture
  114679. */
  114680. clone(): RefractionTexture;
  114681. /**
  114682. * Serialize the texture to a JSON representation you could use in Parse later on
  114683. * @returns the serialized JSON representation
  114684. */
  114685. serialize(): any;
  114686. }
  114687. }
  114688. declare module BABYLON {
  114689. /**
  114690. * Defines the options related to the creation of an HtmlElementTexture
  114691. */
  114692. export interface IHtmlElementTextureOptions {
  114693. /**
  114694. * Defines wether mip maps should be created or not.
  114695. */
  114696. generateMipMaps?: boolean;
  114697. /**
  114698. * Defines the sampling mode of the texture.
  114699. */
  114700. samplingMode?: number;
  114701. /**
  114702. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  114703. */
  114704. engine: Nullable<Engine>;
  114705. /**
  114706. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  114707. */
  114708. scene: Nullable<Scene>;
  114709. }
  114710. /**
  114711. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  114712. * To be as efficient as possible depending on your constraints nothing aside the first upload
  114713. * is automatically managed.
  114714. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  114715. * in your application.
  114716. *
  114717. * As the update is not automatic, you need to call them manually.
  114718. */
  114719. export class HtmlElementTexture extends BaseTexture {
  114720. /**
  114721. * The texture URL.
  114722. */
  114723. element: HTMLVideoElement | HTMLCanvasElement;
  114724. private static readonly DefaultOptions;
  114725. private _textureMatrix;
  114726. private _engine;
  114727. private _isVideo;
  114728. private _generateMipMaps;
  114729. private _samplingMode;
  114730. /**
  114731. * Instantiates a HtmlElementTexture from the following parameters.
  114732. *
  114733. * @param name Defines the name of the texture
  114734. * @param element Defines the video or canvas the texture is filled with
  114735. * @param options Defines the other none mandatory texture creation options
  114736. */
  114737. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  114738. private _createInternalTexture;
  114739. /**
  114740. * Returns the texture matrix used in most of the material.
  114741. */
  114742. getTextureMatrix(): Matrix;
  114743. /**
  114744. * Updates the content of the texture.
  114745. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  114746. */
  114747. update(invertY?: Nullable<boolean>): void;
  114748. }
  114749. }
  114750. declare module BABYLON {
  114751. /**
  114752. * Enum used to define the target of a block
  114753. */
  114754. export enum NodeMaterialBlockTargets {
  114755. /** Vertex shader */
  114756. Vertex = 1,
  114757. /** Fragment shader */
  114758. Fragment = 2,
  114759. /** Neutral */
  114760. Neutral = 4,
  114761. /** Vertex and Fragment */
  114762. VertexAndFragment = 3
  114763. }
  114764. }
  114765. declare module BABYLON {
  114766. /**
  114767. * Defines the kind of connection point for node based material
  114768. */
  114769. export enum NodeMaterialBlockConnectionPointTypes {
  114770. /** Float */
  114771. Float = 1,
  114772. /** Int */
  114773. Int = 2,
  114774. /** Vector2 */
  114775. Vector2 = 4,
  114776. /** Vector3 */
  114777. Vector3 = 8,
  114778. /** Vector4 */
  114779. Vector4 = 16,
  114780. /** Color3 */
  114781. Color3 = 32,
  114782. /** Color4 */
  114783. Color4 = 64,
  114784. /** Matrix */
  114785. Matrix = 128,
  114786. /** Vector3 or Color3 */
  114787. Vector3OrColor3 = 40,
  114788. /** Vector3 or Vector4 */
  114789. Vector3OrVector4 = 24,
  114790. /** Vector4 or Color4 */
  114791. Vector4OrColor4 = 80,
  114792. /** Color3 or Color4 */
  114793. Color3OrColor4 = 96,
  114794. /** Vector2 or Color3 or Color4 */
  114795. Vector2OrColor3OrColor4 = 100,
  114796. /** Vector3 or Color3 or Color4 or Vector4 */
  114797. Vector3OrColor3OrVector4OrColor4 = 120,
  114798. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  114799. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  114800. /** Detect type based on connection */
  114801. AutoDetect = 1024,
  114802. /** Output type that will be defined by input type */
  114803. BasedOnInput = 2048
  114804. }
  114805. }
  114806. declare module BABYLON {
  114807. /**
  114808. * Root class for all node material optimizers
  114809. */
  114810. export class NodeMaterialOptimizer {
  114811. /**
  114812. * Function used to optimize a NodeMaterial graph
  114813. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  114814. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  114815. */
  114816. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  114817. }
  114818. }
  114819. declare module BABYLON {
  114820. /**
  114821. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  114822. */
  114823. export class TransformBlock extends NodeMaterialBlock {
  114824. /**
  114825. * Defines the value to use to complement W value to transform it to a Vector4
  114826. */
  114827. complementW: number;
  114828. /**
  114829. * Defines the value to use to complement z value to transform it to a Vector4
  114830. */
  114831. complementZ: number;
  114832. /**
  114833. * Creates a new TransformBlock
  114834. * @param name defines the block name
  114835. */
  114836. constructor(name: string);
  114837. /**
  114838. * Gets the current class name
  114839. * @returns the class name
  114840. */
  114841. getClassName(): string;
  114842. /**
  114843. * Gets the vector input
  114844. */
  114845. readonly vector: NodeMaterialConnectionPoint;
  114846. /**
  114847. * Gets the output component
  114848. */
  114849. readonly output: NodeMaterialConnectionPoint;
  114850. /**
  114851. * Gets the matrix transform input
  114852. */
  114853. readonly transform: NodeMaterialConnectionPoint;
  114854. protected _buildBlock(state: NodeMaterialBuildState): this;
  114855. }
  114856. }
  114857. declare module BABYLON {
  114858. /**
  114859. * Block used to output the vertex position
  114860. */
  114861. export class VertexOutputBlock extends NodeMaterialBlock {
  114862. /**
  114863. * Creates a new VertexOutputBlock
  114864. * @param name defines the block name
  114865. */
  114866. constructor(name: string);
  114867. /**
  114868. * Gets the current class name
  114869. * @returns the class name
  114870. */
  114871. getClassName(): string;
  114872. /**
  114873. * Gets the vector input component
  114874. */
  114875. readonly vector: NodeMaterialConnectionPoint;
  114876. protected _buildBlock(state: NodeMaterialBuildState): this;
  114877. }
  114878. }
  114879. declare module BABYLON {
  114880. /**
  114881. * Block used to output the final color
  114882. */
  114883. export class FragmentOutputBlock extends NodeMaterialBlock {
  114884. /**
  114885. * Gets or sets a boolean indicating if this block will output an alpha value
  114886. */
  114887. alphaBlendingEnabled: boolean;
  114888. /**
  114889. * Create a new FragmentOutputBlock
  114890. * @param name defines the block name
  114891. */
  114892. constructor(name: string);
  114893. /**
  114894. * Gets the current class name
  114895. * @returns the class name
  114896. */
  114897. getClassName(): string;
  114898. /**
  114899. * Gets the color input component
  114900. */
  114901. readonly color: NodeMaterialConnectionPoint;
  114902. protected _buildBlock(state: NodeMaterialBuildState): this;
  114903. }
  114904. }
  114905. declare module BABYLON {
  114906. /**
  114907. * Interface used to configure the node material editor
  114908. */
  114909. export interface INodeMaterialEditorOptions {
  114910. /** Define the URl to load node editor script */
  114911. editorURL?: string;
  114912. }
  114913. /** @hidden */
  114914. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  114915. /** BONES */
  114916. NUM_BONE_INFLUENCERS: number;
  114917. BonesPerMesh: number;
  114918. BONETEXTURE: boolean;
  114919. /** MORPH TARGETS */
  114920. MORPHTARGETS: boolean;
  114921. MORPHTARGETS_NORMAL: boolean;
  114922. MORPHTARGETS_TANGENT: boolean;
  114923. MORPHTARGETS_UV: boolean;
  114924. NUM_MORPH_INFLUENCERS: number;
  114925. /** IMAGE PROCESSING */
  114926. IMAGEPROCESSING: boolean;
  114927. VIGNETTE: boolean;
  114928. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114929. VIGNETTEBLENDMODEOPAQUE: boolean;
  114930. TONEMAPPING: boolean;
  114931. TONEMAPPING_ACES: boolean;
  114932. CONTRAST: boolean;
  114933. EXPOSURE: boolean;
  114934. COLORCURVES: boolean;
  114935. COLORGRADING: boolean;
  114936. COLORGRADING3D: boolean;
  114937. SAMPLER3DGREENDEPTH: boolean;
  114938. SAMPLER3DBGRMAP: boolean;
  114939. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114940. constructor();
  114941. setValue(name: string, value: boolean): void;
  114942. }
  114943. /**
  114944. * Class used to configure NodeMaterial
  114945. */
  114946. export interface INodeMaterialOptions {
  114947. /**
  114948. * Defines if blocks should emit comments
  114949. */
  114950. emitComments: boolean;
  114951. }
  114952. /**
  114953. * Class used to create a node based material built by assembling shader blocks
  114954. */
  114955. export class NodeMaterial extends PushMaterial {
  114956. private _options;
  114957. private _vertexCompilationState;
  114958. private _fragmentCompilationState;
  114959. private _sharedData;
  114960. private _buildId;
  114961. private _buildWasSuccessful;
  114962. private _cachedWorldViewMatrix;
  114963. private _cachedWorldViewProjectionMatrix;
  114964. private _optimizers;
  114965. /** Define the URl to load node editor script */
  114966. static EditorURL: string;
  114967. private BJSNODEMATERIALEDITOR;
  114968. /** Get the inspector from bundle or global */
  114969. private _getGlobalNodeMaterialEditor;
  114970. /**
  114971. * Defines the maximum number of lights that can be used in the material
  114972. */
  114973. maxSimultaneousLights: number;
  114974. /**
  114975. * Observable raised when the material is built
  114976. */
  114977. onBuildObservable: Observable<NodeMaterial>;
  114978. /**
  114979. * Gets or sets the root nodes of the material vertex shader
  114980. */
  114981. _vertexOutputNodes: NodeMaterialBlock[];
  114982. /**
  114983. * Gets or sets the root nodes of the material fragment (pixel) shader
  114984. */
  114985. _fragmentOutputNodes: NodeMaterialBlock[];
  114986. /** Gets or sets options to control the node material overall behavior */
  114987. options: INodeMaterialOptions;
  114988. /**
  114989. * Default configuration related to image processing available in the standard Material.
  114990. */
  114991. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114992. /**
  114993. * Gets the image processing configuration used either in this material.
  114994. */
  114995. /**
  114996. * Sets the Default image processing configuration used either in the this material.
  114997. *
  114998. * If sets to null, the scene one is in use.
  114999. */
  115000. imageProcessingConfiguration: ImageProcessingConfiguration;
  115001. /**
  115002. * Create a new node based material
  115003. * @param name defines the material name
  115004. * @param scene defines the hosting scene
  115005. * @param options defines creation option
  115006. */
  115007. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  115008. /**
  115009. * Gets the current class name of the material e.g. "NodeMaterial"
  115010. * @returns the class name
  115011. */
  115012. getClassName(): string;
  115013. /**
  115014. * Keep track of the image processing observer to allow dispose and replace.
  115015. */
  115016. private _imageProcessingObserver;
  115017. /**
  115018. * Attaches a new image processing configuration to the Standard Material.
  115019. * @param configuration
  115020. */
  115021. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115022. /**
  115023. * Adds a new optimizer to the list of optimizers
  115024. * @param optimizer defines the optimizers to add
  115025. * @returns the current material
  115026. */
  115027. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115028. /**
  115029. * Remove an optimizer from the list of optimizers
  115030. * @param optimizer defines the optimizers to remove
  115031. * @returns the current material
  115032. */
  115033. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115034. /**
  115035. * Add a new block to the list of output nodes
  115036. * @param node defines the node to add
  115037. * @returns the current material
  115038. */
  115039. addOutputNode(node: NodeMaterialBlock): this;
  115040. /**
  115041. * Remove a block from the list of root nodes
  115042. * @param node defines the node to remove
  115043. * @returns the current material
  115044. */
  115045. removeOutputNode(node: NodeMaterialBlock): this;
  115046. private _addVertexOutputNode;
  115047. private _removeVertexOutputNode;
  115048. private _addFragmentOutputNode;
  115049. private _removeFragmentOutputNode;
  115050. /**
  115051. * Specifies if the material will require alpha blending
  115052. * @returns a boolean specifying if alpha blending is needed
  115053. */
  115054. needAlphaBlending(): boolean;
  115055. /**
  115056. * Specifies if this material should be rendered in alpha test mode
  115057. * @returns a boolean specifying if an alpha test is needed.
  115058. */
  115059. needAlphaTesting(): boolean;
  115060. private _initializeBlock;
  115061. private _resetDualBlocks;
  115062. /**
  115063. * Build the material and generates the inner effect
  115064. * @param verbose defines if the build should log activity
  115065. */
  115066. build(verbose?: boolean): void;
  115067. /**
  115068. * Runs an otpimization phase to try to improve the shader code
  115069. */
  115070. optimize(): void;
  115071. private _prepareDefinesForAttributes;
  115072. /**
  115073. * Get if the submesh is ready to be used and all its information available.
  115074. * Child classes can use it to update shaders
  115075. * @param mesh defines the mesh to check
  115076. * @param subMesh defines which submesh to check
  115077. * @param useInstances specifies that instances should be used
  115078. * @returns a boolean indicating that the submesh is ready or not
  115079. */
  115080. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115081. /**
  115082. * Get a string representing the shaders built by the current node graph
  115083. */
  115084. readonly compiledShaders: string;
  115085. /**
  115086. * Binds the world matrix to the material
  115087. * @param world defines the world transformation matrix
  115088. */
  115089. bindOnlyWorldMatrix(world: Matrix): void;
  115090. /**
  115091. * Binds the submesh to this material by preparing the effect and shader to draw
  115092. * @param world defines the world transformation matrix
  115093. * @param mesh defines the mesh containing the submesh
  115094. * @param subMesh defines the submesh to bind the material to
  115095. */
  115096. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115097. /**
  115098. * Gets the active textures from the material
  115099. * @returns an array of textures
  115100. */
  115101. getActiveTextures(): BaseTexture[];
  115102. /**
  115103. * Specifies if the material uses a texture
  115104. * @param texture defines the texture to check against the material
  115105. * @returns a boolean specifying if the material uses the texture
  115106. */
  115107. hasTexture(texture: BaseTexture): boolean;
  115108. /**
  115109. * Disposes the material
  115110. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115111. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115112. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115113. */
  115114. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115115. /** Creates the node editor window. */
  115116. private _createNodeEditor;
  115117. /**
  115118. * Launch the node material editor
  115119. * @param config Define the configuration of the editor
  115120. * @return a promise fulfilled when the node editor is visible
  115121. */
  115122. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  115123. /**
  115124. * Clear the current material
  115125. */
  115126. clear(): void;
  115127. /**
  115128. * Clear the current material and set it to a default state
  115129. */
  115130. setToDefault(): void;
  115131. private _gatherBlocks;
  115132. /**
  115133. * Serializes this material in a JSON representation
  115134. * @returns the serialized material object
  115135. */
  115136. serialize(): any;
  115137. /**
  115138. * Clear the current graph and load a new one from a serialization object
  115139. * @param source defines the JSON representation of the material
  115140. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115141. */
  115142. loadFromSerialization(source: any, rootUrl?: string): void;
  115143. /**
  115144. * Creates a node material from parsed material data
  115145. * @param source defines the JSON representation of the material
  115146. * @param scene defines the hosting scene
  115147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115148. * @returns a new node material
  115149. */
  115150. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  115151. }
  115152. }
  115153. declare module BABYLON {
  115154. /**
  115155. * Block used to read a texture from a sampler
  115156. */
  115157. export class TextureBlock extends NodeMaterialBlock {
  115158. private _defineName;
  115159. private _samplerName;
  115160. private _transformedUVName;
  115161. private _textureTransformName;
  115162. private _textureInfoName;
  115163. private _mainUVName;
  115164. private _mainUVDefineName;
  115165. /**
  115166. * Gets or sets the texture associated with the node
  115167. */
  115168. texture: Nullable<BaseTexture>;
  115169. /**
  115170. * Create a new TextureBlock
  115171. * @param name defines the block name
  115172. */
  115173. constructor(name: string);
  115174. /**
  115175. * Gets the current class name
  115176. * @returns the class name
  115177. */
  115178. getClassName(): string;
  115179. /**
  115180. * Gets the uv input component
  115181. */
  115182. readonly uv: NodeMaterialConnectionPoint;
  115183. /**
  115184. * Gets the output component
  115185. */
  115186. readonly output: NodeMaterialConnectionPoint;
  115187. autoConfigure(): void;
  115188. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115189. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115190. isReady(): boolean;
  115191. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115192. private _injectVertexCode;
  115193. private _writeOutput;
  115194. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115195. serialize(): any;
  115196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115197. }
  115198. }
  115199. declare module BABYLON {
  115200. /**
  115201. * Class used to store shared data between 2 NodeMaterialBuildState
  115202. */
  115203. export class NodeMaterialBuildStateSharedData {
  115204. /**
  115205. * Gets the list of emitted varyings
  115206. */
  115207. varyings: string[];
  115208. /**
  115209. * Gets the varying declaration string
  115210. */
  115211. varyingDeclaration: string;
  115212. /**
  115213. * Input blocks
  115214. */
  115215. inputBlocks: InputBlock[];
  115216. /**
  115217. * Input blocks
  115218. */
  115219. textureBlocks: TextureBlock[];
  115220. /**
  115221. * Bindable blocks (Blocks that need to set data to the effect)
  115222. */
  115223. bindableBlocks: NodeMaterialBlock[];
  115224. /**
  115225. * List of blocks that can provide a compilation fallback
  115226. */
  115227. blocksWithFallbacks: NodeMaterialBlock[];
  115228. /**
  115229. * List of blocks that can provide a define update
  115230. */
  115231. blocksWithDefines: NodeMaterialBlock[];
  115232. /**
  115233. * List of blocks that can provide a repeatable content
  115234. */
  115235. repeatableContentBlocks: NodeMaterialBlock[];
  115236. /**
  115237. * List of blocks that can provide a dynamic list of uniforms
  115238. */
  115239. dynamicUniformBlocks: NodeMaterialBlock[];
  115240. /**
  115241. * List of blocks that can block the isReady function for the material
  115242. */
  115243. blockingBlocks: NodeMaterialBlock[];
  115244. /**
  115245. * Build Id used to avoid multiple recompilations
  115246. */
  115247. buildId: number;
  115248. /** List of emitted variables */
  115249. variableNames: {
  115250. [key: string]: number;
  115251. };
  115252. /** List of emitted defines */
  115253. defineNames: {
  115254. [key: string]: number;
  115255. };
  115256. /** Should emit comments? */
  115257. emitComments: boolean;
  115258. /** Emit build activity */
  115259. verbose: boolean;
  115260. /**
  115261. * Gets the compilation hints emitted at compilation time
  115262. */
  115263. hints: {
  115264. needWorldViewMatrix: boolean;
  115265. needWorldViewProjectionMatrix: boolean;
  115266. needAlphaBlending: boolean;
  115267. needAlphaTesting: boolean;
  115268. };
  115269. /**
  115270. * List of compilation checks
  115271. */
  115272. checks: {
  115273. emitVertex: boolean;
  115274. emitFragment: boolean;
  115275. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  115276. };
  115277. /** Creates a new shared data */
  115278. constructor();
  115279. /**
  115280. * Emits console errors and exceptions if there is a failing check
  115281. */
  115282. emitErrors(): void;
  115283. }
  115284. }
  115285. declare module BABYLON {
  115286. /**
  115287. * Class used to store node based material build state
  115288. */
  115289. export class NodeMaterialBuildState {
  115290. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  115291. supportUniformBuffers: boolean;
  115292. /**
  115293. * Gets the list of emitted attributes
  115294. */
  115295. attributes: string[];
  115296. /**
  115297. * Gets the list of emitted uniforms
  115298. */
  115299. uniforms: string[];
  115300. /**
  115301. * Gets the list of emitted uniform buffers
  115302. */
  115303. uniformBuffers: string[];
  115304. /**
  115305. * Gets the list of emitted samplers
  115306. */
  115307. samplers: string[];
  115308. /**
  115309. * Gets the list of emitted functions
  115310. */
  115311. functions: {
  115312. [key: string]: string;
  115313. };
  115314. /**
  115315. * Gets the target of the compilation state
  115316. */
  115317. target: NodeMaterialBlockTargets;
  115318. /**
  115319. * Gets the list of emitted counters
  115320. */
  115321. counters: {
  115322. [key: string]: number;
  115323. };
  115324. /**
  115325. * Shared data between multiple NodeMaterialBuildState instances
  115326. */
  115327. sharedData: NodeMaterialBuildStateSharedData;
  115328. /** @hidden */
  115329. _vertexState: NodeMaterialBuildState;
  115330. /** @hidden */
  115331. _attributeDeclaration: string;
  115332. /** @hidden */
  115333. _uniformDeclaration: string;
  115334. /** @hidden */
  115335. _samplerDeclaration: string;
  115336. /** @hidden */
  115337. _varyingTransfer: string;
  115338. private _repeatableContentAnchorIndex;
  115339. /** @hidden */
  115340. _builtCompilationString: string;
  115341. /**
  115342. * Gets the emitted compilation strings
  115343. */
  115344. compilationString: string;
  115345. /**
  115346. * Finalize the compilation strings
  115347. * @param state defines the current compilation state
  115348. */
  115349. finalize(state: NodeMaterialBuildState): void;
  115350. /** @hidden */
  115351. readonly _repeatableContentAnchor: string;
  115352. /** @hidden */
  115353. _getFreeVariableName(prefix: string): string;
  115354. /** @hidden */
  115355. _getFreeDefineName(prefix: string): string;
  115356. /** @hidden */
  115357. _excludeVariableName(name: string): void;
  115358. /** @hidden */
  115359. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  115360. /** @hidden */
  115361. _emitFunction(name: string, code: string, comments: string): void;
  115362. /** @hidden */
  115363. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  115364. replaceStrings?: {
  115365. search: RegExp;
  115366. replace: string;
  115367. }[];
  115368. repeatKey?: string;
  115369. }): string;
  115370. /** @hidden */
  115371. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  115372. repeatKey?: string;
  115373. removeAttributes?: boolean;
  115374. removeUniforms?: boolean;
  115375. removeVaryings?: boolean;
  115376. removeIfDef?: boolean;
  115377. replaceStrings?: {
  115378. search: RegExp;
  115379. replace: string;
  115380. }[];
  115381. }, storeKey?: string): void;
  115382. /** @hidden */
  115383. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115384. /** @hidden */
  115385. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115386. }
  115387. }
  115388. declare module BABYLON {
  115389. /**
  115390. * Defines a block that can be used inside a node based material
  115391. */
  115392. export class NodeMaterialBlock {
  115393. private _buildId;
  115394. private _buildTarget;
  115395. private _target;
  115396. private _isFinalMerger;
  115397. private _isInput;
  115398. /** @hidden */
  115399. _inputs: NodeMaterialConnectionPoint[];
  115400. /** @hidden */
  115401. _outputs: NodeMaterialConnectionPoint[];
  115402. /**
  115403. * Gets or sets the name of the block
  115404. */
  115405. name: string;
  115406. /**
  115407. * Gets or sets the unique id of the node
  115408. */
  115409. uniqueId: number;
  115410. /**
  115411. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  115412. */
  115413. readonly isFinalMerger: boolean;
  115414. /**
  115415. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  115416. */
  115417. readonly isInput: boolean;
  115418. /**
  115419. * Gets or sets the build Id
  115420. */
  115421. buildId: number;
  115422. /**
  115423. * Gets or sets the target of the block
  115424. */
  115425. target: NodeMaterialBlockTargets;
  115426. /**
  115427. * Gets the list of input points
  115428. */
  115429. readonly inputs: NodeMaterialConnectionPoint[];
  115430. /** Gets the list of output points */
  115431. readonly outputs: NodeMaterialConnectionPoint[];
  115432. /**
  115433. * Find an input by its name
  115434. * @param name defines the name of the input to look for
  115435. * @returns the input or null if not found
  115436. */
  115437. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115438. /**
  115439. * Find an output by its name
  115440. * @param name defines the name of the outputto look for
  115441. * @returns the output or null if not found
  115442. */
  115443. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115444. /**
  115445. * Creates a new NodeMaterialBlock
  115446. * @param name defines the block name
  115447. * @param target defines the target of that block (Vertex by default)
  115448. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  115449. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  115450. */
  115451. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  115452. /**
  115453. * Initialize the block and prepare the context for build
  115454. * @param state defines the state that will be used for the build
  115455. */
  115456. initialize(state: NodeMaterialBuildState): void;
  115457. /**
  115458. * Bind data to effect. Will only be called for blocks with isBindable === true
  115459. * @param effect defines the effect to bind data to
  115460. * @param nodeMaterial defines the hosting NodeMaterial
  115461. * @param mesh defines the mesh that will be rendered
  115462. */
  115463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115464. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  115465. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  115466. protected _writeFloat(value: number): string;
  115467. /**
  115468. * Gets the current class name e.g. "NodeMaterialBlock"
  115469. * @returns the class name
  115470. */
  115471. getClassName(): string;
  115472. /**
  115473. * Register a new input. Must be called inside a block constructor
  115474. * @param name defines the connection point name
  115475. * @param type defines the connection point type
  115476. * @param isOptional defines a boolean indicating that this input can be omitted
  115477. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115478. * @returns the current block
  115479. */
  115480. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  115481. /**
  115482. * Register a new output. Must be called inside a block constructor
  115483. * @param name defines the connection point name
  115484. * @param type defines the connection point type
  115485. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115486. * @returns the current block
  115487. */
  115488. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  115489. /**
  115490. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  115491. * @param forOutput defines an optional connection point to check compatibility with
  115492. * @returns the first available input or null
  115493. */
  115494. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  115495. /**
  115496. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  115497. * @param forBlock defines an optional block to check compatibility with
  115498. * @returns the first available input or null
  115499. */
  115500. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  115501. /**
  115502. * Connect current block with another block
  115503. * @param other defines the block to connect with
  115504. * @param options define the various options to help pick the right connections
  115505. * @returns the current block
  115506. */
  115507. connectTo(other: NodeMaterialBlock, options?: {
  115508. input?: string;
  115509. output?: string;
  115510. outputSwizzle?: string;
  115511. }): this | undefined;
  115512. protected _buildBlock(state: NodeMaterialBuildState): void;
  115513. /**
  115514. * Add uniforms, samplers and uniform buffers at compilation time
  115515. * @param state defines the state to update
  115516. * @param nodeMaterial defines the node material requesting the update
  115517. * @param defines defines the material defines to update
  115518. */
  115519. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115520. /**
  115521. * Add potential fallbacks if shader compilation fails
  115522. * @param mesh defines the mesh to be rendered
  115523. * @param fallbacks defines the current prioritized list of fallbacks
  115524. */
  115525. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  115526. /**
  115527. * Update defines for shader compilation
  115528. * @param mesh defines the mesh to be rendered
  115529. * @param nodeMaterial defines the node material requesting the update
  115530. * @param defines defines the material defines to update
  115531. * @param useInstances specifies that instances should be used
  115532. */
  115533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115534. /**
  115535. * Initialize defines for shader compilation
  115536. * @param mesh defines the mesh to be rendered
  115537. * @param nodeMaterial defines the node material requesting the update
  115538. * @param defines defines the material defines to be prepared
  115539. * @param useInstances specifies that instances should be used
  115540. */
  115541. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115542. /**
  115543. * Lets the block try to connect some inputs automatically
  115544. */
  115545. autoConfigure(): void;
  115546. /**
  115547. * Function called when a block is declared as repeatable content generator
  115548. * @param vertexShaderState defines the current compilation state for the vertex shader
  115549. * @param fragmentShaderState defines the current compilation state for the fragment shader
  115550. * @param mesh defines the mesh to be rendered
  115551. * @param defines defines the material defines to update
  115552. */
  115553. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  115554. /**
  115555. * Checks if the block is ready
  115556. * @param mesh defines the mesh to be rendered
  115557. * @param nodeMaterial defines the node material requesting the update
  115558. * @param defines defines the material defines to update
  115559. * @param useInstances specifies that instances should be used
  115560. * @returns true if the block is ready
  115561. */
  115562. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  115563. private _processBuild;
  115564. /**
  115565. * Compile the current node and generate the shader code
  115566. * @param state defines the current compilation state (uniforms, samplers, current string)
  115567. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  115568. * @returns true if already built
  115569. */
  115570. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  115571. /**
  115572. * Serializes this block in a JSON representation
  115573. * @returns the serialized block object
  115574. */
  115575. serialize(): any;
  115576. /** @hidden */
  115577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115578. }
  115579. }
  115580. declare module BABYLON {
  115581. /**
  115582. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  115583. */
  115584. export enum NodeMaterialBlockConnectionPointMode {
  115585. /** Value is an uniform */
  115586. Uniform = 0,
  115587. /** Value is a mesh attribute */
  115588. Attribute = 1,
  115589. /** Value is a varying between vertex and fragment shaders */
  115590. Varying = 2,
  115591. /** Mode is undefined */
  115592. Undefined = 3
  115593. }
  115594. }
  115595. declare module BABYLON {
  115596. /**
  115597. * Enum used to define well known values e.g. values automatically provided by the system
  115598. */
  115599. export enum NodeMaterialWellKnownValues {
  115600. /** World */
  115601. World = 1,
  115602. /** View */
  115603. View = 2,
  115604. /** Projection */
  115605. Projection = 3,
  115606. /** ViewProjection */
  115607. ViewProjection = 4,
  115608. /** WorldView */
  115609. WorldView = 5,
  115610. /** WorldViewProjection */
  115611. WorldViewProjection = 6,
  115612. /** CameraPosition */
  115613. CameraPosition = 7,
  115614. /** Fog Color */
  115615. FogColor = 8
  115616. }
  115617. }
  115618. declare module BABYLON {
  115619. /**
  115620. * Contains position and normal vectors for a vertex
  115621. */
  115622. export class PositionNormalVertex {
  115623. /** the position of the vertex (defaut: 0,0,0) */
  115624. position: Vector3;
  115625. /** the normal of the vertex (defaut: 0,1,0) */
  115626. normal: Vector3;
  115627. /**
  115628. * Creates a PositionNormalVertex
  115629. * @param position the position of the vertex (defaut: 0,0,0)
  115630. * @param normal the normal of the vertex (defaut: 0,1,0)
  115631. */
  115632. constructor(
  115633. /** the position of the vertex (defaut: 0,0,0) */
  115634. position?: Vector3,
  115635. /** the normal of the vertex (defaut: 0,1,0) */
  115636. normal?: Vector3);
  115637. /**
  115638. * Clones the PositionNormalVertex
  115639. * @returns the cloned PositionNormalVertex
  115640. */
  115641. clone(): PositionNormalVertex;
  115642. }
  115643. /**
  115644. * Contains position, normal and uv vectors for a vertex
  115645. */
  115646. export class PositionNormalTextureVertex {
  115647. /** the position of the vertex (defaut: 0,0,0) */
  115648. position: Vector3;
  115649. /** the normal of the vertex (defaut: 0,1,0) */
  115650. normal: Vector3;
  115651. /** the uv of the vertex (default: 0,0) */
  115652. uv: Vector2;
  115653. /**
  115654. * Creates a PositionNormalTextureVertex
  115655. * @param position the position of the vertex (defaut: 0,0,0)
  115656. * @param normal the normal of the vertex (defaut: 0,1,0)
  115657. * @param uv the uv of the vertex (default: 0,0)
  115658. */
  115659. constructor(
  115660. /** the position of the vertex (defaut: 0,0,0) */
  115661. position?: Vector3,
  115662. /** the normal of the vertex (defaut: 0,1,0) */
  115663. normal?: Vector3,
  115664. /** the uv of the vertex (default: 0,0) */
  115665. uv?: Vector2);
  115666. /**
  115667. * Clones the PositionNormalTextureVertex
  115668. * @returns the cloned PositionNormalTextureVertex
  115669. */
  115670. clone(): PositionNormalTextureVertex;
  115671. }
  115672. }
  115673. declare module BABYLON {
  115674. /**
  115675. * Block used to expose an input value
  115676. */
  115677. export class InputBlock extends NodeMaterialBlock {
  115678. private _mode;
  115679. private _associatedVariableName;
  115680. private _storedValue;
  115681. private _valueCallback;
  115682. private _type;
  115683. /** @hidden */
  115684. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  115685. /**
  115686. * Gets or sets the connection point type (default is float)
  115687. */
  115688. readonly type: NodeMaterialBlockConnectionPointTypes;
  115689. /**
  115690. * Creates a new InputBlock
  115691. * @param name defines the block name
  115692. * @param target defines the target of that block (Vertex by default)
  115693. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  115694. */
  115695. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  115696. /**
  115697. * Gets the output component
  115698. */
  115699. readonly output: NodeMaterialConnectionPoint;
  115700. /**
  115701. * Set the source of this connection point to a vertex attribute
  115702. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  115703. * @returns the current connection point
  115704. */
  115705. setAsAttribute(attributeName?: string): InputBlock;
  115706. /**
  115707. * Set the source of this connection point to a well known value
  115708. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  115709. * @returns the current connection point
  115710. */
  115711. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  115712. /**
  115713. * Gets or sets the value of that point.
  115714. * Please note that this value will be ignored if valueCallback is defined
  115715. */
  115716. value: any;
  115717. /**
  115718. * Gets or sets a callback used to get the value of that point.
  115719. * Please note that setting this value will force the connection point to ignore the value property
  115720. */
  115721. valueCallback: () => any;
  115722. /**
  115723. * Gets or sets the associated variable name in the shader
  115724. */
  115725. associatedVariableName: string;
  115726. /**
  115727. * Gets a boolean indicating that this connection point not defined yet
  115728. */
  115729. readonly isUndefined: boolean;
  115730. /**
  115731. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  115732. * In this case the connection point name must be the name of the uniform to use.
  115733. * Can only be set on inputs
  115734. */
  115735. isUniform: boolean;
  115736. /**
  115737. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  115738. * In this case the connection point name must be the name of the attribute to use
  115739. * Can only be set on inputs
  115740. */
  115741. isAttribute: boolean;
  115742. /**
  115743. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  115744. * Can only be set on exit points
  115745. */
  115746. isVarying: boolean;
  115747. /**
  115748. * Gets a boolean indicating that the current connection point is a well known value
  115749. */
  115750. readonly isWellKnownValue: boolean;
  115751. /**
  115752. * Gets or sets the current well known value or null if not defined as well know value
  115753. */
  115754. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  115755. /**
  115756. * Gets the current class name
  115757. * @returns the class name
  115758. */
  115759. getClassName(): string;
  115760. private _emitDefine;
  115761. /**
  115762. * Set the input block to its default value (based on its type)
  115763. */
  115764. setDefaultValue(): void;
  115765. private _emit;
  115766. /** @hidden */
  115767. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  115768. /** @hidden */
  115769. _transmit(effect: Effect, scene: Scene): void;
  115770. protected _buildBlock(state: NodeMaterialBuildState): void;
  115771. serialize(): any;
  115772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115773. }
  115774. }
  115775. declare module BABYLON {
  115776. /**
  115777. * Defines a connection point for a block
  115778. */
  115779. export class NodeMaterialConnectionPoint {
  115780. /** @hidden */
  115781. _ownerBlock: NodeMaterialBlock;
  115782. /** @hidden */
  115783. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  115784. private _endpoints;
  115785. private _associatedVariableName;
  115786. /** @hidden */
  115787. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  115788. private _type;
  115789. /** @hidden */
  115790. _enforceAssociatedVariableName: boolean;
  115791. /**
  115792. * Gets or sets the associated variable name in the shader
  115793. */
  115794. associatedVariableName: string;
  115795. /**
  115796. * Gets or sets the connection point type (default is float)
  115797. */
  115798. type: NodeMaterialBlockConnectionPointTypes;
  115799. /**
  115800. * Gets or sets the connection point name
  115801. */
  115802. name: string;
  115803. /**
  115804. * Gets or sets the swizzle to apply to this connection point when reading or writing
  115805. */
  115806. swizzle: string;
  115807. /**
  115808. * Gets or sets a boolean indicating that this connection point can be omitted
  115809. */
  115810. isOptional: boolean;
  115811. /**
  115812. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  115813. */
  115814. define: string;
  115815. /** Gets or sets the target of that connection point */
  115816. target: NodeMaterialBlockTargets;
  115817. /**
  115818. * Gets a boolean indicating that the current point is connected
  115819. */
  115820. readonly isConnected: boolean;
  115821. /**
  115822. * Gets a boolean indicating that the current point is connected to an input block
  115823. */
  115824. readonly isConnectedToInput: boolean;
  115825. /**
  115826. * Gets a the connected input block (if any)
  115827. */
  115828. readonly connectInputBlock: Nullable<InputBlock>;
  115829. /** Get the other side of the connection (if any) */
  115830. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  115831. /** Get the block that owns this connection point */
  115832. readonly ownerBlock: NodeMaterialBlock;
  115833. /** Get the block connected on the other side of this connection (if any) */
  115834. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  115835. /** Get the block connected on the endpoints of this connection (if any) */
  115836. readonly connectedBlocks: Array<NodeMaterialBlock>;
  115837. /** Gets the list of connected endpoints */
  115838. readonly endpoints: NodeMaterialConnectionPoint[];
  115839. /**
  115840. * Creates a new connection point
  115841. * @param name defines the connection point name
  115842. * @param ownerBlock defines the block hosting this connection point
  115843. */
  115844. constructor(name: string, ownerBlock: NodeMaterialBlock);
  115845. /**
  115846. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  115847. * @returns the class name
  115848. */
  115849. getClassName(): string;
  115850. /**
  115851. * Gets an boolean indicating if the current point can be connected to another point
  115852. * @param connectionPoint defines the other connection point
  115853. * @returns true if the connection is possible
  115854. */
  115855. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  115856. /**
  115857. * Connect this point to another connection point
  115858. * @param connectionPoint defines the other connection point
  115859. * @returns the current connection point
  115860. */
  115861. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  115862. /**
  115863. * Disconnect this point from one of his endpoint
  115864. * @param endpoint defines the other connection point
  115865. * @returns the current connection point
  115866. */
  115867. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  115868. /**
  115869. * Serializes this point in a JSON representation
  115870. * @returns the serialized point object
  115871. */
  115872. serialize(): any;
  115873. private static _GetTypeLength;
  115874. }
  115875. }
  115876. declare module BABYLON {
  115877. /**
  115878. * Block used to add support for vertex skinning (bones)
  115879. */
  115880. export class BonesBlock extends NodeMaterialBlock {
  115881. /**
  115882. * Creates a new BonesBlock
  115883. * @param name defines the block name
  115884. */
  115885. constructor(name: string);
  115886. /**
  115887. * Initialize the block and prepare the context for build
  115888. * @param state defines the state that will be used for the build
  115889. */
  115890. initialize(state: NodeMaterialBuildState): void;
  115891. /**
  115892. * Gets the current class name
  115893. * @returns the class name
  115894. */
  115895. getClassName(): string;
  115896. /**
  115897. * Gets the matrix indices input component
  115898. */
  115899. readonly matricesIndices: NodeMaterialConnectionPoint;
  115900. /**
  115901. * Gets the matrix weights input component
  115902. */
  115903. readonly matricesWeights: NodeMaterialConnectionPoint;
  115904. /**
  115905. * Gets the extra matrix indices input component
  115906. */
  115907. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  115908. /**
  115909. * Gets the extra matrix weights input component
  115910. */
  115911. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  115912. /**
  115913. * Gets the world input component
  115914. */
  115915. readonly world: NodeMaterialConnectionPoint;
  115916. /**
  115917. * Gets the output component
  115918. */
  115919. readonly output: NodeMaterialConnectionPoint;
  115920. autoConfigure(): void;
  115921. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  115922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115924. protected _buildBlock(state: NodeMaterialBuildState): this;
  115925. }
  115926. }
  115927. declare module BABYLON {
  115928. /**
  115929. * Block used to add support for instances
  115930. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  115931. */
  115932. export class InstancesBlock extends NodeMaterialBlock {
  115933. /**
  115934. * Creates a new InstancesBlock
  115935. * @param name defines the block name
  115936. */
  115937. constructor(name: string);
  115938. /**
  115939. * Gets the current class name
  115940. * @returns the class name
  115941. */
  115942. getClassName(): string;
  115943. /**
  115944. * Gets the first world row input component
  115945. */
  115946. readonly world0: NodeMaterialConnectionPoint;
  115947. /**
  115948. * Gets the second world row input component
  115949. */
  115950. readonly world1: NodeMaterialConnectionPoint;
  115951. /**
  115952. * Gets the third world row input component
  115953. */
  115954. readonly world2: NodeMaterialConnectionPoint;
  115955. /**
  115956. * Gets the forth world row input component
  115957. */
  115958. readonly world3: NodeMaterialConnectionPoint;
  115959. /**
  115960. * Gets the world input component
  115961. */
  115962. readonly world: NodeMaterialConnectionPoint;
  115963. /**
  115964. * Gets the output component
  115965. */
  115966. readonly output: NodeMaterialConnectionPoint;
  115967. autoConfigure(): void;
  115968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115969. protected _buildBlock(state: NodeMaterialBuildState): this;
  115970. }
  115971. }
  115972. declare module BABYLON {
  115973. /**
  115974. * Block used to add morph targets support to vertex shader
  115975. */
  115976. export class MorphTargetsBlock extends NodeMaterialBlock {
  115977. private _repeatableContentAnchor;
  115978. private _repeatebleContentGenerated;
  115979. /**
  115980. * Create a new MorphTargetsBlock
  115981. * @param name defines the block name
  115982. */
  115983. constructor(name: string);
  115984. /**
  115985. * Gets the current class name
  115986. * @returns the class name
  115987. */
  115988. getClassName(): string;
  115989. /**
  115990. * Gets the position input component
  115991. */
  115992. readonly position: NodeMaterialConnectionPoint;
  115993. /**
  115994. * Gets the normal input component
  115995. */
  115996. readonly normal: NodeMaterialConnectionPoint;
  115997. /**
  115998. * Gets the tangent input component
  115999. */
  116000. readonly tangent: NodeMaterialConnectionPoint;
  116001. /**
  116002. * Gets the tangent input component
  116003. */
  116004. readonly uv: NodeMaterialConnectionPoint;
  116005. /**
  116006. * Gets the position output component
  116007. */
  116008. readonly positionOutput: NodeMaterialConnectionPoint;
  116009. /**
  116010. * Gets the normal output component
  116011. */
  116012. readonly normalOutput: NodeMaterialConnectionPoint;
  116013. /**
  116014. * Gets the tangent output component
  116015. */
  116016. readonly tangentOutput: NodeMaterialConnectionPoint;
  116017. /**
  116018. * Gets the tangent output component
  116019. */
  116020. readonly uvOutput: NodeMaterialConnectionPoint;
  116021. initialize(state: NodeMaterialBuildState): void;
  116022. autoConfigure(): void;
  116023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116025. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116026. protected _buildBlock(state: NodeMaterialBuildState): this;
  116027. }
  116028. }
  116029. declare module BABYLON {
  116030. /**
  116031. * Block used to add an alpha test in the fragment shader
  116032. */
  116033. export class AlphaTestBlock extends NodeMaterialBlock {
  116034. /**
  116035. * Gets or sets the alpha value where alpha testing happens
  116036. */
  116037. alphaCutOff: number;
  116038. /**
  116039. * Create a new AlphaTestBlock
  116040. * @param name defines the block name
  116041. */
  116042. constructor(name: string);
  116043. /**
  116044. * Gets the current class name
  116045. * @returns the class name
  116046. */
  116047. getClassName(): string;
  116048. /**
  116049. * Gets the color input component
  116050. */
  116051. readonly color: NodeMaterialConnectionPoint;
  116052. protected _buildBlock(state: NodeMaterialBuildState): this;
  116053. }
  116054. }
  116055. declare module BABYLON {
  116056. /**
  116057. * Block used to create a Color4 out of 4 inputs (one for each component)
  116058. */
  116059. export class RGBAMergerBlock extends NodeMaterialBlock {
  116060. /**
  116061. * Create a new RGBAMergerBlock
  116062. * @param name defines the block name
  116063. */
  116064. constructor(name: string);
  116065. /**
  116066. * Gets the current class name
  116067. * @returns the class name
  116068. */
  116069. getClassName(): string;
  116070. /**
  116071. * Gets the R input component
  116072. */
  116073. readonly r: NodeMaterialConnectionPoint;
  116074. /**
  116075. * Gets the G input component
  116076. */
  116077. readonly g: NodeMaterialConnectionPoint;
  116078. /**
  116079. * Gets the B input component
  116080. */
  116081. readonly b: NodeMaterialConnectionPoint;
  116082. /**
  116083. * Gets the RGB input component
  116084. */
  116085. readonly rgb: NodeMaterialConnectionPoint;
  116086. /**
  116087. * Gets the R input component
  116088. */
  116089. readonly a: NodeMaterialConnectionPoint;
  116090. /**
  116091. * Gets the output component
  116092. */
  116093. readonly output: NodeMaterialConnectionPoint;
  116094. protected _buildBlock(state: NodeMaterialBuildState): this;
  116095. }
  116096. }
  116097. declare module BABYLON {
  116098. /**
  116099. * Block used to create a Color3 out of 3 inputs (one for each component)
  116100. */
  116101. export class RGBMergerBlock extends NodeMaterialBlock {
  116102. /**
  116103. * Create a new RGBMergerBlock
  116104. * @param name defines the block name
  116105. */
  116106. constructor(name: string);
  116107. /**
  116108. * Gets the current class name
  116109. * @returns the class name
  116110. */
  116111. getClassName(): string;
  116112. /**
  116113. * Gets the R component input
  116114. */
  116115. readonly r: NodeMaterialConnectionPoint;
  116116. /**
  116117. * Gets the G component input
  116118. */
  116119. readonly g: NodeMaterialConnectionPoint;
  116120. /**
  116121. * Gets the B component input
  116122. */
  116123. readonly b: NodeMaterialConnectionPoint;
  116124. /**
  116125. * Gets the output component
  116126. */
  116127. readonly output: NodeMaterialConnectionPoint;
  116128. protected _buildBlock(state: NodeMaterialBuildState): this;
  116129. }
  116130. }
  116131. declare module BABYLON {
  116132. /**
  116133. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  116134. */
  116135. export class RGBASplitterBlock extends NodeMaterialBlock {
  116136. /**
  116137. * Create a new RGBASplitterBlock
  116138. * @param name defines the block name
  116139. */
  116140. constructor(name: string);
  116141. /**
  116142. * Gets the current class name
  116143. * @returns the class name
  116144. */
  116145. getClassName(): string;
  116146. /**
  116147. * Gets the input component
  116148. */
  116149. readonly input: NodeMaterialConnectionPoint;
  116150. protected _buildBlock(state: NodeMaterialBuildState): this;
  116151. }
  116152. }
  116153. declare module BABYLON {
  116154. /**
  116155. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  116156. */
  116157. export class RGBSplitterBlock extends NodeMaterialBlock {
  116158. /**
  116159. * Create a new RGBSplitterBlock
  116160. * @param name defines the block name
  116161. */
  116162. constructor(name: string);
  116163. /**
  116164. * Gets the current class name
  116165. * @returns the class name
  116166. */
  116167. getClassName(): string;
  116168. /**
  116169. * Gets the input component
  116170. */
  116171. readonly input: NodeMaterialConnectionPoint;
  116172. protected _buildBlock(state: NodeMaterialBuildState): this;
  116173. }
  116174. }
  116175. declare module BABYLON {
  116176. /**
  116177. * Block used to add image processing support to fragment shader
  116178. */
  116179. export class ImageProcessingBlock extends NodeMaterialBlock {
  116180. /**
  116181. * Create a new ImageProcessingBlock
  116182. * @param name defines the block name
  116183. */
  116184. constructor(name: string);
  116185. /**
  116186. * Gets the current class name
  116187. * @returns the class name
  116188. */
  116189. getClassName(): string;
  116190. /**
  116191. * Gets the color input component
  116192. */
  116193. readonly color: NodeMaterialConnectionPoint;
  116194. /**
  116195. * Gets the output component
  116196. */
  116197. readonly output: NodeMaterialConnectionPoint;
  116198. /**
  116199. * Initialize the block and prepare the context for build
  116200. * @param state defines the state that will be used for the build
  116201. */
  116202. initialize(state: NodeMaterialBuildState): void;
  116203. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  116204. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116205. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116206. protected _buildBlock(state: NodeMaterialBuildState): this;
  116207. }
  116208. }
  116209. declare module BABYLON {
  116210. /**
  116211. * Block used to add support for scene fog
  116212. */
  116213. export class FogBlock extends NodeMaterialBlock {
  116214. private _fogDistanceName;
  116215. private _fogParameters;
  116216. /**
  116217. * Create a new FogBlock
  116218. * @param name defines the block name
  116219. */
  116220. constructor(name: string);
  116221. /**
  116222. * Gets the current class name
  116223. * @returns the class name
  116224. */
  116225. getClassName(): string;
  116226. /**
  116227. * Gets the world position input component
  116228. */
  116229. readonly worldPosition: NodeMaterialConnectionPoint;
  116230. /**
  116231. * Gets the view input component
  116232. */
  116233. readonly view: NodeMaterialConnectionPoint;
  116234. /**
  116235. * Gets the color input component
  116236. */
  116237. readonly color: NodeMaterialConnectionPoint;
  116238. /**
  116239. * Gets the fog color input component
  116240. */
  116241. readonly fogColor: NodeMaterialConnectionPoint;
  116242. /**
  116243. * Gets the output component
  116244. */
  116245. readonly output: NodeMaterialConnectionPoint;
  116246. autoConfigure(): void;
  116247. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116248. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116249. protected _buildBlock(state: NodeMaterialBuildState): this;
  116250. }
  116251. }
  116252. declare module BABYLON {
  116253. /**
  116254. * Block used to add light in the fragment shader
  116255. */
  116256. export class LightBlock extends NodeMaterialBlock {
  116257. private _lightId;
  116258. /**
  116259. * Gets or sets the light associated with this block
  116260. */
  116261. light: Nullable<Light>;
  116262. /**
  116263. * Create a new LightBlock
  116264. * @param name defines the block name
  116265. */
  116266. constructor(name: string);
  116267. /**
  116268. * Gets the current class name
  116269. * @returns the class name
  116270. */
  116271. getClassName(): string;
  116272. /**
  116273. * Gets the world position input component
  116274. */
  116275. readonly worldPosition: NodeMaterialConnectionPoint;
  116276. /**
  116277. * Gets the world normal input component
  116278. */
  116279. readonly worldNormal: NodeMaterialConnectionPoint;
  116280. /**
  116281. * Gets the camera (or eye) position component
  116282. */
  116283. readonly cameraPosition: NodeMaterialConnectionPoint;
  116284. /**
  116285. * Gets the diffuse output component
  116286. */
  116287. readonly diffuseOutput: NodeMaterialConnectionPoint;
  116288. /**
  116289. * Gets the specular output component
  116290. */
  116291. readonly specularOutput: NodeMaterialConnectionPoint;
  116292. autoConfigure(): void;
  116293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116294. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116295. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116296. private _injectVertexCode;
  116297. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116298. serialize(): any;
  116299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116300. }
  116301. }
  116302. declare module BABYLON {
  116303. /**
  116304. * Block used to multiply 2 values
  116305. */
  116306. export class MultiplyBlock extends NodeMaterialBlock {
  116307. /**
  116308. * Creates a new MultiplyBlock
  116309. * @param name defines the block name
  116310. */
  116311. constructor(name: string);
  116312. /**
  116313. * Gets the current class name
  116314. * @returns the class name
  116315. */
  116316. getClassName(): string;
  116317. /**
  116318. * Gets the left operand input component
  116319. */
  116320. readonly left: NodeMaterialConnectionPoint;
  116321. /**
  116322. * Gets the right operand input component
  116323. */
  116324. readonly right: NodeMaterialConnectionPoint;
  116325. /**
  116326. * Gets the output component
  116327. */
  116328. readonly output: NodeMaterialConnectionPoint;
  116329. protected _buildBlock(state: NodeMaterialBuildState): this;
  116330. }
  116331. }
  116332. declare module BABYLON {
  116333. /**
  116334. * Block used to add 2 vectors
  116335. */
  116336. export class AddBlock extends NodeMaterialBlock {
  116337. /**
  116338. * Creates a new AddBlock
  116339. * @param name defines the block name
  116340. */
  116341. constructor(name: string);
  116342. /**
  116343. * Gets the current class name
  116344. * @returns the class name
  116345. */
  116346. getClassName(): string;
  116347. /**
  116348. * Gets the left operand input component
  116349. */
  116350. readonly left: NodeMaterialConnectionPoint;
  116351. /**
  116352. * Gets the right operand input component
  116353. */
  116354. readonly right: NodeMaterialConnectionPoint;
  116355. /**
  116356. * Gets the output component
  116357. */
  116358. readonly output: NodeMaterialConnectionPoint;
  116359. protected _buildBlock(state: NodeMaterialBuildState): this;
  116360. }
  116361. }
  116362. declare module BABYLON {
  116363. /**
  116364. * Block used to clamp a float
  116365. */
  116366. export class ClampBlock extends NodeMaterialBlock {
  116367. /** Gets or sets the minimum range */
  116368. minimum: number;
  116369. /** Gets or sets the maximum range */
  116370. maximum: number;
  116371. /**
  116372. * Creates a new ClampBlock
  116373. * @param name defines the block name
  116374. */
  116375. constructor(name: string);
  116376. /**
  116377. * Gets the current class name
  116378. * @returns the class name
  116379. */
  116380. getClassName(): string;
  116381. /**
  116382. * Gets the value input component
  116383. */
  116384. readonly value: NodeMaterialConnectionPoint;
  116385. /**
  116386. * Gets the output component
  116387. */
  116388. readonly output: NodeMaterialConnectionPoint;
  116389. protected _buildBlock(state: NodeMaterialBuildState): this;
  116390. }
  116391. }
  116392. declare module BABYLON {
  116393. /**
  116394. * Block used to apply a cross product between 2 vectors
  116395. */
  116396. export class CrossBlock extends NodeMaterialBlock {
  116397. /**
  116398. * Creates a new CrossBlock
  116399. * @param name defines the block name
  116400. */
  116401. constructor(name: string);
  116402. /**
  116403. * Gets the current class name
  116404. * @returns the class name
  116405. */
  116406. getClassName(): string;
  116407. /**
  116408. * Gets the left operand input component
  116409. */
  116410. readonly left: NodeMaterialConnectionPoint;
  116411. /**
  116412. * Gets the right operand input component
  116413. */
  116414. readonly right: NodeMaterialConnectionPoint;
  116415. /**
  116416. * Gets the output component
  116417. */
  116418. readonly output: NodeMaterialConnectionPoint;
  116419. protected _buildBlock(state: NodeMaterialBuildState): this;
  116420. }
  116421. }
  116422. declare module BABYLON {
  116423. /**
  116424. * Block used to apply a dot product between 2 vectors
  116425. */
  116426. export class DotBlock extends NodeMaterialBlock {
  116427. /**
  116428. * Creates a new DotBlock
  116429. * @param name defines the block name
  116430. */
  116431. constructor(name: string);
  116432. /**
  116433. * Gets the current class name
  116434. * @returns the class name
  116435. */
  116436. getClassName(): string;
  116437. /**
  116438. * Gets the left operand input component
  116439. */
  116440. readonly left: NodeMaterialConnectionPoint;
  116441. /**
  116442. * Gets the right operand input component
  116443. */
  116444. readonly right: NodeMaterialConnectionPoint;
  116445. /**
  116446. * Gets the output component
  116447. */
  116448. readonly output: NodeMaterialConnectionPoint;
  116449. protected _buildBlock(state: NodeMaterialBuildState): this;
  116450. }
  116451. }
  116452. declare module BABYLON {
  116453. /**
  116454. * Effect Render Options
  116455. */
  116456. export interface IEffectRendererOptions {
  116457. /**
  116458. * Defines the vertices positions.
  116459. */
  116460. positions?: number[];
  116461. /**
  116462. * Defines the indices.
  116463. */
  116464. indices?: number[];
  116465. }
  116466. /**
  116467. * Helper class to render one or more effects
  116468. */
  116469. export class EffectRenderer {
  116470. private engine;
  116471. private static _DefaultOptions;
  116472. private _vertexBuffers;
  116473. private _indexBuffer;
  116474. private _ringBufferIndex;
  116475. private _ringScreenBuffer;
  116476. private _fullscreenViewport;
  116477. private _getNextFrameBuffer;
  116478. /**
  116479. * Creates an effect renderer
  116480. * @param engine the engine to use for rendering
  116481. * @param options defines the options of the effect renderer
  116482. */
  116483. constructor(engine: Engine, options?: IEffectRendererOptions);
  116484. /**
  116485. * Sets the current viewport in normalized coordinates 0-1
  116486. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  116487. */
  116488. setViewport(viewport?: Viewport): void;
  116489. /**
  116490. * Sets the current effect wrapper to use during draw.
  116491. * The effect needs to be ready before calling this api.
  116492. * This also sets the default full screen position attribute.
  116493. * @param effectWrapper Defines the effect to draw with
  116494. */
  116495. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  116496. /**
  116497. * Draws a full screen quad.
  116498. */
  116499. draw(): void;
  116500. /**
  116501. * renders one or more effects to a specified texture
  116502. * @param effectWrappers list of effects to renderer
  116503. * @param outputTexture texture to draw to, if null it will render to the screen
  116504. */
  116505. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  116506. /**
  116507. * Disposes of the effect renderer
  116508. */
  116509. dispose(): void;
  116510. }
  116511. /**
  116512. * Options to create an EffectWrapper
  116513. */
  116514. interface EffectWrapperCreationOptions {
  116515. /**
  116516. * Engine to use to create the effect
  116517. */
  116518. engine: Engine;
  116519. /**
  116520. * Fragment shader for the effect
  116521. */
  116522. fragmentShader: string;
  116523. /**
  116524. * Vertex shader for the effect
  116525. */
  116526. vertexShader: string;
  116527. /**
  116528. * Attributes to use in the shader
  116529. */
  116530. attributeNames?: Array<string>;
  116531. /**
  116532. * Uniforms to use in the shader
  116533. */
  116534. uniformNames?: Array<string>;
  116535. /**
  116536. * Texture sampler names to use in the shader
  116537. */
  116538. samplerNames?: Array<string>;
  116539. /**
  116540. * The friendly name of the effect displayed in Spector.
  116541. */
  116542. name?: string;
  116543. }
  116544. /**
  116545. * Wraps an effect to be used for rendering
  116546. */
  116547. export class EffectWrapper {
  116548. /**
  116549. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  116550. */
  116551. onApplyObservable: Observable<{}>;
  116552. /**
  116553. * The underlying effect
  116554. */
  116555. effect: Effect;
  116556. /**
  116557. * Creates an effect to be renderer
  116558. * @param creationOptions options to create the effect
  116559. */
  116560. constructor(creationOptions: EffectWrapperCreationOptions);
  116561. /**
  116562. * Disposes of the effect wrapper
  116563. */
  116564. dispose(): void;
  116565. }
  116566. }
  116567. declare module BABYLON {
  116568. /**
  116569. * Helper class to push actions to a pool of workers.
  116570. */
  116571. export class WorkerPool implements IDisposable {
  116572. private _workerInfos;
  116573. private _pendingActions;
  116574. /**
  116575. * Constructor
  116576. * @param workers Array of workers to use for actions
  116577. */
  116578. constructor(workers: Array<Worker>);
  116579. /**
  116580. * Terminates all workers and clears any pending actions.
  116581. */
  116582. dispose(): void;
  116583. /**
  116584. * Pushes an action to the worker pool. If all the workers are active, the action will be
  116585. * pended until a worker has completed its action.
  116586. * @param action The action to perform. Call onComplete when the action is complete.
  116587. */
  116588. push(action: (worker: Worker, onComplete: () => void) => void): void;
  116589. private _execute;
  116590. }
  116591. }
  116592. declare module BABYLON {
  116593. /**
  116594. * Configuration for Draco compression
  116595. */
  116596. export interface IDracoCompressionConfiguration {
  116597. /**
  116598. * Configuration for the decoder.
  116599. */
  116600. decoder: {
  116601. /**
  116602. * The url to the WebAssembly module.
  116603. */
  116604. wasmUrl?: string;
  116605. /**
  116606. * The url to the WebAssembly binary.
  116607. */
  116608. wasmBinaryUrl?: string;
  116609. /**
  116610. * The url to the fallback JavaScript module.
  116611. */
  116612. fallbackUrl?: string;
  116613. };
  116614. }
  116615. /**
  116616. * Draco compression (https://google.github.io/draco/)
  116617. *
  116618. * This class wraps the Draco module.
  116619. *
  116620. * **Encoder**
  116621. *
  116622. * The encoder is not currently implemented.
  116623. *
  116624. * **Decoder**
  116625. *
  116626. * 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.
  116627. *
  116628. * To update the configuration, use the following code:
  116629. * ```javascript
  116630. * DracoCompression.Configuration = {
  116631. * decoder: {
  116632. * wasmUrl: "<url to the WebAssembly library>",
  116633. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  116634. * fallbackUrl: "<url to the fallback JavaScript library>",
  116635. * }
  116636. * };
  116637. * ```
  116638. *
  116639. * 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.
  116640. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  116641. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  116642. *
  116643. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  116644. * ```javascript
  116645. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  116646. * ```
  116647. *
  116648. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  116649. */
  116650. export class DracoCompression implements IDisposable {
  116651. private _workerPoolPromise?;
  116652. private _decoderModulePromise?;
  116653. /**
  116654. * The configuration. Defaults to the following urls:
  116655. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  116656. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  116657. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  116658. */
  116659. static Configuration: IDracoCompressionConfiguration;
  116660. /**
  116661. * Returns true if the decoder configuration is available.
  116662. */
  116663. static readonly DecoderAvailable: boolean;
  116664. /**
  116665. * Default number of workers to create when creating the draco compression object.
  116666. */
  116667. static DefaultNumWorkers: number;
  116668. private static GetDefaultNumWorkers;
  116669. private static _Default;
  116670. /**
  116671. * Default instance for the draco compression object.
  116672. */
  116673. static readonly Default: DracoCompression;
  116674. /**
  116675. * Constructor
  116676. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  116677. */
  116678. constructor(numWorkers?: number);
  116679. /**
  116680. * Stop all async operations and release resources.
  116681. */
  116682. dispose(): void;
  116683. /**
  116684. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  116685. * @returns a promise that resolves when ready
  116686. */
  116687. whenReadyAsync(): Promise<void>;
  116688. /**
  116689. * Decode Draco compressed mesh data to vertex data.
  116690. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  116691. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  116692. * @returns A promise that resolves with the decoded vertex data
  116693. */
  116694. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  116695. [kind: string]: number;
  116696. }): Promise<VertexData>;
  116697. }
  116698. }
  116699. declare module BABYLON {
  116700. /**
  116701. * Class for building Constructive Solid Geometry
  116702. */
  116703. export class CSG {
  116704. private polygons;
  116705. /**
  116706. * The world matrix
  116707. */
  116708. matrix: Matrix;
  116709. /**
  116710. * Stores the position
  116711. */
  116712. position: Vector3;
  116713. /**
  116714. * Stores the rotation
  116715. */
  116716. rotation: Vector3;
  116717. /**
  116718. * Stores the rotation quaternion
  116719. */
  116720. rotationQuaternion: Nullable<Quaternion>;
  116721. /**
  116722. * Stores the scaling vector
  116723. */
  116724. scaling: Vector3;
  116725. /**
  116726. * Convert the Mesh to CSG
  116727. * @param mesh The Mesh to convert to CSG
  116728. * @returns A new CSG from the Mesh
  116729. */
  116730. static FromMesh(mesh: Mesh): CSG;
  116731. /**
  116732. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  116733. * @param polygons Polygons used to construct a CSG solid
  116734. */
  116735. private static FromPolygons;
  116736. /**
  116737. * Clones, or makes a deep copy, of the CSG
  116738. * @returns A new CSG
  116739. */
  116740. clone(): CSG;
  116741. /**
  116742. * Unions this CSG with another CSG
  116743. * @param csg The CSG to union against this CSG
  116744. * @returns The unioned CSG
  116745. */
  116746. union(csg: CSG): CSG;
  116747. /**
  116748. * Unions this CSG with another CSG in place
  116749. * @param csg The CSG to union against this CSG
  116750. */
  116751. unionInPlace(csg: CSG): void;
  116752. /**
  116753. * Subtracts this CSG with another CSG
  116754. * @param csg The CSG to subtract against this CSG
  116755. * @returns A new CSG
  116756. */
  116757. subtract(csg: CSG): CSG;
  116758. /**
  116759. * Subtracts this CSG with another CSG in place
  116760. * @param csg The CSG to subtact against this CSG
  116761. */
  116762. subtractInPlace(csg: CSG): void;
  116763. /**
  116764. * Intersect this CSG with another CSG
  116765. * @param csg The CSG to intersect against this CSG
  116766. * @returns A new CSG
  116767. */
  116768. intersect(csg: CSG): CSG;
  116769. /**
  116770. * Intersects this CSG with another CSG in place
  116771. * @param csg The CSG to intersect against this CSG
  116772. */
  116773. intersectInPlace(csg: CSG): void;
  116774. /**
  116775. * Return a new CSG solid with solid and empty space switched. This solid is
  116776. * not modified.
  116777. * @returns A new CSG solid with solid and empty space switched
  116778. */
  116779. inverse(): CSG;
  116780. /**
  116781. * Inverses the CSG in place
  116782. */
  116783. inverseInPlace(): void;
  116784. /**
  116785. * This is used to keep meshes transformations so they can be restored
  116786. * when we build back a Babylon Mesh
  116787. * NB : All CSG operations are performed in world coordinates
  116788. * @param csg The CSG to copy the transform attributes from
  116789. * @returns This CSG
  116790. */
  116791. copyTransformAttributes(csg: CSG): CSG;
  116792. /**
  116793. * Build Raw mesh from CSG
  116794. * Coordinates here are in world space
  116795. * @param name The name of the mesh geometry
  116796. * @param scene The Scene
  116797. * @param keepSubMeshes Specifies if the submeshes should be kept
  116798. * @returns A new Mesh
  116799. */
  116800. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  116801. /**
  116802. * Build Mesh from CSG taking material and transforms into account
  116803. * @param name The name of the Mesh
  116804. * @param material The material of the Mesh
  116805. * @param scene The Scene
  116806. * @param keepSubMeshes Specifies if submeshes should be kept
  116807. * @returns The new Mesh
  116808. */
  116809. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  116810. }
  116811. }
  116812. declare module BABYLON {
  116813. /**
  116814. * Class used to create a trail following a mesh
  116815. */
  116816. export class TrailMesh extends Mesh {
  116817. private _generator;
  116818. private _autoStart;
  116819. private _running;
  116820. private _diameter;
  116821. private _length;
  116822. private _sectionPolygonPointsCount;
  116823. private _sectionVectors;
  116824. private _sectionNormalVectors;
  116825. private _beforeRenderObserver;
  116826. /**
  116827. * @constructor
  116828. * @param name The value used by scene.getMeshByName() to do a lookup.
  116829. * @param generator The mesh to generate a trail.
  116830. * @param scene The scene to add this mesh to.
  116831. * @param diameter Diameter of trailing mesh. Default is 1.
  116832. * @param length Length of trailing mesh. Default is 60.
  116833. * @param autoStart Automatically start trailing mesh. Default true.
  116834. */
  116835. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  116836. /**
  116837. * "TrailMesh"
  116838. * @returns "TrailMesh"
  116839. */
  116840. getClassName(): string;
  116841. private _createMesh;
  116842. /**
  116843. * Start trailing mesh.
  116844. */
  116845. start(): void;
  116846. /**
  116847. * Stop trailing mesh.
  116848. */
  116849. stop(): void;
  116850. /**
  116851. * Update trailing mesh geometry.
  116852. */
  116853. update(): void;
  116854. /**
  116855. * Returns a new TrailMesh object.
  116856. * @param name is a string, the name given to the new mesh
  116857. * @param newGenerator use new generator object for cloned trail mesh
  116858. * @returns a new mesh
  116859. */
  116860. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  116861. /**
  116862. * Serializes this trail mesh
  116863. * @param serializationObject object to write serialization to
  116864. */
  116865. serialize(serializationObject: any): void;
  116866. /**
  116867. * Parses a serialized trail mesh
  116868. * @param parsedMesh the serialized mesh
  116869. * @param scene the scene to create the trail mesh in
  116870. * @returns the created trail mesh
  116871. */
  116872. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  116873. }
  116874. }
  116875. declare module BABYLON {
  116876. /**
  116877. * Class containing static functions to help procedurally build meshes
  116878. */
  116879. export class TiledBoxBuilder {
  116880. /**
  116881. * Creates a box mesh
  116882. * 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)
  116883. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116887. * @param name defines the name of the mesh
  116888. * @param options defines the options used to create the mesh
  116889. * @param scene defines the hosting scene
  116890. * @returns the box mesh
  116891. */
  116892. static CreateTiledBox(name: string, options: {
  116893. pattern?: number;
  116894. width?: number;
  116895. height?: number;
  116896. depth?: number;
  116897. tileSize?: number;
  116898. tileWidth?: number;
  116899. tileHeight?: number;
  116900. alignHorizontal?: number;
  116901. alignVertical?: number;
  116902. faceUV?: Vector4[];
  116903. faceColors?: Color4[];
  116904. sideOrientation?: number;
  116905. updatable?: boolean;
  116906. }, scene?: Nullable<Scene>): Mesh;
  116907. }
  116908. }
  116909. declare module BABYLON {
  116910. /**
  116911. * Class containing static functions to help procedurally build meshes
  116912. */
  116913. export class TorusKnotBuilder {
  116914. /**
  116915. * Creates a torus knot mesh
  116916. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116917. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116918. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116919. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116923. * @param name defines the name of the mesh
  116924. * @param options defines the options used to create the mesh
  116925. * @param scene defines the hosting scene
  116926. * @returns the torus knot mesh
  116927. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116928. */
  116929. static CreateTorusKnot(name: string, options: {
  116930. radius?: number;
  116931. tube?: number;
  116932. radialSegments?: number;
  116933. tubularSegments?: number;
  116934. p?: number;
  116935. q?: number;
  116936. updatable?: boolean;
  116937. sideOrientation?: number;
  116938. frontUVs?: Vector4;
  116939. backUVs?: Vector4;
  116940. }, scene: any): Mesh;
  116941. }
  116942. }
  116943. declare module BABYLON {
  116944. /**
  116945. * Polygon
  116946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  116947. */
  116948. export class Polygon {
  116949. /**
  116950. * Creates a rectangle
  116951. * @param xmin bottom X coord
  116952. * @param ymin bottom Y coord
  116953. * @param xmax top X coord
  116954. * @param ymax top Y coord
  116955. * @returns points that make the resulting rectation
  116956. */
  116957. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  116958. /**
  116959. * Creates a circle
  116960. * @param radius radius of circle
  116961. * @param cx scale in x
  116962. * @param cy scale in y
  116963. * @param numberOfSides number of sides that make up the circle
  116964. * @returns points that make the resulting circle
  116965. */
  116966. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  116967. /**
  116968. * Creates a polygon from input string
  116969. * @param input Input polygon data
  116970. * @returns the parsed points
  116971. */
  116972. static Parse(input: string): Vector2[];
  116973. /**
  116974. * Starts building a polygon from x and y coordinates
  116975. * @param x x coordinate
  116976. * @param y y coordinate
  116977. * @returns the started path2
  116978. */
  116979. static StartingAt(x: number, y: number): Path2;
  116980. }
  116981. /**
  116982. * Builds a polygon
  116983. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  116984. */
  116985. export class PolygonMeshBuilder {
  116986. private _points;
  116987. private _outlinepoints;
  116988. private _holes;
  116989. private _name;
  116990. private _scene;
  116991. private _epoints;
  116992. private _eholes;
  116993. private _addToepoint;
  116994. /**
  116995. * Babylon reference to the earcut plugin.
  116996. */
  116997. bjsEarcut: any;
  116998. /**
  116999. * Creates a PolygonMeshBuilder
  117000. * @param name name of the builder
  117001. * @param contours Path of the polygon
  117002. * @param scene scene to add to when creating the mesh
  117003. * @param earcutInjection can be used to inject your own earcut reference
  117004. */
  117005. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  117006. /**
  117007. * Adds a whole within the polygon
  117008. * @param hole Array of points defining the hole
  117009. * @returns this
  117010. */
  117011. addHole(hole: Vector2[]): PolygonMeshBuilder;
  117012. /**
  117013. * Creates the polygon
  117014. * @param updatable If the mesh should be updatable
  117015. * @param depth The depth of the mesh created
  117016. * @returns the created mesh
  117017. */
  117018. build(updatable?: boolean, depth?: number): Mesh;
  117019. /**
  117020. * Creates the polygon
  117021. * @param depth The depth of the mesh created
  117022. * @returns the created VertexData
  117023. */
  117024. buildVertexData(depth?: number): VertexData;
  117025. /**
  117026. * Adds a side to the polygon
  117027. * @param positions points that make the polygon
  117028. * @param normals normals of the polygon
  117029. * @param uvs uvs of the polygon
  117030. * @param indices indices of the polygon
  117031. * @param bounds bounds of the polygon
  117032. * @param points points of the polygon
  117033. * @param depth depth of the polygon
  117034. * @param flip flip of the polygon
  117035. */
  117036. private addSide;
  117037. }
  117038. }
  117039. declare module BABYLON {
  117040. /**
  117041. * Class containing static functions to help procedurally build meshes
  117042. */
  117043. export class PolygonBuilder {
  117044. /**
  117045. * Creates a polygon mesh
  117046. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  117047. * * 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
  117048. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117050. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  117051. * * Remember you can only change the shape positions, not their number when updating a polygon
  117052. * @param name defines the name of the mesh
  117053. * @param options defines the options used to create the mesh
  117054. * @param scene defines the hosting scene
  117055. * @param earcutInjection can be used to inject your own earcut reference
  117056. * @returns the polygon mesh
  117057. */
  117058. static CreatePolygon(name: string, options: {
  117059. shape: Vector3[];
  117060. holes?: Vector3[][];
  117061. depth?: number;
  117062. faceUV?: Vector4[];
  117063. faceColors?: Color4[];
  117064. updatable?: boolean;
  117065. sideOrientation?: number;
  117066. frontUVs?: Vector4;
  117067. backUVs?: Vector4;
  117068. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117069. /**
  117070. * Creates an extruded polygon mesh, with depth in the Y direction.
  117071. * * 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)
  117072. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117073. * @param name defines the name of the mesh
  117074. * @param options defines the options used to create the mesh
  117075. * @param scene defines the hosting scene
  117076. * @param earcutInjection can be used to inject your own earcut reference
  117077. * @returns the polygon mesh
  117078. */
  117079. static ExtrudePolygon(name: string, options: {
  117080. shape: Vector3[];
  117081. holes?: Vector3[][];
  117082. depth?: number;
  117083. faceUV?: Vector4[];
  117084. faceColors?: Color4[];
  117085. updatable?: boolean;
  117086. sideOrientation?: number;
  117087. frontUVs?: Vector4;
  117088. backUVs?: Vector4;
  117089. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117090. }
  117091. }
  117092. declare module BABYLON {
  117093. /**
  117094. * Class containing static functions to help procedurally build meshes
  117095. */
  117096. export class LatheBuilder {
  117097. /**
  117098. * Creates lathe mesh.
  117099. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117100. * * 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
  117101. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117102. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117103. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117104. * * 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
  117105. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117106. * * 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
  117107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117109. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117111. * @param name defines the name of the mesh
  117112. * @param options defines the options used to create the mesh
  117113. * @param scene defines the hosting scene
  117114. * @returns the lathe mesh
  117115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117116. */
  117117. static CreateLathe(name: string, options: {
  117118. shape: Vector3[];
  117119. radius?: number;
  117120. tessellation?: number;
  117121. clip?: number;
  117122. arc?: number;
  117123. closed?: boolean;
  117124. updatable?: boolean;
  117125. sideOrientation?: number;
  117126. frontUVs?: Vector4;
  117127. backUVs?: Vector4;
  117128. cap?: number;
  117129. invertUV?: boolean;
  117130. }, scene?: Nullable<Scene>): Mesh;
  117131. }
  117132. }
  117133. declare module BABYLON {
  117134. /**
  117135. * Class containing static functions to help procedurally build meshes
  117136. */
  117137. export class TiledPlaneBuilder {
  117138. /**
  117139. * Creates a tiled plane mesh
  117140. * * The parameter `pattern` will, depending on value, do nothing or
  117141. * * * flip (reflect about central vertical) alternate tiles across and up
  117142. * * * flip every tile on alternate rows
  117143. * * * rotate (180 degs) alternate tiles across and up
  117144. * * * rotate every tile on alternate rows
  117145. * * * flip and rotate alternate tiles across and up
  117146. * * * flip and rotate every tile on alternate rows
  117147. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  117148. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  117149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117151. * * 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)
  117152. * * 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)
  117153. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117154. * @param name defines the name of the mesh
  117155. * @param options defines the options used to create the mesh
  117156. * @param scene defines the hosting scene
  117157. * @returns the box mesh
  117158. */
  117159. static CreateTiledPlane(name: string, options: {
  117160. pattern?: number;
  117161. tileSize?: number;
  117162. tileWidth?: number;
  117163. tileHeight?: number;
  117164. size?: number;
  117165. width?: number;
  117166. height?: number;
  117167. alignHorizontal?: number;
  117168. alignVertical?: number;
  117169. sideOrientation?: number;
  117170. frontUVs?: Vector4;
  117171. backUVs?: Vector4;
  117172. updatable?: boolean;
  117173. }, scene?: Nullable<Scene>): Mesh;
  117174. }
  117175. }
  117176. declare module BABYLON {
  117177. /**
  117178. * Class containing static functions to help procedurally build meshes
  117179. */
  117180. export class TubeBuilder {
  117181. /**
  117182. * Creates a tube mesh.
  117183. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117184. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  117185. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  117186. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  117187. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  117188. * * 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)
  117189. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  117190. * * 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
  117191. * * 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
  117192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117194. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117196. * @param name defines the name of the mesh
  117197. * @param options defines the options used to create the mesh
  117198. * @param scene defines the hosting scene
  117199. * @returns the tube mesh
  117200. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117201. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  117202. */
  117203. static CreateTube(name: string, options: {
  117204. path: Vector3[];
  117205. radius?: number;
  117206. tessellation?: number;
  117207. radiusFunction?: {
  117208. (i: number, distance: number): number;
  117209. };
  117210. cap?: number;
  117211. arc?: number;
  117212. updatable?: boolean;
  117213. sideOrientation?: number;
  117214. frontUVs?: Vector4;
  117215. backUVs?: Vector4;
  117216. instance?: Mesh;
  117217. invertUV?: boolean;
  117218. }, scene?: Nullable<Scene>): Mesh;
  117219. }
  117220. }
  117221. declare module BABYLON {
  117222. /**
  117223. * Class containing static functions to help procedurally build meshes
  117224. */
  117225. export class IcoSphereBuilder {
  117226. /**
  117227. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117228. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117229. * * 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`)
  117230. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117231. * * 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
  117232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117235. * @param name defines the name of the mesh
  117236. * @param options defines the options used to create the mesh
  117237. * @param scene defines the hosting scene
  117238. * @returns the icosahedron mesh
  117239. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117240. */
  117241. static CreateIcoSphere(name: string, options: {
  117242. radius?: number;
  117243. radiusX?: number;
  117244. radiusY?: number;
  117245. radiusZ?: number;
  117246. flat?: boolean;
  117247. subdivisions?: number;
  117248. sideOrientation?: number;
  117249. frontUVs?: Vector4;
  117250. backUVs?: Vector4;
  117251. updatable?: boolean;
  117252. }, scene?: Nullable<Scene>): Mesh;
  117253. }
  117254. }
  117255. declare module BABYLON {
  117256. /**
  117257. * Class containing static functions to help procedurally build meshes
  117258. */
  117259. export class DecalBuilder {
  117260. /**
  117261. * Creates a decal mesh.
  117262. * 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
  117263. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  117264. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  117265. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  117266. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  117267. * @param name defines the name of the mesh
  117268. * @param sourceMesh defines the mesh where the decal must be applied
  117269. * @param options defines the options used to create the mesh
  117270. * @param scene defines the hosting scene
  117271. * @returns the decal mesh
  117272. * @see https://doc.babylonjs.com/how_to/decals
  117273. */
  117274. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  117275. position?: Vector3;
  117276. normal?: Vector3;
  117277. size?: Vector3;
  117278. angle?: number;
  117279. }): Mesh;
  117280. }
  117281. }
  117282. declare module BABYLON {
  117283. /**
  117284. * Class containing static functions to help procedurally build meshes
  117285. */
  117286. export class MeshBuilder {
  117287. /**
  117288. * Creates a box mesh
  117289. * * The parameter `size` sets the size (float) of each box side (default 1)
  117290. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  117291. * * 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)
  117292. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117296. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117297. * @param name defines the name of the mesh
  117298. * @param options defines the options used to create the mesh
  117299. * @param scene defines the hosting scene
  117300. * @returns the box mesh
  117301. */
  117302. static CreateBox(name: string, options: {
  117303. size?: number;
  117304. width?: number;
  117305. height?: number;
  117306. depth?: number;
  117307. faceUV?: Vector4[];
  117308. faceColors?: Color4[];
  117309. sideOrientation?: number;
  117310. frontUVs?: Vector4;
  117311. backUVs?: Vector4;
  117312. updatable?: boolean;
  117313. }, scene?: Nullable<Scene>): Mesh;
  117314. /**
  117315. * Creates a tiled box mesh
  117316. * * faceTiles sets the pattern, tile size and number of tiles for a face
  117317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117318. * @param name defines the name of the mesh
  117319. * @param options defines the options used to create the mesh
  117320. * @param scene defines the hosting scene
  117321. * @returns the tiled box mesh
  117322. */
  117323. static CreateTiledBox(name: string, options: {
  117324. pattern?: number;
  117325. size?: number;
  117326. width?: number;
  117327. height?: number;
  117328. depth: number;
  117329. tileSize?: number;
  117330. tileWidth?: number;
  117331. tileHeight?: number;
  117332. faceUV?: Vector4[];
  117333. faceColors?: Color4[];
  117334. alignHorizontal?: number;
  117335. alignVertical?: number;
  117336. sideOrientation?: number;
  117337. updatable?: boolean;
  117338. }, scene?: Nullable<Scene>): Mesh;
  117339. /**
  117340. * Creates a sphere mesh
  117341. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117342. * * 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`)
  117343. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117344. * * 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
  117345. * * 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)
  117346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117349. * @param name defines the name of the mesh
  117350. * @param options defines the options used to create the mesh
  117351. * @param scene defines the hosting scene
  117352. * @returns the sphere mesh
  117353. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117354. */
  117355. static CreateSphere(name: string, options: {
  117356. segments?: number;
  117357. diameter?: number;
  117358. diameterX?: number;
  117359. diameterY?: number;
  117360. diameterZ?: number;
  117361. arc?: number;
  117362. slice?: number;
  117363. sideOrientation?: number;
  117364. frontUVs?: Vector4;
  117365. backUVs?: Vector4;
  117366. updatable?: boolean;
  117367. }, scene?: Nullable<Scene>): Mesh;
  117368. /**
  117369. * Creates a plane polygonal mesh. By default, this is a disc
  117370. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  117371. * * 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
  117372. * * 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
  117373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117376. * @param name defines the name of the mesh
  117377. * @param options defines the options used to create the mesh
  117378. * @param scene defines the hosting scene
  117379. * @returns the plane polygonal mesh
  117380. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  117381. */
  117382. static CreateDisc(name: string, options: {
  117383. radius?: number;
  117384. tessellation?: number;
  117385. arc?: number;
  117386. updatable?: boolean;
  117387. sideOrientation?: number;
  117388. frontUVs?: Vector4;
  117389. backUVs?: Vector4;
  117390. }, scene?: Nullable<Scene>): Mesh;
  117391. /**
  117392. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117393. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117394. * * 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`)
  117395. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117396. * * 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
  117397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117400. * @param name defines the name of the mesh
  117401. * @param options defines the options used to create the mesh
  117402. * @param scene defines the hosting scene
  117403. * @returns the icosahedron mesh
  117404. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117405. */
  117406. static CreateIcoSphere(name: string, options: {
  117407. radius?: number;
  117408. radiusX?: number;
  117409. radiusY?: number;
  117410. radiusZ?: number;
  117411. flat?: boolean;
  117412. subdivisions?: number;
  117413. sideOrientation?: number;
  117414. frontUVs?: Vector4;
  117415. backUVs?: Vector4;
  117416. updatable?: boolean;
  117417. }, scene?: Nullable<Scene>): Mesh;
  117418. /**
  117419. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117420. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117421. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117422. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117423. * * 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
  117424. * * 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
  117425. * * 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
  117426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117428. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117429. * * 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
  117430. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117431. * * 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
  117432. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117434. * @param name defines the name of the mesh
  117435. * @param options defines the options used to create the mesh
  117436. * @param scene defines the hosting scene
  117437. * @returns the ribbon mesh
  117438. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117439. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117440. */
  117441. static CreateRibbon(name: string, options: {
  117442. pathArray: Vector3[][];
  117443. closeArray?: boolean;
  117444. closePath?: boolean;
  117445. offset?: number;
  117446. updatable?: boolean;
  117447. sideOrientation?: number;
  117448. frontUVs?: Vector4;
  117449. backUVs?: Vector4;
  117450. instance?: Mesh;
  117451. invertUV?: boolean;
  117452. uvs?: Vector2[];
  117453. colors?: Color4[];
  117454. }, scene?: Nullable<Scene>): Mesh;
  117455. /**
  117456. * Creates a cylinder or a cone mesh
  117457. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117458. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117459. * * 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.
  117460. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117461. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117462. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117463. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117464. * * 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).
  117465. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117466. * * 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).
  117467. * * 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
  117468. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117469. * * 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
  117470. * * 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.
  117471. * * If `enclose` is false, a ring surface is one element.
  117472. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117473. * * 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
  117474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117477. * @param name defines the name of the mesh
  117478. * @param options defines the options used to create the mesh
  117479. * @param scene defines the hosting scene
  117480. * @returns the cylinder mesh
  117481. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117482. */
  117483. static CreateCylinder(name: string, options: {
  117484. height?: number;
  117485. diameterTop?: number;
  117486. diameterBottom?: number;
  117487. diameter?: number;
  117488. tessellation?: number;
  117489. subdivisions?: number;
  117490. arc?: number;
  117491. faceColors?: Color4[];
  117492. faceUV?: Vector4[];
  117493. updatable?: boolean;
  117494. hasRings?: boolean;
  117495. enclose?: boolean;
  117496. cap?: number;
  117497. sideOrientation?: number;
  117498. frontUVs?: Vector4;
  117499. backUVs?: Vector4;
  117500. }, scene?: Nullable<Scene>): Mesh;
  117501. /**
  117502. * Creates a torus mesh
  117503. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117504. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117505. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117509. * @param name defines the name of the mesh
  117510. * @param options defines the options used to create the mesh
  117511. * @param scene defines the hosting scene
  117512. * @returns the torus mesh
  117513. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117514. */
  117515. static CreateTorus(name: string, options: {
  117516. diameter?: number;
  117517. thickness?: number;
  117518. tessellation?: number;
  117519. updatable?: boolean;
  117520. sideOrientation?: number;
  117521. frontUVs?: Vector4;
  117522. backUVs?: Vector4;
  117523. }, scene?: Nullable<Scene>): Mesh;
  117524. /**
  117525. * Creates a torus knot mesh
  117526. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117527. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117528. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117529. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117531. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117533. * @param name defines the name of the mesh
  117534. * @param options defines the options used to create the mesh
  117535. * @param scene defines the hosting scene
  117536. * @returns the torus knot mesh
  117537. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117538. */
  117539. static CreateTorusKnot(name: string, options: {
  117540. radius?: number;
  117541. tube?: number;
  117542. radialSegments?: number;
  117543. tubularSegments?: number;
  117544. p?: number;
  117545. q?: number;
  117546. updatable?: boolean;
  117547. sideOrientation?: number;
  117548. frontUVs?: Vector4;
  117549. backUVs?: Vector4;
  117550. }, scene?: Nullable<Scene>): Mesh;
  117551. /**
  117552. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117553. * * 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
  117554. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117555. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117556. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117557. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117558. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117559. * * 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
  117560. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117563. * @param name defines the name of the new line system
  117564. * @param options defines the options used to create the line system
  117565. * @param scene defines the hosting scene
  117566. * @returns a new line system mesh
  117567. */
  117568. static CreateLineSystem(name: string, options: {
  117569. lines: Vector3[][];
  117570. updatable?: boolean;
  117571. instance?: Nullable<LinesMesh>;
  117572. colors?: Nullable<Color4[][]>;
  117573. useVertexAlpha?: boolean;
  117574. }, scene: Nullable<Scene>): LinesMesh;
  117575. /**
  117576. * Creates a line mesh
  117577. * 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
  117578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117579. * * The parameter `points` is an array successive Vector3
  117580. * * 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
  117581. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117582. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117583. * * When updating an instance, remember that only point positions can change, not the number of points
  117584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117586. * @param name defines the name of the new line system
  117587. * @param options defines the options used to create the line system
  117588. * @param scene defines the hosting scene
  117589. * @returns a new line mesh
  117590. */
  117591. static CreateLines(name: string, options: {
  117592. points: Vector3[];
  117593. updatable?: boolean;
  117594. instance?: Nullable<LinesMesh>;
  117595. colors?: Color4[];
  117596. useVertexAlpha?: boolean;
  117597. }, scene?: Nullable<Scene>): LinesMesh;
  117598. /**
  117599. * Creates a dashed line mesh
  117600. * * 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
  117601. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117602. * * The parameter `points` is an array successive Vector3
  117603. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117604. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117605. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117606. * * 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
  117607. * * When updating an instance, remember that only point positions can change, not the number of points
  117608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117609. * @param name defines the name of the mesh
  117610. * @param options defines the options used to create the mesh
  117611. * @param scene defines the hosting scene
  117612. * @returns the dashed line mesh
  117613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117614. */
  117615. static CreateDashedLines(name: string, options: {
  117616. points: Vector3[];
  117617. dashSize?: number;
  117618. gapSize?: number;
  117619. dashNb?: number;
  117620. updatable?: boolean;
  117621. instance?: LinesMesh;
  117622. }, scene?: Nullable<Scene>): LinesMesh;
  117623. /**
  117624. * 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.
  117625. * * 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.
  117626. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117627. * * 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.
  117628. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117629. * * 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
  117630. * * 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
  117631. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117634. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117636. * @param name defines the name of the mesh
  117637. * @param options defines the options used to create the mesh
  117638. * @param scene defines the hosting scene
  117639. * @returns the extruded shape mesh
  117640. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117642. */
  117643. static ExtrudeShape(name: string, options: {
  117644. shape: Vector3[];
  117645. path: Vector3[];
  117646. scale?: number;
  117647. rotation?: number;
  117648. cap?: number;
  117649. updatable?: boolean;
  117650. sideOrientation?: number;
  117651. frontUVs?: Vector4;
  117652. backUVs?: Vector4;
  117653. instance?: Mesh;
  117654. invertUV?: boolean;
  117655. }, scene?: Nullable<Scene>): Mesh;
  117656. /**
  117657. * Creates an custom extruded shape mesh.
  117658. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117659. * * 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.
  117660. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117661. * * 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
  117662. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117663. * * 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
  117664. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117665. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117666. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117667. * * 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
  117668. * * 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
  117669. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117672. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117674. * @param name defines the name of the mesh
  117675. * @param options defines the options used to create the mesh
  117676. * @param scene defines the hosting scene
  117677. * @returns the custom extruded shape mesh
  117678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117679. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117681. */
  117682. static ExtrudeShapeCustom(name: string, options: {
  117683. shape: Vector3[];
  117684. path: Vector3[];
  117685. scaleFunction?: any;
  117686. rotationFunction?: any;
  117687. ribbonCloseArray?: boolean;
  117688. ribbonClosePath?: boolean;
  117689. cap?: number;
  117690. updatable?: boolean;
  117691. sideOrientation?: number;
  117692. frontUVs?: Vector4;
  117693. backUVs?: Vector4;
  117694. instance?: Mesh;
  117695. invertUV?: boolean;
  117696. }, scene?: Nullable<Scene>): Mesh;
  117697. /**
  117698. * Creates lathe mesh.
  117699. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117700. * * 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
  117701. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117702. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117703. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117704. * * 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
  117705. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117706. * * 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
  117707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117709. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117711. * @param name defines the name of the mesh
  117712. * @param options defines the options used to create the mesh
  117713. * @param scene defines the hosting scene
  117714. * @returns the lathe mesh
  117715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117716. */
  117717. static CreateLathe(name: string, options: {
  117718. shape: Vector3[];
  117719. radius?: number;
  117720. tessellation?: number;
  117721. clip?: number;
  117722. arc?: number;
  117723. closed?: boolean;
  117724. updatable?: boolean;
  117725. sideOrientation?: number;
  117726. frontUVs?: Vector4;
  117727. backUVs?: Vector4;
  117728. cap?: number;
  117729. invertUV?: boolean;
  117730. }, scene?: Nullable<Scene>): Mesh;
  117731. /**
  117732. * Creates a tiled plane mesh
  117733. * * You can set a limited pattern arrangement with the tiles
  117734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117737. * @param name defines the name of the mesh
  117738. * @param options defines the options used to create the mesh
  117739. * @param scene defines the hosting scene
  117740. * @returns the plane mesh
  117741. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  117742. */
  117743. static CreateTiledPlane(name: string, options: {
  117744. pattern?: number;
  117745. tileSize?: number;
  117746. tileWidth?: number;
  117747. tileHeight?: number;
  117748. size?: number;
  117749. width?: number;
  117750. height?: number;
  117751. alignHorizontal?: number;
  117752. alignVertical?: number;
  117753. sideOrientation?: number;
  117754. frontUVs?: Vector4;
  117755. backUVs?: Vector4;
  117756. updatable?: boolean;
  117757. }, scene?: Nullable<Scene>): Mesh;
  117758. /**
  117759. * Creates a plane mesh
  117760. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  117761. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  117762. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  117763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117766. * @param name defines the name of the mesh
  117767. * @param options defines the options used to create the mesh
  117768. * @param scene defines the hosting scene
  117769. * @returns the plane mesh
  117770. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  117771. */
  117772. static CreatePlane(name: string, options: {
  117773. size?: number;
  117774. width?: number;
  117775. height?: number;
  117776. sideOrientation?: number;
  117777. frontUVs?: Vector4;
  117778. backUVs?: Vector4;
  117779. updatable?: boolean;
  117780. sourcePlane?: Plane;
  117781. }, scene?: Nullable<Scene>): Mesh;
  117782. /**
  117783. * Creates a ground mesh
  117784. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  117785. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  117786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117787. * @param name defines the name of the mesh
  117788. * @param options defines the options used to create the mesh
  117789. * @param scene defines the hosting scene
  117790. * @returns the ground mesh
  117791. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  117792. */
  117793. static CreateGround(name: string, options: {
  117794. width?: number;
  117795. height?: number;
  117796. subdivisions?: number;
  117797. subdivisionsX?: number;
  117798. subdivisionsY?: number;
  117799. updatable?: boolean;
  117800. }, scene?: Nullable<Scene>): Mesh;
  117801. /**
  117802. * Creates a tiled ground mesh
  117803. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117804. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117805. * * 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
  117806. * * 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
  117807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117808. * @param name defines the name of the mesh
  117809. * @param options defines the options used to create the mesh
  117810. * @param scene defines the hosting scene
  117811. * @returns the tiled ground mesh
  117812. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117813. */
  117814. static CreateTiledGround(name: string, options: {
  117815. xmin: number;
  117816. zmin: number;
  117817. xmax: number;
  117818. zmax: number;
  117819. subdivisions?: {
  117820. w: number;
  117821. h: number;
  117822. };
  117823. precision?: {
  117824. w: number;
  117825. h: number;
  117826. };
  117827. updatable?: boolean;
  117828. }, scene?: Nullable<Scene>): Mesh;
  117829. /**
  117830. * Creates a ground mesh from a height map
  117831. * * The parameter `url` sets the URL of the height map image resource.
  117832. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117833. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117834. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117835. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117836. * * 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.
  117837. * * 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).
  117838. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117840. * @param name defines the name of the mesh
  117841. * @param url defines the url to the height map
  117842. * @param options defines the options used to create the mesh
  117843. * @param scene defines the hosting scene
  117844. * @returns the ground mesh
  117845. * @see https://doc.babylonjs.com/babylon101/height_map
  117846. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  117847. */
  117848. static CreateGroundFromHeightMap(name: string, url: string, options: {
  117849. width?: number;
  117850. height?: number;
  117851. subdivisions?: number;
  117852. minHeight?: number;
  117853. maxHeight?: number;
  117854. colorFilter?: Color3;
  117855. alphaFilter?: number;
  117856. updatable?: boolean;
  117857. onReady?: (mesh: GroundMesh) => void;
  117858. }, scene?: Nullable<Scene>): GroundMesh;
  117859. /**
  117860. * Creates a polygon mesh
  117861. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  117862. * * 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
  117863. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  117866. * * Remember you can only change the shape positions, not their number when updating a polygon
  117867. * @param name defines the name of the mesh
  117868. * @param options defines the options used to create the mesh
  117869. * @param scene defines the hosting scene
  117870. * @param earcutInjection can be used to inject your own earcut reference
  117871. * @returns the polygon mesh
  117872. */
  117873. static CreatePolygon(name: string, options: {
  117874. shape: Vector3[];
  117875. holes?: Vector3[][];
  117876. depth?: number;
  117877. faceUV?: Vector4[];
  117878. faceColors?: Color4[];
  117879. updatable?: boolean;
  117880. sideOrientation?: number;
  117881. frontUVs?: Vector4;
  117882. backUVs?: Vector4;
  117883. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117884. /**
  117885. * Creates an extruded polygon mesh, with depth in the Y direction.
  117886. * * 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)
  117887. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117888. * @param name defines the name of the mesh
  117889. * @param options defines the options used to create the mesh
  117890. * @param scene defines the hosting scene
  117891. * @param earcutInjection can be used to inject your own earcut reference
  117892. * @returns the polygon mesh
  117893. */
  117894. static ExtrudePolygon(name: string, options: {
  117895. shape: Vector3[];
  117896. holes?: Vector3[][];
  117897. depth?: number;
  117898. faceUV?: Vector4[];
  117899. faceColors?: Color4[];
  117900. updatable?: boolean;
  117901. sideOrientation?: number;
  117902. frontUVs?: Vector4;
  117903. backUVs?: Vector4;
  117904. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117905. /**
  117906. * Creates a tube mesh.
  117907. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117908. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  117909. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  117910. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  117911. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  117912. * * 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)
  117913. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  117914. * * 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
  117915. * * 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
  117916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117918. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117920. * @param name defines the name of the mesh
  117921. * @param options defines the options used to create the mesh
  117922. * @param scene defines the hosting scene
  117923. * @returns the tube mesh
  117924. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117925. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  117926. */
  117927. static CreateTube(name: string, options: {
  117928. path: Vector3[];
  117929. radius?: number;
  117930. tessellation?: number;
  117931. radiusFunction?: {
  117932. (i: number, distance: number): number;
  117933. };
  117934. cap?: number;
  117935. arc?: number;
  117936. updatable?: boolean;
  117937. sideOrientation?: number;
  117938. frontUVs?: Vector4;
  117939. backUVs?: Vector4;
  117940. instance?: Mesh;
  117941. invertUV?: boolean;
  117942. }, scene?: Nullable<Scene>): Mesh;
  117943. /**
  117944. * Creates a polyhedron mesh
  117945. * * 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
  117946. * * The parameter `size` (positive float, default 1) sets the polygon size
  117947. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117948. * * 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`
  117949. * * 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
  117950. * * 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)`)
  117951. * * 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
  117952. * * 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
  117953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117956. * @param name defines the name of the mesh
  117957. * @param options defines the options used to create the mesh
  117958. * @param scene defines the hosting scene
  117959. * @returns the polyhedron mesh
  117960. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117961. */
  117962. static CreatePolyhedron(name: string, options: {
  117963. type?: number;
  117964. size?: number;
  117965. sizeX?: number;
  117966. sizeY?: number;
  117967. sizeZ?: number;
  117968. custom?: any;
  117969. faceUV?: Vector4[];
  117970. faceColors?: Color4[];
  117971. flat?: boolean;
  117972. updatable?: boolean;
  117973. sideOrientation?: number;
  117974. frontUVs?: Vector4;
  117975. backUVs?: Vector4;
  117976. }, scene?: Nullable<Scene>): Mesh;
  117977. /**
  117978. * Creates a decal mesh.
  117979. * 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
  117980. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  117981. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  117982. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  117983. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  117984. * @param name defines the name of the mesh
  117985. * @param sourceMesh defines the mesh where the decal must be applied
  117986. * @param options defines the options used to create the mesh
  117987. * @param scene defines the hosting scene
  117988. * @returns the decal mesh
  117989. * @see https://doc.babylonjs.com/how_to/decals
  117990. */
  117991. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  117992. position?: Vector3;
  117993. normal?: Vector3;
  117994. size?: Vector3;
  117995. angle?: number;
  117996. }): Mesh;
  117997. }
  117998. }
  117999. declare module BABYLON {
  118000. /**
  118001. * A simplifier interface for future simplification implementations
  118002. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118003. */
  118004. export interface ISimplifier {
  118005. /**
  118006. * Simplification of a given mesh according to the given settings.
  118007. * Since this requires computation, it is assumed that the function runs async.
  118008. * @param settings The settings of the simplification, including quality and distance
  118009. * @param successCallback A callback that will be called after the mesh was simplified.
  118010. * @param errorCallback in case of an error, this callback will be called. optional.
  118011. */
  118012. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  118013. }
  118014. /**
  118015. * Expected simplification settings.
  118016. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  118017. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118018. */
  118019. export interface ISimplificationSettings {
  118020. /**
  118021. * Gets or sets the expected quality
  118022. */
  118023. quality: number;
  118024. /**
  118025. * Gets or sets the distance when this optimized version should be used
  118026. */
  118027. distance: number;
  118028. /**
  118029. * Gets an already optimized mesh
  118030. */
  118031. optimizeMesh?: boolean;
  118032. }
  118033. /**
  118034. * Class used to specify simplification options
  118035. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118036. */
  118037. export class SimplificationSettings implements ISimplificationSettings {
  118038. /** expected quality */
  118039. quality: number;
  118040. /** distance when this optimized version should be used */
  118041. distance: number;
  118042. /** already optimized mesh */
  118043. optimizeMesh?: boolean | undefined;
  118044. /**
  118045. * Creates a SimplificationSettings
  118046. * @param quality expected quality
  118047. * @param distance distance when this optimized version should be used
  118048. * @param optimizeMesh already optimized mesh
  118049. */
  118050. constructor(
  118051. /** expected quality */
  118052. quality: number,
  118053. /** distance when this optimized version should be used */
  118054. distance: number,
  118055. /** already optimized mesh */
  118056. optimizeMesh?: boolean | undefined);
  118057. }
  118058. /**
  118059. * Interface used to define a simplification task
  118060. */
  118061. export interface ISimplificationTask {
  118062. /**
  118063. * Array of settings
  118064. */
  118065. settings: Array<ISimplificationSettings>;
  118066. /**
  118067. * Simplification type
  118068. */
  118069. simplificationType: SimplificationType;
  118070. /**
  118071. * Mesh to simplify
  118072. */
  118073. mesh: Mesh;
  118074. /**
  118075. * Callback called on success
  118076. */
  118077. successCallback?: () => void;
  118078. /**
  118079. * Defines if parallel processing can be used
  118080. */
  118081. parallelProcessing: boolean;
  118082. }
  118083. /**
  118084. * Queue used to order the simplification tasks
  118085. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118086. */
  118087. export class SimplificationQueue {
  118088. private _simplificationArray;
  118089. /**
  118090. * Gets a boolean indicating that the process is still running
  118091. */
  118092. running: boolean;
  118093. /**
  118094. * Creates a new queue
  118095. */
  118096. constructor();
  118097. /**
  118098. * Adds a new simplification task
  118099. * @param task defines a task to add
  118100. */
  118101. addTask(task: ISimplificationTask): void;
  118102. /**
  118103. * Execute next task
  118104. */
  118105. executeNext(): void;
  118106. /**
  118107. * Execute a simplification task
  118108. * @param task defines the task to run
  118109. */
  118110. runSimplification(task: ISimplificationTask): void;
  118111. private getSimplifier;
  118112. }
  118113. /**
  118114. * The implemented types of simplification
  118115. * At the moment only Quadratic Error Decimation is implemented
  118116. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118117. */
  118118. export enum SimplificationType {
  118119. /** Quadratic error decimation */
  118120. QUADRATIC = 0
  118121. }
  118122. }
  118123. declare module BABYLON {
  118124. interface Scene {
  118125. /** @hidden (Backing field) */
  118126. _simplificationQueue: SimplificationQueue;
  118127. /**
  118128. * Gets or sets the simplification queue attached to the scene
  118129. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118130. */
  118131. simplificationQueue: SimplificationQueue;
  118132. }
  118133. interface Mesh {
  118134. /**
  118135. * Simplify the mesh according to the given array of settings.
  118136. * Function will return immediately and will simplify async
  118137. * @param settings a collection of simplification settings
  118138. * @param parallelProcessing should all levels calculate parallel or one after the other
  118139. * @param simplificationType the type of simplification to run
  118140. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  118141. * @returns the current mesh
  118142. */
  118143. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  118144. }
  118145. /**
  118146. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  118147. * created in a scene
  118148. */
  118149. export class SimplicationQueueSceneComponent implements ISceneComponent {
  118150. /**
  118151. * The component name helpfull to identify the component in the list of scene components.
  118152. */
  118153. readonly name: string;
  118154. /**
  118155. * The scene the component belongs to.
  118156. */
  118157. scene: Scene;
  118158. /**
  118159. * Creates a new instance of the component for the given scene
  118160. * @param scene Defines the scene to register the component in
  118161. */
  118162. constructor(scene: Scene);
  118163. /**
  118164. * Registers the component in a given scene
  118165. */
  118166. register(): void;
  118167. /**
  118168. * Rebuilds the elements related to this component in case of
  118169. * context lost for instance.
  118170. */
  118171. rebuild(): void;
  118172. /**
  118173. * Disposes the component and the associated ressources
  118174. */
  118175. dispose(): void;
  118176. private _beforeCameraUpdate;
  118177. }
  118178. }
  118179. declare module BABYLON {
  118180. /**
  118181. * Navigation plugin interface to add navigation constrained by a navigation mesh
  118182. */
  118183. export interface INavigationEnginePlugin {
  118184. /**
  118185. * plugin name
  118186. */
  118187. name: string;
  118188. /**
  118189. * Creates a navigation mesh
  118190. * @param meshes array of all the geometry used to compute the navigatio mesh
  118191. * @param parameters bunch of parameters used to filter geometry
  118192. */
  118193. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118194. /**
  118195. * Create a navigation mesh debug mesh
  118196. * @param scene is where the mesh will be added
  118197. * @returns debug display mesh
  118198. */
  118199. createDebugNavMesh(scene: Scene): Mesh;
  118200. /**
  118201. * Get a navigation mesh constrained position, closest to the parameter position
  118202. * @param position world position
  118203. * @returns the closest point to position constrained by the navigation mesh
  118204. */
  118205. getClosestPoint(position: Vector3): Vector3;
  118206. /**
  118207. * Get a navigation mesh constrained position, within a particular radius
  118208. * @param position world position
  118209. * @param maxRadius the maximum distance to the constrained world position
  118210. * @returns the closest point to position constrained by the navigation mesh
  118211. */
  118212. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118213. /**
  118214. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118215. * @param start world position
  118216. * @param end world position
  118217. * @returns array containing world position composing the path
  118218. */
  118219. computePath(start: Vector3, end: Vector3): Vector3[];
  118220. /**
  118221. * If this plugin is supported
  118222. * @returns true if plugin is supported
  118223. */
  118224. isSupported(): boolean;
  118225. /**
  118226. * Create a new Crowd so you can add agents
  118227. * @param maxAgents the maximum agent count in the crowd
  118228. * @param maxAgentRadius the maximum radius an agent can have
  118229. * @param scene to attach the crowd to
  118230. * @returns the crowd you can add agents to
  118231. */
  118232. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118233. /**
  118234. * Release all resources
  118235. */
  118236. dispose(): void;
  118237. }
  118238. /**
  118239. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  118240. */
  118241. export interface ICrowd {
  118242. /**
  118243. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118244. * You can attach anything to that node. The node position is updated in the scene update tick.
  118245. * @param pos world position that will be constrained by the navigation mesh
  118246. * @param parameters agent parameters
  118247. * @param transform hooked to the agent that will be update by the scene
  118248. * @returns agent index
  118249. */
  118250. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118251. /**
  118252. * Returns the agent position in world space
  118253. * @param index agent index returned by addAgent
  118254. * @returns world space position
  118255. */
  118256. getAgentPosition(index: number): Vector3;
  118257. /**
  118258. * Gets the agent velocity in world space
  118259. * @param index agent index returned by addAgent
  118260. * @returns world space velocity
  118261. */
  118262. getAgentVelocity(index: number): Vector3;
  118263. /**
  118264. * remove a particular agent previously created
  118265. * @param index agent index returned by addAgent
  118266. */
  118267. removeAgent(index: number): void;
  118268. /**
  118269. * get the list of all agents attached to this crowd
  118270. * @returns list of agent indices
  118271. */
  118272. getAgents(): number[];
  118273. /**
  118274. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118275. * @param deltaTime in seconds
  118276. */
  118277. update(deltaTime: number): void;
  118278. /**
  118279. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118280. * @param index agent index returned by addAgent
  118281. * @param destination targeted world position
  118282. */
  118283. agentGoto(index: number, destination: Vector3): void;
  118284. /**
  118285. * Release all resources
  118286. */
  118287. dispose(): void;
  118288. }
  118289. /**
  118290. * Configures an agent
  118291. */
  118292. export interface IAgentParameters {
  118293. /**
  118294. * Agent radius. [Limit: >= 0]
  118295. */
  118296. radius: number;
  118297. /**
  118298. * Agent height. [Limit: > 0]
  118299. */
  118300. height: number;
  118301. /**
  118302. * Maximum allowed acceleration. [Limit: >= 0]
  118303. */
  118304. maxAcceleration: number;
  118305. /**
  118306. * Maximum allowed speed. [Limit: >= 0]
  118307. */
  118308. maxSpeed: number;
  118309. /**
  118310. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  118311. */
  118312. collisionQueryRange: number;
  118313. /**
  118314. * The path visibility optimization range. [Limit: > 0]
  118315. */
  118316. pathOptimizationRange: number;
  118317. /**
  118318. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  118319. */
  118320. separationWeight: number;
  118321. }
  118322. /**
  118323. * Configures the navigation mesh creation
  118324. */
  118325. export interface INavMeshParameters {
  118326. /**
  118327. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  118328. */
  118329. cs: number;
  118330. /**
  118331. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  118332. */
  118333. ch: number;
  118334. /**
  118335. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  118336. */
  118337. walkableSlopeAngle: number;
  118338. /**
  118339. * Minimum floor to 'ceiling' height that will still allow the floor area to
  118340. * be considered walkable. [Limit: >= 3] [Units: vx]
  118341. */
  118342. walkableHeight: number;
  118343. /**
  118344. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  118345. */
  118346. walkableClimb: number;
  118347. /**
  118348. * The distance to erode/shrink the walkable area of the heightfield away from
  118349. * obstructions. [Limit: >=0] [Units: vx]
  118350. */
  118351. walkableRadius: number;
  118352. /**
  118353. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  118354. */
  118355. maxEdgeLen: number;
  118356. /**
  118357. * The maximum distance a simplfied contour's border edges should deviate
  118358. * the original raw contour. [Limit: >=0] [Units: vx]
  118359. */
  118360. maxSimplificationError: number;
  118361. /**
  118362. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  118363. */
  118364. minRegionArea: number;
  118365. /**
  118366. * Any regions with a span count smaller than this value will, if possible,
  118367. * be merged with larger regions. [Limit: >=0] [Units: vx]
  118368. */
  118369. mergeRegionArea: number;
  118370. /**
  118371. * The maximum number of vertices allowed for polygons generated during the
  118372. * contour to polygon conversion process. [Limit: >= 3]
  118373. */
  118374. maxVertsPerPoly: number;
  118375. /**
  118376. * Sets the sampling distance to use when generating the detail mesh.
  118377. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  118378. */
  118379. detailSampleDist: number;
  118380. /**
  118381. * The maximum distance the detail mesh surface should deviate from heightfield
  118382. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  118383. */
  118384. detailSampleMaxError: number;
  118385. }
  118386. }
  118387. declare module BABYLON {
  118388. /**
  118389. * RecastJS navigation plugin
  118390. */
  118391. export class RecastJSPlugin implements INavigationEnginePlugin {
  118392. /**
  118393. * Reference to the Recast library
  118394. */
  118395. bjsRECAST: any;
  118396. /**
  118397. * plugin name
  118398. */
  118399. name: string;
  118400. /**
  118401. * the first navmesh created. We might extend this to support multiple navmeshes
  118402. */
  118403. navMesh: any;
  118404. /**
  118405. * Initializes the recastJS plugin
  118406. * @param recastInjection can be used to inject your own recast reference
  118407. */
  118408. constructor(recastInjection?: any);
  118409. /**
  118410. * Creates a navigation mesh
  118411. * @param meshes array of all the geometry used to compute the navigatio mesh
  118412. * @param parameters bunch of parameters used to filter geometry
  118413. */
  118414. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118415. /**
  118416. * Create a navigation mesh debug mesh
  118417. * @param scene is where the mesh will be added
  118418. * @returns debug display mesh
  118419. */
  118420. createDebugNavMesh(scene: Scene): Mesh;
  118421. /**
  118422. * Get a navigation mesh constrained position, closest to the parameter position
  118423. * @param position world position
  118424. * @returns the closest point to position constrained by the navigation mesh
  118425. */
  118426. getClosestPoint(position: Vector3): Vector3;
  118427. /**
  118428. * Get a navigation mesh constrained position, within a particular radius
  118429. * @param position world position
  118430. * @param maxRadius the maximum distance to the constrained world position
  118431. * @returns the closest point to position constrained by the navigation mesh
  118432. */
  118433. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118434. /**
  118435. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118436. * @param start world position
  118437. * @param end world position
  118438. * @returns array containing world position composing the path
  118439. */
  118440. computePath(start: Vector3, end: Vector3): Vector3[];
  118441. /**
  118442. * Create a new Crowd so you can add agents
  118443. * @param maxAgents the maximum agent count in the crowd
  118444. * @param maxAgentRadius the maximum radius an agent can have
  118445. * @param scene to attach the crowd to
  118446. * @returns the crowd you can add agents to
  118447. */
  118448. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118449. /**
  118450. * Disposes
  118451. */
  118452. dispose(): void;
  118453. /**
  118454. * If this plugin is supported
  118455. * @returns true if plugin is supported
  118456. */
  118457. isSupported(): boolean;
  118458. }
  118459. /**
  118460. * Recast detour crowd implementation
  118461. */
  118462. export class RecastJSCrowd implements ICrowd {
  118463. /**
  118464. * Recast/detour plugin
  118465. */
  118466. bjsRECASTPlugin: RecastJSPlugin;
  118467. /**
  118468. * Link to the detour crowd
  118469. */
  118470. recastCrowd: any;
  118471. /**
  118472. * One transform per agent
  118473. */
  118474. transforms: TransformNode[];
  118475. /**
  118476. * All agents created
  118477. */
  118478. agents: number[];
  118479. /**
  118480. * Link to the scene is kept to unregister the crowd from the scene
  118481. */
  118482. private _scene;
  118483. /**
  118484. * Observer for crowd updates
  118485. */
  118486. private _onBeforeAnimationsObserver;
  118487. /**
  118488. * Constructor
  118489. * @param plugin recastJS plugin
  118490. * @param maxAgents the maximum agent count in the crowd
  118491. * @param maxAgentRadius the maximum radius an agent can have
  118492. * @param scene to attach the crowd to
  118493. * @returns the crowd you can add agents to
  118494. */
  118495. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  118496. /**
  118497. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118498. * You can attach anything to that node. The node position is updated in the scene update tick.
  118499. * @param pos world position that will be constrained by the navigation mesh
  118500. * @param parameters agent parameters
  118501. * @param transform hooked to the agent that will be update by the scene
  118502. * @returns agent index
  118503. */
  118504. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118505. /**
  118506. * Returns the agent position in world space
  118507. * @param index agent index returned by addAgent
  118508. * @returns world space position
  118509. */
  118510. getAgentPosition(index: number): Vector3;
  118511. /**
  118512. * Returns the agent velocity in world space
  118513. * @param index agent index returned by addAgent
  118514. * @returns world space velocity
  118515. */
  118516. getAgentVelocity(index: number): Vector3;
  118517. /**
  118518. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118519. * @param index agent index returned by addAgent
  118520. * @param destination targeted world position
  118521. */
  118522. agentGoto(index: number, destination: Vector3): void;
  118523. /**
  118524. * remove a particular agent previously created
  118525. * @param index agent index returned by addAgent
  118526. */
  118527. removeAgent(index: number): void;
  118528. /**
  118529. * get the list of all agents attached to this crowd
  118530. * @returns list of agent indices
  118531. */
  118532. getAgents(): number[];
  118533. /**
  118534. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118535. * @param deltaTime in seconds
  118536. */
  118537. update(deltaTime: number): void;
  118538. /**
  118539. * Release all resources
  118540. */
  118541. dispose(): void;
  118542. }
  118543. }
  118544. declare module BABYLON {
  118545. /**
  118546. * Class used to enable access to IndexedDB
  118547. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118548. */
  118549. export class Database implements IOfflineProvider {
  118550. private _callbackManifestChecked;
  118551. private _currentSceneUrl;
  118552. private _db;
  118553. private _enableSceneOffline;
  118554. private _enableTexturesOffline;
  118555. private _manifestVersionFound;
  118556. private _mustUpdateRessources;
  118557. private _hasReachedQuota;
  118558. private _isSupported;
  118559. private _idbFactory;
  118560. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  118561. private static IsUASupportingBlobStorage;
  118562. /**
  118563. * Gets a boolean indicating if Database storate is enabled (off by default)
  118564. */
  118565. static IDBStorageEnabled: boolean;
  118566. /**
  118567. * Gets a boolean indicating if scene must be saved in the database
  118568. */
  118569. readonly enableSceneOffline: boolean;
  118570. /**
  118571. * Gets a boolean indicating if textures must be saved in the database
  118572. */
  118573. readonly enableTexturesOffline: boolean;
  118574. /**
  118575. * Creates a new Database
  118576. * @param urlToScene defines the url to load the scene
  118577. * @param callbackManifestChecked defines the callback to use when manifest is checked
  118578. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  118579. */
  118580. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  118581. private static _ParseURL;
  118582. private static _ReturnFullUrlLocation;
  118583. private _checkManifestFile;
  118584. /**
  118585. * Open the database and make it available
  118586. * @param successCallback defines the callback to call on success
  118587. * @param errorCallback defines the callback to call on error
  118588. */
  118589. open(successCallback: () => void, errorCallback: () => void): void;
  118590. /**
  118591. * Loads an image from the database
  118592. * @param url defines the url to load from
  118593. * @param image defines the target DOM image
  118594. */
  118595. loadImage(url: string, image: HTMLImageElement): void;
  118596. private _loadImageFromDBAsync;
  118597. private _saveImageIntoDBAsync;
  118598. private _checkVersionFromDB;
  118599. private _loadVersionFromDBAsync;
  118600. private _saveVersionIntoDBAsync;
  118601. /**
  118602. * Loads a file from database
  118603. * @param url defines the URL to load from
  118604. * @param sceneLoaded defines a callback to call on success
  118605. * @param progressCallBack defines a callback to call when progress changed
  118606. * @param errorCallback defines a callback to call on error
  118607. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  118608. */
  118609. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  118610. private _loadFileAsync;
  118611. private _saveFileAsync;
  118612. /**
  118613. * Validates if xhr data is correct
  118614. * @param xhr defines the request to validate
  118615. * @param dataType defines the expected data type
  118616. * @returns true if data is correct
  118617. */
  118618. private static _ValidateXHRData;
  118619. }
  118620. }
  118621. declare module BABYLON {
  118622. /** @hidden */
  118623. export var gpuUpdateParticlesPixelShader: {
  118624. name: string;
  118625. shader: string;
  118626. };
  118627. }
  118628. declare module BABYLON {
  118629. /** @hidden */
  118630. export var gpuUpdateParticlesVertexShader: {
  118631. name: string;
  118632. shader: string;
  118633. };
  118634. }
  118635. declare module BABYLON {
  118636. /** @hidden */
  118637. export var clipPlaneFragmentDeclaration2: {
  118638. name: string;
  118639. shader: string;
  118640. };
  118641. }
  118642. declare module BABYLON {
  118643. /** @hidden */
  118644. export var gpuRenderParticlesPixelShader: {
  118645. name: string;
  118646. shader: string;
  118647. };
  118648. }
  118649. declare module BABYLON {
  118650. /** @hidden */
  118651. export var clipPlaneVertexDeclaration2: {
  118652. name: string;
  118653. shader: string;
  118654. };
  118655. }
  118656. declare module BABYLON {
  118657. /** @hidden */
  118658. export var gpuRenderParticlesVertexShader: {
  118659. name: string;
  118660. shader: string;
  118661. };
  118662. }
  118663. declare module BABYLON {
  118664. /**
  118665. * This represents a GPU particle system in Babylon
  118666. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  118667. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  118668. */
  118669. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  118670. /**
  118671. * The layer mask we are rendering the particles through.
  118672. */
  118673. layerMask: number;
  118674. private _capacity;
  118675. private _activeCount;
  118676. private _currentActiveCount;
  118677. private _accumulatedCount;
  118678. private _renderEffect;
  118679. private _updateEffect;
  118680. private _buffer0;
  118681. private _buffer1;
  118682. private _spriteBuffer;
  118683. private _updateVAO;
  118684. private _renderVAO;
  118685. private _targetIndex;
  118686. private _sourceBuffer;
  118687. private _targetBuffer;
  118688. private _engine;
  118689. private _currentRenderId;
  118690. private _started;
  118691. private _stopped;
  118692. private _timeDelta;
  118693. private _randomTexture;
  118694. private _randomTexture2;
  118695. private _attributesStrideSize;
  118696. private _updateEffectOptions;
  118697. private _randomTextureSize;
  118698. private _actualFrame;
  118699. private readonly _rawTextureWidth;
  118700. /**
  118701. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  118702. */
  118703. static readonly IsSupported: boolean;
  118704. /**
  118705. * An event triggered when the system is disposed.
  118706. */
  118707. onDisposeObservable: Observable<GPUParticleSystem>;
  118708. /**
  118709. * Gets the maximum number of particles active at the same time.
  118710. * @returns The max number of active particles.
  118711. */
  118712. getCapacity(): number;
  118713. /**
  118714. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  118715. * to override the particles.
  118716. */
  118717. forceDepthWrite: boolean;
  118718. /**
  118719. * Gets or set the number of active particles
  118720. */
  118721. activeParticleCount: number;
  118722. private _preWarmDone;
  118723. /**
  118724. * Is this system ready to be used/rendered
  118725. * @return true if the system is ready
  118726. */
  118727. isReady(): boolean;
  118728. /**
  118729. * Gets if the system has been started. (Note: this will still be true after stop is called)
  118730. * @returns True if it has been started, otherwise false.
  118731. */
  118732. isStarted(): boolean;
  118733. /**
  118734. * Starts the particle system and begins to emit
  118735. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  118736. */
  118737. start(delay?: number): void;
  118738. /**
  118739. * Stops the particle system.
  118740. */
  118741. stop(): void;
  118742. /**
  118743. * Remove all active particles
  118744. */
  118745. reset(): void;
  118746. /**
  118747. * Returns the string "GPUParticleSystem"
  118748. * @returns a string containing the class name
  118749. */
  118750. getClassName(): string;
  118751. private _colorGradientsTexture;
  118752. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  118753. /**
  118754. * Adds a new color gradient
  118755. * @param gradient defines the gradient to use (between 0 and 1)
  118756. * @param color1 defines the color to affect to the specified gradient
  118757. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  118758. * @returns the current particle system
  118759. */
  118760. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  118761. /**
  118762. * Remove a specific color gradient
  118763. * @param gradient defines the gradient to remove
  118764. * @returns the current particle system
  118765. */
  118766. removeColorGradient(gradient: number): GPUParticleSystem;
  118767. private _angularSpeedGradientsTexture;
  118768. private _sizeGradientsTexture;
  118769. private _velocityGradientsTexture;
  118770. private _limitVelocityGradientsTexture;
  118771. private _dragGradientsTexture;
  118772. private _addFactorGradient;
  118773. /**
  118774. * Adds a new size gradient
  118775. * @param gradient defines the gradient to use (between 0 and 1)
  118776. * @param factor defines the size factor to affect to the specified gradient
  118777. * @returns the current particle system
  118778. */
  118779. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  118780. /**
  118781. * Remove a specific size gradient
  118782. * @param gradient defines the gradient to remove
  118783. * @returns the current particle system
  118784. */
  118785. removeSizeGradient(gradient: number): GPUParticleSystem;
  118786. /**
  118787. * Adds a new angular speed gradient
  118788. * @param gradient defines the gradient to use (between 0 and 1)
  118789. * @param factor defines the angular speed to affect to the specified gradient
  118790. * @returns the current particle system
  118791. */
  118792. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  118793. /**
  118794. * Remove a specific angular speed gradient
  118795. * @param gradient defines the gradient to remove
  118796. * @returns the current particle system
  118797. */
  118798. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  118799. /**
  118800. * Adds a new velocity gradient
  118801. * @param gradient defines the gradient to use (between 0 and 1)
  118802. * @param factor defines the velocity to affect to the specified gradient
  118803. * @returns the current particle system
  118804. */
  118805. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  118806. /**
  118807. * Remove a specific velocity gradient
  118808. * @param gradient defines the gradient to remove
  118809. * @returns the current particle system
  118810. */
  118811. removeVelocityGradient(gradient: number): GPUParticleSystem;
  118812. /**
  118813. * Adds a new limit velocity gradient
  118814. * @param gradient defines the gradient to use (between 0 and 1)
  118815. * @param factor defines the limit velocity value to affect to the specified gradient
  118816. * @returns the current particle system
  118817. */
  118818. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  118819. /**
  118820. * Remove a specific limit velocity gradient
  118821. * @param gradient defines the gradient to remove
  118822. * @returns the current particle system
  118823. */
  118824. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  118825. /**
  118826. * Adds a new drag gradient
  118827. * @param gradient defines the gradient to use (between 0 and 1)
  118828. * @param factor defines the drag value to affect to the specified gradient
  118829. * @returns the current particle system
  118830. */
  118831. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  118832. /**
  118833. * Remove a specific drag gradient
  118834. * @param gradient defines the gradient to remove
  118835. * @returns the current particle system
  118836. */
  118837. removeDragGradient(gradient: number): GPUParticleSystem;
  118838. /**
  118839. * Not supported by GPUParticleSystem
  118840. * @param gradient defines the gradient to use (between 0 and 1)
  118841. * @param factor defines the emit rate value to affect to the specified gradient
  118842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  118843. * @returns the current particle system
  118844. */
  118845. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  118846. /**
  118847. * Not supported by GPUParticleSystem
  118848. * @param gradient defines the gradient to remove
  118849. * @returns the current particle system
  118850. */
  118851. removeEmitRateGradient(gradient: number): IParticleSystem;
  118852. /**
  118853. * Not supported by GPUParticleSystem
  118854. * @param gradient defines the gradient to use (between 0 and 1)
  118855. * @param factor defines the start size value to affect to the specified gradient
  118856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  118857. * @returns the current particle system
  118858. */
  118859. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  118860. /**
  118861. * Not supported by GPUParticleSystem
  118862. * @param gradient defines the gradient to remove
  118863. * @returns the current particle system
  118864. */
  118865. removeStartSizeGradient(gradient: number): IParticleSystem;
  118866. /**
  118867. * Not supported by GPUParticleSystem
  118868. * @param gradient defines the gradient to use (between 0 and 1)
  118869. * @param min defines the color remap minimal range
  118870. * @param max defines the color remap maximal range
  118871. * @returns the current particle system
  118872. */
  118873. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  118874. /**
  118875. * Not supported by GPUParticleSystem
  118876. * @param gradient defines the gradient to remove
  118877. * @returns the current particle system
  118878. */
  118879. removeColorRemapGradient(): IParticleSystem;
  118880. /**
  118881. * Not supported by GPUParticleSystem
  118882. * @param gradient defines the gradient to use (between 0 and 1)
  118883. * @param min defines the alpha remap minimal range
  118884. * @param max defines the alpha remap maximal range
  118885. * @returns the current particle system
  118886. */
  118887. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  118888. /**
  118889. * Not supported by GPUParticleSystem
  118890. * @param gradient defines the gradient to remove
  118891. * @returns the current particle system
  118892. */
  118893. removeAlphaRemapGradient(): IParticleSystem;
  118894. /**
  118895. * Not supported by GPUParticleSystem
  118896. * @param gradient defines the gradient to use (between 0 and 1)
  118897. * @param color defines the color to affect to the specified gradient
  118898. * @returns the current particle system
  118899. */
  118900. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  118901. /**
  118902. * Not supported by GPUParticleSystem
  118903. * @param gradient defines the gradient to remove
  118904. * @returns the current particle system
  118905. */
  118906. removeRampGradient(): IParticleSystem;
  118907. /**
  118908. * Not supported by GPUParticleSystem
  118909. * @returns the list of ramp gradients
  118910. */
  118911. getRampGradients(): Nullable<Array<Color3Gradient>>;
  118912. /**
  118913. * Not supported by GPUParticleSystem
  118914. * Gets or sets a boolean indicating that ramp gradients must be used
  118915. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  118916. */
  118917. useRampGradients: boolean;
  118918. /**
  118919. * Not supported by GPUParticleSystem
  118920. * @param gradient defines the gradient to use (between 0 and 1)
  118921. * @param factor defines the life time factor to affect to the specified gradient
  118922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  118923. * @returns the current particle system
  118924. */
  118925. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  118926. /**
  118927. * Not supported by GPUParticleSystem
  118928. * @param gradient defines the gradient to remove
  118929. * @returns the current particle system
  118930. */
  118931. removeLifeTimeGradient(gradient: number): IParticleSystem;
  118932. /**
  118933. * Instantiates a GPU particle system.
  118934. * 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.
  118935. * @param name The name of the particle system
  118936. * @param options The options used to create the system
  118937. * @param scene The scene the particle system belongs to
  118938. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  118939. */
  118940. constructor(name: string, options: Partial<{
  118941. capacity: number;
  118942. randomTextureSize: number;
  118943. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  118944. protected _reset(): void;
  118945. private _createUpdateVAO;
  118946. private _createRenderVAO;
  118947. private _initialize;
  118948. /** @hidden */
  118949. _recreateUpdateEffect(): void;
  118950. /** @hidden */
  118951. _recreateRenderEffect(): void;
  118952. /**
  118953. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  118954. * @param preWarm defines if we are in the pre-warmimg phase
  118955. */
  118956. animate(preWarm?: boolean): void;
  118957. private _createFactorGradientTexture;
  118958. private _createSizeGradientTexture;
  118959. private _createAngularSpeedGradientTexture;
  118960. private _createVelocityGradientTexture;
  118961. private _createLimitVelocityGradientTexture;
  118962. private _createDragGradientTexture;
  118963. private _createColorGradientTexture;
  118964. /**
  118965. * Renders the particle system in its current state
  118966. * @param preWarm defines if the system should only update the particles but not render them
  118967. * @returns the current number of particles
  118968. */
  118969. render(preWarm?: boolean): number;
  118970. /**
  118971. * Rebuilds the particle system
  118972. */
  118973. rebuild(): void;
  118974. private _releaseBuffers;
  118975. private _releaseVAOs;
  118976. /**
  118977. * Disposes the particle system and free the associated resources
  118978. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  118979. */
  118980. dispose(disposeTexture?: boolean): void;
  118981. /**
  118982. * Clones the particle system.
  118983. * @param name The name of the cloned object
  118984. * @param newEmitter The new emitter to use
  118985. * @returns the cloned particle system
  118986. */
  118987. clone(name: string, newEmitter: any): GPUParticleSystem;
  118988. /**
  118989. * Serializes the particle system to a JSON object.
  118990. * @returns the JSON object
  118991. */
  118992. serialize(): any;
  118993. /**
  118994. * Parses a JSON object to create a GPU particle system.
  118995. * @param parsedParticleSystem The JSON object to parse
  118996. * @param scene The scene to create the particle system in
  118997. * @param rootUrl The root url to use to load external dependencies like texture
  118998. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  118999. * @returns the parsed GPU particle system
  119000. */
  119001. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  119002. }
  119003. }
  119004. declare module BABYLON {
  119005. /**
  119006. * Represents a set of particle systems working together to create a specific effect
  119007. */
  119008. export class ParticleSystemSet implements IDisposable {
  119009. private _emitterCreationOptions;
  119010. private _emitterNode;
  119011. /**
  119012. * Gets the particle system list
  119013. */
  119014. systems: IParticleSystem[];
  119015. /**
  119016. * Gets the emitter node used with this set
  119017. */
  119018. readonly emitterNode: Nullable<TransformNode>;
  119019. /**
  119020. * Creates a new emitter mesh as a sphere
  119021. * @param options defines the options used to create the sphere
  119022. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  119023. * @param scene defines the hosting scene
  119024. */
  119025. setEmitterAsSphere(options: {
  119026. diameter: number;
  119027. segments: number;
  119028. color: Color3;
  119029. }, renderingGroupId: number, scene: Scene): void;
  119030. /**
  119031. * Starts all particle systems of the set
  119032. * @param emitter defines an optional mesh to use as emitter for the particle systems
  119033. */
  119034. start(emitter?: AbstractMesh): void;
  119035. /**
  119036. * Release all associated resources
  119037. */
  119038. dispose(): void;
  119039. /**
  119040. * Serialize the set into a JSON compatible object
  119041. * @returns a JSON compatible representation of the set
  119042. */
  119043. serialize(): any;
  119044. /**
  119045. * Parse a new ParticleSystemSet from a serialized source
  119046. * @param data defines a JSON compatible representation of the set
  119047. * @param scene defines the hosting scene
  119048. * @param gpu defines if we want GPU particles or CPU particles
  119049. * @returns a new ParticleSystemSet
  119050. */
  119051. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  119052. }
  119053. }
  119054. declare module BABYLON {
  119055. /**
  119056. * This class is made for on one-liner static method to help creating particle system set.
  119057. */
  119058. export class ParticleHelper {
  119059. /**
  119060. * Gets or sets base Assets URL
  119061. */
  119062. static BaseAssetsUrl: string;
  119063. /**
  119064. * Create a default particle system that you can tweak
  119065. * @param emitter defines the emitter to use
  119066. * @param capacity defines the system capacity (default is 500 particles)
  119067. * @param scene defines the hosting scene
  119068. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  119069. * @returns the new Particle system
  119070. */
  119071. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  119072. /**
  119073. * This is the main static method (one-liner) of this helper to create different particle systems
  119074. * @param type This string represents the type to the particle system to create
  119075. * @param scene The scene where the particle system should live
  119076. * @param gpu If the system will use gpu
  119077. * @returns the ParticleSystemSet created
  119078. */
  119079. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  119080. /**
  119081. * Static function used to export a particle system to a ParticleSystemSet variable.
  119082. * Please note that the emitter shape is not exported
  119083. * @param systems defines the particle systems to export
  119084. * @returns the created particle system set
  119085. */
  119086. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  119087. }
  119088. }
  119089. declare module BABYLON {
  119090. interface Engine {
  119091. /**
  119092. * Create an effect to use with particle systems.
  119093. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  119094. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  119095. * @param uniformsNames defines a list of attribute names
  119096. * @param samplers defines an array of string used to represent textures
  119097. * @param defines defines the string containing the defines to use to compile the shaders
  119098. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119099. * @param onCompiled defines a function to call when the effect creation is successful
  119100. * @param onError defines a function to call when the effect creation has failed
  119101. * @returns the new Effect
  119102. */
  119103. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  119104. }
  119105. interface Mesh {
  119106. /**
  119107. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  119108. * @returns an array of IParticleSystem
  119109. */
  119110. getEmittedParticleSystems(): IParticleSystem[];
  119111. /**
  119112. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  119113. * @returns an array of IParticleSystem
  119114. */
  119115. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  119116. }
  119117. /**
  119118. * @hidden
  119119. */
  119120. export var _IDoNeedToBeInTheBuild: number;
  119121. }
  119122. declare module BABYLON {
  119123. interface Scene {
  119124. /** @hidden (Backing field) */
  119125. _physicsEngine: Nullable<IPhysicsEngine>;
  119126. /**
  119127. * Gets the current physics engine
  119128. * @returns a IPhysicsEngine or null if none attached
  119129. */
  119130. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  119131. /**
  119132. * Enables physics to the current scene
  119133. * @param gravity defines the scene's gravity for the physics engine
  119134. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  119135. * @return a boolean indicating if the physics engine was initialized
  119136. */
  119137. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  119138. /**
  119139. * Disables and disposes the physics engine associated with the scene
  119140. */
  119141. disablePhysicsEngine(): void;
  119142. /**
  119143. * Gets a boolean indicating if there is an active physics engine
  119144. * @returns a boolean indicating if there is an active physics engine
  119145. */
  119146. isPhysicsEnabled(): boolean;
  119147. /**
  119148. * Deletes a physics compound impostor
  119149. * @param compound defines the compound to delete
  119150. */
  119151. deleteCompoundImpostor(compound: any): void;
  119152. /**
  119153. * An event triggered when physic simulation is about to be run
  119154. */
  119155. onBeforePhysicsObservable: Observable<Scene>;
  119156. /**
  119157. * An event triggered when physic simulation has been done
  119158. */
  119159. onAfterPhysicsObservable: Observable<Scene>;
  119160. }
  119161. interface AbstractMesh {
  119162. /** @hidden */
  119163. _physicsImpostor: Nullable<PhysicsImpostor>;
  119164. /**
  119165. * Gets or sets impostor used for physic simulation
  119166. * @see http://doc.babylonjs.com/features/physics_engine
  119167. */
  119168. physicsImpostor: Nullable<PhysicsImpostor>;
  119169. /**
  119170. * Gets the current physics impostor
  119171. * @see http://doc.babylonjs.com/features/physics_engine
  119172. * @returns a physics impostor or null
  119173. */
  119174. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  119175. /** Apply a physic impulse to the mesh
  119176. * @param force defines the force to apply
  119177. * @param contactPoint defines where to apply the force
  119178. * @returns the current mesh
  119179. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119180. */
  119181. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  119182. /**
  119183. * Creates a physic joint between two meshes
  119184. * @param otherMesh defines the other mesh to use
  119185. * @param pivot1 defines the pivot to use on this mesh
  119186. * @param pivot2 defines the pivot to use on the other mesh
  119187. * @param options defines additional options (can be plugin dependent)
  119188. * @returns the current mesh
  119189. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  119190. */
  119191. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  119192. /** @hidden */
  119193. _disposePhysicsObserver: Nullable<Observer<Node>>;
  119194. }
  119195. /**
  119196. * Defines the physics engine scene component responsible to manage a physics engine
  119197. */
  119198. export class PhysicsEngineSceneComponent implements ISceneComponent {
  119199. /**
  119200. * The component name helpful to identify the component in the list of scene components.
  119201. */
  119202. readonly name: string;
  119203. /**
  119204. * The scene the component belongs to.
  119205. */
  119206. scene: Scene;
  119207. /**
  119208. * Creates a new instance of the component for the given scene
  119209. * @param scene Defines the scene to register the component in
  119210. */
  119211. constructor(scene: Scene);
  119212. /**
  119213. * Registers the component in a given scene
  119214. */
  119215. register(): void;
  119216. /**
  119217. * Rebuilds the elements related to this component in case of
  119218. * context lost for instance.
  119219. */
  119220. rebuild(): void;
  119221. /**
  119222. * Disposes the component and the associated ressources
  119223. */
  119224. dispose(): void;
  119225. }
  119226. }
  119227. declare module BABYLON {
  119228. /**
  119229. * A helper for physics simulations
  119230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119231. */
  119232. export class PhysicsHelper {
  119233. private _scene;
  119234. private _physicsEngine;
  119235. /**
  119236. * Initializes the Physics helper
  119237. * @param scene Babylon.js scene
  119238. */
  119239. constructor(scene: Scene);
  119240. /**
  119241. * Applies a radial explosion impulse
  119242. * @param origin the origin of the explosion
  119243. * @param radiusOrEventOptions the radius or the options of radial explosion
  119244. * @param strength the explosion strength
  119245. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119246. * @returns A physics radial explosion event, or null
  119247. */
  119248. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119249. /**
  119250. * Applies a radial explosion force
  119251. * @param origin the origin of the explosion
  119252. * @param radiusOrEventOptions the radius or the options of radial explosion
  119253. * @param strength the explosion strength
  119254. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119255. * @returns A physics radial explosion event, or null
  119256. */
  119257. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119258. /**
  119259. * Creates a gravitational field
  119260. * @param origin the origin of the explosion
  119261. * @param radiusOrEventOptions the radius or the options of radial explosion
  119262. * @param strength the explosion strength
  119263. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119264. * @returns A physics gravitational field event, or null
  119265. */
  119266. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  119267. /**
  119268. * Creates a physics updraft event
  119269. * @param origin the origin of the updraft
  119270. * @param radiusOrEventOptions the radius or the options of the updraft
  119271. * @param strength the strength of the updraft
  119272. * @param height the height of the updraft
  119273. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  119274. * @returns A physics updraft event, or null
  119275. */
  119276. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  119277. /**
  119278. * Creates a physics vortex event
  119279. * @param origin the of the vortex
  119280. * @param radiusOrEventOptions the radius or the options of the vortex
  119281. * @param strength the strength of the vortex
  119282. * @param height the height of the vortex
  119283. * @returns a Physics vortex event, or null
  119284. * A physics vortex event or null
  119285. */
  119286. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  119287. }
  119288. /**
  119289. * Represents a physics radial explosion event
  119290. */
  119291. class PhysicsRadialExplosionEvent {
  119292. private _scene;
  119293. private _options;
  119294. private _sphere;
  119295. private _dataFetched;
  119296. /**
  119297. * Initializes a radial explosioin event
  119298. * @param _scene BabylonJS scene
  119299. * @param _options The options for the vortex event
  119300. */
  119301. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  119302. /**
  119303. * Returns the data related to the radial explosion event (sphere).
  119304. * @returns The radial explosion event data
  119305. */
  119306. getData(): PhysicsRadialExplosionEventData;
  119307. /**
  119308. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  119309. * @param impostor A physics imposter
  119310. * @param origin the origin of the explosion
  119311. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  119312. */
  119313. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  119314. /**
  119315. * Triggers affecterd impostors callbacks
  119316. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  119317. */
  119318. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  119319. /**
  119320. * Disposes the sphere.
  119321. * @param force Specifies if the sphere should be disposed by force
  119322. */
  119323. dispose(force?: boolean): void;
  119324. /*** Helpers ***/
  119325. private _prepareSphere;
  119326. private _intersectsWithSphere;
  119327. }
  119328. /**
  119329. * Represents a gravitational field event
  119330. */
  119331. class PhysicsGravitationalFieldEvent {
  119332. private _physicsHelper;
  119333. private _scene;
  119334. private _origin;
  119335. private _options;
  119336. private _tickCallback;
  119337. private _sphere;
  119338. private _dataFetched;
  119339. /**
  119340. * Initializes the physics gravitational field event
  119341. * @param _physicsHelper A physics helper
  119342. * @param _scene BabylonJS scene
  119343. * @param _origin The origin position of the gravitational field event
  119344. * @param _options The options for the vortex event
  119345. */
  119346. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  119347. /**
  119348. * Returns the data related to the gravitational field event (sphere).
  119349. * @returns A gravitational field event
  119350. */
  119351. getData(): PhysicsGravitationalFieldEventData;
  119352. /**
  119353. * Enables the gravitational field.
  119354. */
  119355. enable(): void;
  119356. /**
  119357. * Disables the gravitational field.
  119358. */
  119359. disable(): void;
  119360. /**
  119361. * Disposes the sphere.
  119362. * @param force The force to dispose from the gravitational field event
  119363. */
  119364. dispose(force?: boolean): void;
  119365. private _tick;
  119366. }
  119367. /**
  119368. * Represents a physics updraft event
  119369. */
  119370. class PhysicsUpdraftEvent {
  119371. private _scene;
  119372. private _origin;
  119373. private _options;
  119374. private _physicsEngine;
  119375. private _originTop;
  119376. private _originDirection;
  119377. private _tickCallback;
  119378. private _cylinder;
  119379. private _cylinderPosition;
  119380. private _dataFetched;
  119381. /**
  119382. * Initializes the physics updraft event
  119383. * @param _scene BabylonJS scene
  119384. * @param _origin The origin position of the updraft
  119385. * @param _options The options for the updraft event
  119386. */
  119387. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  119388. /**
  119389. * Returns the data related to the updraft event (cylinder).
  119390. * @returns A physics updraft event
  119391. */
  119392. getData(): PhysicsUpdraftEventData;
  119393. /**
  119394. * Enables the updraft.
  119395. */
  119396. enable(): void;
  119397. /**
  119398. * Disables the updraft.
  119399. */
  119400. disable(): void;
  119401. /**
  119402. * Disposes the cylinder.
  119403. * @param force Specifies if the updraft should be disposed by force
  119404. */
  119405. dispose(force?: boolean): void;
  119406. private getImpostorHitData;
  119407. private _tick;
  119408. /*** Helpers ***/
  119409. private _prepareCylinder;
  119410. private _intersectsWithCylinder;
  119411. }
  119412. /**
  119413. * Represents a physics vortex event
  119414. */
  119415. class PhysicsVortexEvent {
  119416. private _scene;
  119417. private _origin;
  119418. private _options;
  119419. private _physicsEngine;
  119420. private _originTop;
  119421. private _tickCallback;
  119422. private _cylinder;
  119423. private _cylinderPosition;
  119424. private _dataFetched;
  119425. /**
  119426. * Initializes the physics vortex event
  119427. * @param _scene The BabylonJS scene
  119428. * @param _origin The origin position of the vortex
  119429. * @param _options The options for the vortex event
  119430. */
  119431. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  119432. /**
  119433. * Returns the data related to the vortex event (cylinder).
  119434. * @returns The physics vortex event data
  119435. */
  119436. getData(): PhysicsVortexEventData;
  119437. /**
  119438. * Enables the vortex.
  119439. */
  119440. enable(): void;
  119441. /**
  119442. * Disables the cortex.
  119443. */
  119444. disable(): void;
  119445. /**
  119446. * Disposes the sphere.
  119447. * @param force
  119448. */
  119449. dispose(force?: boolean): void;
  119450. private getImpostorHitData;
  119451. private _tick;
  119452. /*** Helpers ***/
  119453. private _prepareCylinder;
  119454. private _intersectsWithCylinder;
  119455. }
  119456. /**
  119457. * Options fot the radial explosion event
  119458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119459. */
  119460. export class PhysicsRadialExplosionEventOptions {
  119461. /**
  119462. * The radius of the sphere for the radial explosion.
  119463. */
  119464. radius: number;
  119465. /**
  119466. * The strenth of the explosion.
  119467. */
  119468. strength: number;
  119469. /**
  119470. * The strenght of the force in correspondence to the distance of the affected object
  119471. */
  119472. falloff: PhysicsRadialImpulseFalloff;
  119473. /**
  119474. * Sphere options for the radial explosion.
  119475. */
  119476. sphere: {
  119477. segments: number;
  119478. diameter: number;
  119479. };
  119480. /**
  119481. * Sphere options for the radial explosion.
  119482. */
  119483. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  119484. }
  119485. /**
  119486. * Options fot the updraft event
  119487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119488. */
  119489. export class PhysicsUpdraftEventOptions {
  119490. /**
  119491. * The radius of the cylinder for the vortex
  119492. */
  119493. radius: number;
  119494. /**
  119495. * The strenth of the updraft.
  119496. */
  119497. strength: number;
  119498. /**
  119499. * The height of the cylinder for the updraft.
  119500. */
  119501. height: number;
  119502. /**
  119503. * The mode for the the updraft.
  119504. */
  119505. updraftMode: PhysicsUpdraftMode;
  119506. }
  119507. /**
  119508. * Options fot the vortex event
  119509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119510. */
  119511. export class PhysicsVortexEventOptions {
  119512. /**
  119513. * The radius of the cylinder for the vortex
  119514. */
  119515. radius: number;
  119516. /**
  119517. * The strenth of the vortex.
  119518. */
  119519. strength: number;
  119520. /**
  119521. * The height of the cylinder for the vortex.
  119522. */
  119523. height: number;
  119524. /**
  119525. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  119526. */
  119527. centripetalForceThreshold: number;
  119528. /**
  119529. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  119530. */
  119531. centripetalForceMultiplier: number;
  119532. /**
  119533. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  119534. */
  119535. centrifugalForceMultiplier: number;
  119536. /**
  119537. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  119538. */
  119539. updraftForceMultiplier: number;
  119540. }
  119541. /**
  119542. * The strenght of the force in correspondence to the distance of the affected object
  119543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119544. */
  119545. export enum PhysicsRadialImpulseFalloff {
  119546. /** Defines that impulse is constant in strength across it's whole radius */
  119547. Constant = 0,
  119548. /** Defines that impulse gets weaker if it's further from the origin */
  119549. Linear = 1
  119550. }
  119551. /**
  119552. * The strength of the force in correspondence to the distance of the affected object
  119553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119554. */
  119555. export enum PhysicsUpdraftMode {
  119556. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  119557. Center = 0,
  119558. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  119559. Perpendicular = 1
  119560. }
  119561. /**
  119562. * Interface for a physics hit data
  119563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119564. */
  119565. export interface PhysicsHitData {
  119566. /**
  119567. * The force applied at the contact point
  119568. */
  119569. force: Vector3;
  119570. /**
  119571. * The contact point
  119572. */
  119573. contactPoint: Vector3;
  119574. /**
  119575. * The distance from the origin to the contact point
  119576. */
  119577. distanceFromOrigin: number;
  119578. }
  119579. /**
  119580. * Interface for radial explosion event data
  119581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119582. */
  119583. export interface PhysicsRadialExplosionEventData {
  119584. /**
  119585. * A sphere used for the radial explosion event
  119586. */
  119587. sphere: Mesh;
  119588. }
  119589. /**
  119590. * Interface for gravitational field event data
  119591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119592. */
  119593. export interface PhysicsGravitationalFieldEventData {
  119594. /**
  119595. * A sphere mesh used for the gravitational field event
  119596. */
  119597. sphere: Mesh;
  119598. }
  119599. /**
  119600. * Interface for updraft event data
  119601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119602. */
  119603. export interface PhysicsUpdraftEventData {
  119604. /**
  119605. * A cylinder used for the updraft event
  119606. */
  119607. cylinder: Mesh;
  119608. }
  119609. /**
  119610. * Interface for vortex event data
  119611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119612. */
  119613. export interface PhysicsVortexEventData {
  119614. /**
  119615. * A cylinder used for the vortex event
  119616. */
  119617. cylinder: Mesh;
  119618. }
  119619. /**
  119620. * Interface for an affected physics impostor
  119621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119622. */
  119623. export interface PhysicsAffectedImpostorWithData {
  119624. /**
  119625. * The impostor affected by the effect
  119626. */
  119627. impostor: PhysicsImpostor;
  119628. /**
  119629. * The data about the hit/horce from the explosion
  119630. */
  119631. hitData: PhysicsHitData;
  119632. }
  119633. }
  119634. declare module BABYLON {
  119635. /** @hidden */
  119636. export var blackAndWhitePixelShader: {
  119637. name: string;
  119638. shader: string;
  119639. };
  119640. }
  119641. declare module BABYLON {
  119642. /**
  119643. * Post process used to render in black and white
  119644. */
  119645. export class BlackAndWhitePostProcess extends PostProcess {
  119646. /**
  119647. * Linear about to convert he result to black and white (default: 1)
  119648. */
  119649. degree: number;
  119650. /**
  119651. * Creates a black and white post process
  119652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  119653. * @param name The name of the effect.
  119654. * @param options The required width/height ratio to downsize to before computing the render pass.
  119655. * @param camera The camera to apply the render pass to.
  119656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119657. * @param engine The engine which the post process will be applied. (default: current engine)
  119658. * @param reusable If the post process can be reused on the same frame. (default: false)
  119659. */
  119660. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119661. }
  119662. }
  119663. declare module BABYLON {
  119664. /**
  119665. * This represents a set of one or more post processes in Babylon.
  119666. * A post process can be used to apply a shader to a texture after it is rendered.
  119667. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119668. */
  119669. export class PostProcessRenderEffect {
  119670. private _postProcesses;
  119671. private _getPostProcesses;
  119672. private _singleInstance;
  119673. private _cameras;
  119674. private _indicesForCamera;
  119675. /**
  119676. * Name of the effect
  119677. * @hidden
  119678. */
  119679. _name: string;
  119680. /**
  119681. * Instantiates a post process render effect.
  119682. * A post process can be used to apply a shader to a texture after it is rendered.
  119683. * @param engine The engine the effect is tied to
  119684. * @param name The name of the effect
  119685. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  119686. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  119687. */
  119688. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  119689. /**
  119690. * Checks if all the post processes in the effect are supported.
  119691. */
  119692. readonly isSupported: boolean;
  119693. /**
  119694. * Updates the current state of the effect
  119695. * @hidden
  119696. */
  119697. _update(): void;
  119698. /**
  119699. * Attaches the effect on cameras
  119700. * @param cameras The camera to attach to.
  119701. * @hidden
  119702. */
  119703. _attachCameras(cameras: Camera): void;
  119704. /**
  119705. * Attaches the effect on cameras
  119706. * @param cameras The camera to attach to.
  119707. * @hidden
  119708. */
  119709. _attachCameras(cameras: Camera[]): void;
  119710. /**
  119711. * Detaches the effect on cameras
  119712. * @param cameras The camera to detatch from.
  119713. * @hidden
  119714. */
  119715. _detachCameras(cameras: Camera): void;
  119716. /**
  119717. * Detatches the effect on cameras
  119718. * @param cameras The camera to detatch from.
  119719. * @hidden
  119720. */
  119721. _detachCameras(cameras: Camera[]): void;
  119722. /**
  119723. * Enables the effect on given cameras
  119724. * @param cameras The camera to enable.
  119725. * @hidden
  119726. */
  119727. _enable(cameras: Camera): void;
  119728. /**
  119729. * Enables the effect on given cameras
  119730. * @param cameras The camera to enable.
  119731. * @hidden
  119732. */
  119733. _enable(cameras: Nullable<Camera[]>): void;
  119734. /**
  119735. * Disables the effect on the given cameras
  119736. * @param cameras The camera to disable.
  119737. * @hidden
  119738. */
  119739. _disable(cameras: Camera): void;
  119740. /**
  119741. * Disables the effect on the given cameras
  119742. * @param cameras The camera to disable.
  119743. * @hidden
  119744. */
  119745. _disable(cameras: Nullable<Camera[]>): void;
  119746. /**
  119747. * Gets a list of the post processes contained in the effect.
  119748. * @param camera The camera to get the post processes on.
  119749. * @returns The list of the post processes in the effect.
  119750. */
  119751. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  119752. }
  119753. }
  119754. declare module BABYLON {
  119755. /** @hidden */
  119756. export var extractHighlightsPixelShader: {
  119757. name: string;
  119758. shader: string;
  119759. };
  119760. }
  119761. declare module BABYLON {
  119762. /**
  119763. * 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.
  119764. */
  119765. export class ExtractHighlightsPostProcess extends PostProcess {
  119766. /**
  119767. * The luminance threshold, pixels below this value will be set to black.
  119768. */
  119769. threshold: number;
  119770. /** @hidden */
  119771. _exposure: number;
  119772. /**
  119773. * Post process which has the input texture to be used when performing highlight extraction
  119774. * @hidden
  119775. */
  119776. _inputPostProcess: Nullable<PostProcess>;
  119777. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119778. }
  119779. }
  119780. declare module BABYLON {
  119781. /** @hidden */
  119782. export var bloomMergePixelShader: {
  119783. name: string;
  119784. shader: string;
  119785. };
  119786. }
  119787. declare module BABYLON {
  119788. /**
  119789. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  119790. */
  119791. export class BloomMergePostProcess extends PostProcess {
  119792. /** Weight of the bloom to be added to the original input. */
  119793. weight: number;
  119794. /**
  119795. * Creates a new instance of @see BloomMergePostProcess
  119796. * @param name The name of the effect.
  119797. * @param originalFromInput Post process which's input will be used for the merge.
  119798. * @param blurred Blurred highlights post process which's output will be used.
  119799. * @param weight Weight of the bloom to be added to the original input.
  119800. * @param options The required width/height ratio to downsize to before computing the render pass.
  119801. * @param camera The camera to apply the render pass to.
  119802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119803. * @param engine The engine which the post process will be applied. (default: current engine)
  119804. * @param reusable If the post process can be reused on the same frame. (default: false)
  119805. * @param textureType Type of textures used when performing the post process. (default: 0)
  119806. * @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)
  119807. */
  119808. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  119809. /** Weight of the bloom to be added to the original input. */
  119810. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119811. }
  119812. }
  119813. declare module BABYLON {
  119814. /**
  119815. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  119816. */
  119817. export class BloomEffect extends PostProcessRenderEffect {
  119818. private bloomScale;
  119819. /**
  119820. * @hidden Internal
  119821. */
  119822. _effects: Array<PostProcess>;
  119823. /**
  119824. * @hidden Internal
  119825. */
  119826. _downscale: ExtractHighlightsPostProcess;
  119827. private _blurX;
  119828. private _blurY;
  119829. private _merge;
  119830. /**
  119831. * The luminance threshold to find bright areas of the image to bloom.
  119832. */
  119833. threshold: number;
  119834. /**
  119835. * The strength of the bloom.
  119836. */
  119837. weight: number;
  119838. /**
  119839. * Specifies the size of the bloom blur kernel, relative to the final output size
  119840. */
  119841. kernel: number;
  119842. /**
  119843. * Creates a new instance of @see BloomEffect
  119844. * @param scene The scene the effect belongs to.
  119845. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  119846. * @param bloomKernel The size of the kernel to be used when applying the blur.
  119847. * @param bloomWeight The the strength of bloom.
  119848. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  119849. * @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)
  119850. */
  119851. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  119852. /**
  119853. * Disposes each of the internal effects for a given camera.
  119854. * @param camera The camera to dispose the effect on.
  119855. */
  119856. disposeEffects(camera: Camera): void;
  119857. /**
  119858. * @hidden Internal
  119859. */
  119860. _updateEffects(): void;
  119861. /**
  119862. * Internal
  119863. * @returns if all the contained post processes are ready.
  119864. * @hidden
  119865. */
  119866. _isReady(): boolean;
  119867. }
  119868. }
  119869. declare module BABYLON {
  119870. /** @hidden */
  119871. export var chromaticAberrationPixelShader: {
  119872. name: string;
  119873. shader: string;
  119874. };
  119875. }
  119876. declare module BABYLON {
  119877. /**
  119878. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  119879. */
  119880. export class ChromaticAberrationPostProcess extends PostProcess {
  119881. /**
  119882. * The amount of seperation of rgb channels (default: 30)
  119883. */
  119884. aberrationAmount: number;
  119885. /**
  119886. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  119887. */
  119888. radialIntensity: number;
  119889. /**
  119890. * 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))
  119891. */
  119892. direction: Vector2;
  119893. /**
  119894. * 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))
  119895. */
  119896. centerPosition: Vector2;
  119897. /**
  119898. * Creates a new instance ChromaticAberrationPostProcess
  119899. * @param name The name of the effect.
  119900. * @param screenWidth The width of the screen to apply the effect on.
  119901. * @param screenHeight The height of the screen to apply the effect on.
  119902. * @param options The required width/height ratio to downsize to before computing the render pass.
  119903. * @param camera The camera to apply the render pass to.
  119904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119905. * @param engine The engine which the post process will be applied. (default: current engine)
  119906. * @param reusable If the post process can be reused on the same frame. (default: false)
  119907. * @param textureType Type of textures used when performing the post process. (default: 0)
  119908. * @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)
  119909. */
  119910. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119911. }
  119912. }
  119913. declare module BABYLON {
  119914. /** @hidden */
  119915. export var circleOfConfusionPixelShader: {
  119916. name: string;
  119917. shader: string;
  119918. };
  119919. }
  119920. declare module BABYLON {
  119921. /**
  119922. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  119923. */
  119924. export class CircleOfConfusionPostProcess extends PostProcess {
  119925. /**
  119926. * 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.
  119927. */
  119928. lensSize: number;
  119929. /**
  119930. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  119931. */
  119932. fStop: number;
  119933. /**
  119934. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  119935. */
  119936. focusDistance: number;
  119937. /**
  119938. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  119939. */
  119940. focalLength: number;
  119941. private _depthTexture;
  119942. /**
  119943. * Creates a new instance CircleOfConfusionPostProcess
  119944. * @param name The name of the effect.
  119945. * @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.
  119946. * @param options The required width/height ratio to downsize to before computing the render pass.
  119947. * @param camera The camera to apply the render pass to.
  119948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119949. * @param engine The engine which the post process will be applied. (default: current engine)
  119950. * @param reusable If the post process can be reused on the same frame. (default: false)
  119951. * @param textureType Type of textures used when performing the post process. (default: 0)
  119952. * @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)
  119953. */
  119954. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119955. /**
  119956. * 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.
  119957. */
  119958. depthTexture: RenderTargetTexture;
  119959. }
  119960. }
  119961. declare module BABYLON {
  119962. /** @hidden */
  119963. export var colorCorrectionPixelShader: {
  119964. name: string;
  119965. shader: string;
  119966. };
  119967. }
  119968. declare module BABYLON {
  119969. /**
  119970. *
  119971. * This post-process allows the modification of rendered colors by using
  119972. * a 'look-up table' (LUT). This effect is also called Color Grading.
  119973. *
  119974. * The object needs to be provided an url to a texture containing the color
  119975. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  119976. * Use an image editing software to tweak the LUT to match your needs.
  119977. *
  119978. * For an example of a color LUT, see here:
  119979. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  119980. * For explanations on color grading, see here:
  119981. * @see http://udn.epicgames.com/Three/ColorGrading.html
  119982. *
  119983. */
  119984. export class ColorCorrectionPostProcess extends PostProcess {
  119985. private _colorTableTexture;
  119986. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119987. }
  119988. }
  119989. declare module BABYLON {
  119990. /** @hidden */
  119991. export var convolutionPixelShader: {
  119992. name: string;
  119993. shader: string;
  119994. };
  119995. }
  119996. declare module BABYLON {
  119997. /**
  119998. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  119999. * input texture to perform effects such as edge detection or sharpening
  120000. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120001. */
  120002. export class ConvolutionPostProcess extends PostProcess {
  120003. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120004. kernel: number[];
  120005. /**
  120006. * Creates a new instance ConvolutionPostProcess
  120007. * @param name The name of the effect.
  120008. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  120009. * @param options The required width/height ratio to downsize to before computing the render pass.
  120010. * @param camera The camera to apply the render pass to.
  120011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120012. * @param engine The engine which the post process will be applied. (default: current engine)
  120013. * @param reusable If the post process can be reused on the same frame. (default: false)
  120014. * @param textureType Type of textures used when performing the post process. (default: 0)
  120015. */
  120016. constructor(name: string,
  120017. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120018. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120019. /**
  120020. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120021. */
  120022. static EdgeDetect0Kernel: number[];
  120023. /**
  120024. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120025. */
  120026. static EdgeDetect1Kernel: number[];
  120027. /**
  120028. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120029. */
  120030. static EdgeDetect2Kernel: number[];
  120031. /**
  120032. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120033. */
  120034. static SharpenKernel: number[];
  120035. /**
  120036. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120037. */
  120038. static EmbossKernel: number[];
  120039. /**
  120040. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120041. */
  120042. static GaussianKernel: number[];
  120043. }
  120044. }
  120045. declare module BABYLON {
  120046. /**
  120047. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  120048. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  120049. * based on samples that have a large difference in distance than the center pixel.
  120050. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  120051. */
  120052. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  120053. direction: Vector2;
  120054. /**
  120055. * Creates a new instance CircleOfConfusionPostProcess
  120056. * @param name The name of the effect.
  120057. * @param scene The scene the effect belongs to.
  120058. * @param direction The direction the blur should be applied.
  120059. * @param kernel The size of the kernel used to blur.
  120060. * @param options The required width/height ratio to downsize to before computing the render pass.
  120061. * @param camera The camera to apply the render pass to.
  120062. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  120063. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  120064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120065. * @param engine The engine which the post process will be applied. (default: current engine)
  120066. * @param reusable If the post process can be reused on the same frame. (default: false)
  120067. * @param textureType Type of textures used when performing the post process. (default: 0)
  120068. * @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)
  120069. */
  120070. 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);
  120071. }
  120072. }
  120073. declare module BABYLON {
  120074. /** @hidden */
  120075. export var depthOfFieldMergePixelShader: {
  120076. name: string;
  120077. shader: string;
  120078. };
  120079. }
  120080. declare module BABYLON {
  120081. /**
  120082. * Options to be set when merging outputs from the default pipeline.
  120083. */
  120084. export class DepthOfFieldMergePostProcessOptions {
  120085. /**
  120086. * The original image to merge on top of
  120087. */
  120088. originalFromInput: PostProcess;
  120089. /**
  120090. * Parameters to perform the merge of the depth of field effect
  120091. */
  120092. depthOfField?: {
  120093. circleOfConfusion: PostProcess;
  120094. blurSteps: Array<PostProcess>;
  120095. };
  120096. /**
  120097. * Parameters to perform the merge of bloom effect
  120098. */
  120099. bloom?: {
  120100. blurred: PostProcess;
  120101. weight: number;
  120102. };
  120103. }
  120104. /**
  120105. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120106. */
  120107. export class DepthOfFieldMergePostProcess extends PostProcess {
  120108. private blurSteps;
  120109. /**
  120110. * Creates a new instance of DepthOfFieldMergePostProcess
  120111. * @param name The name of the effect.
  120112. * @param originalFromInput Post process which's input will be used for the merge.
  120113. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  120114. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  120115. * @param options The required width/height ratio to downsize to before computing the render pass.
  120116. * @param camera The camera to apply the render pass to.
  120117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120118. * @param engine The engine which the post process will be applied. (default: current engine)
  120119. * @param reusable If the post process can be reused on the same frame. (default: false)
  120120. * @param textureType Type of textures used when performing the post process. (default: 0)
  120121. * @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)
  120122. */
  120123. 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);
  120124. /**
  120125. * Updates the effect with the current post process compile time values and recompiles the shader.
  120126. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  120127. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  120128. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  120129. * @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
  120130. * @param onCompiled Called when the shader has been compiled.
  120131. * @param onError Called if there is an error when compiling a shader.
  120132. */
  120133. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  120134. }
  120135. }
  120136. declare module BABYLON {
  120137. /**
  120138. * Specifies the level of max blur that should be applied when using the depth of field effect
  120139. */
  120140. export enum DepthOfFieldEffectBlurLevel {
  120141. /**
  120142. * Subtle blur
  120143. */
  120144. Low = 0,
  120145. /**
  120146. * Medium blur
  120147. */
  120148. Medium = 1,
  120149. /**
  120150. * Large blur
  120151. */
  120152. High = 2
  120153. }
  120154. /**
  120155. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  120156. */
  120157. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  120158. private _circleOfConfusion;
  120159. /**
  120160. * @hidden Internal, blurs from high to low
  120161. */
  120162. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  120163. private _depthOfFieldBlurY;
  120164. private _dofMerge;
  120165. /**
  120166. * @hidden Internal post processes in depth of field effect
  120167. */
  120168. _effects: Array<PostProcess>;
  120169. /**
  120170. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  120171. */
  120172. focalLength: number;
  120173. /**
  120174. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120175. */
  120176. fStop: number;
  120177. /**
  120178. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120179. */
  120180. focusDistance: number;
  120181. /**
  120182. * 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.
  120183. */
  120184. lensSize: number;
  120185. /**
  120186. * Creates a new instance DepthOfFieldEffect
  120187. * @param scene The scene the effect belongs to.
  120188. * @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.
  120189. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120190. * @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)
  120191. */
  120192. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  120193. /**
  120194. * Get the current class name of the current effet
  120195. * @returns "DepthOfFieldEffect"
  120196. */
  120197. getClassName(): string;
  120198. /**
  120199. * 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.
  120200. */
  120201. depthTexture: RenderTargetTexture;
  120202. /**
  120203. * Disposes each of the internal effects for a given camera.
  120204. * @param camera The camera to dispose the effect on.
  120205. */
  120206. disposeEffects(camera: Camera): void;
  120207. /**
  120208. * @hidden Internal
  120209. */
  120210. _updateEffects(): void;
  120211. /**
  120212. * Internal
  120213. * @returns if all the contained post processes are ready.
  120214. * @hidden
  120215. */
  120216. _isReady(): boolean;
  120217. }
  120218. }
  120219. declare module BABYLON {
  120220. /** @hidden */
  120221. export var displayPassPixelShader: {
  120222. name: string;
  120223. shader: string;
  120224. };
  120225. }
  120226. declare module BABYLON {
  120227. /**
  120228. * DisplayPassPostProcess which produces an output the same as it's input
  120229. */
  120230. export class DisplayPassPostProcess extends PostProcess {
  120231. /**
  120232. * Creates the DisplayPassPostProcess
  120233. * @param name The name of the effect.
  120234. * @param options The required width/height ratio to downsize to before computing the render pass.
  120235. * @param camera The camera to apply the render pass to.
  120236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120237. * @param engine The engine which the post process will be applied. (default: current engine)
  120238. * @param reusable If the post process can be reused on the same frame. (default: false)
  120239. */
  120240. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120241. }
  120242. }
  120243. declare module BABYLON {
  120244. /** @hidden */
  120245. export var filterPixelShader: {
  120246. name: string;
  120247. shader: string;
  120248. };
  120249. }
  120250. declare module BABYLON {
  120251. /**
  120252. * Applies a kernel filter to the image
  120253. */
  120254. export class FilterPostProcess extends PostProcess {
  120255. /** The matrix to be applied to the image */
  120256. kernelMatrix: Matrix;
  120257. /**
  120258. *
  120259. * @param name The name of the effect.
  120260. * @param kernelMatrix The matrix to be applied to the image
  120261. * @param options The required width/height ratio to downsize to before computing the render pass.
  120262. * @param camera The camera to apply the render pass to.
  120263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120264. * @param engine The engine which the post process will be applied. (default: current engine)
  120265. * @param reusable If the post process can be reused on the same frame. (default: false)
  120266. */
  120267. constructor(name: string,
  120268. /** The matrix to be applied to the image */
  120269. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120270. }
  120271. }
  120272. declare module BABYLON {
  120273. /** @hidden */
  120274. export var fxaaPixelShader: {
  120275. name: string;
  120276. shader: string;
  120277. };
  120278. }
  120279. declare module BABYLON {
  120280. /** @hidden */
  120281. export var fxaaVertexShader: {
  120282. name: string;
  120283. shader: string;
  120284. };
  120285. }
  120286. declare module BABYLON {
  120287. /**
  120288. * Fxaa post process
  120289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  120290. */
  120291. export class FxaaPostProcess extends PostProcess {
  120292. /** @hidden */
  120293. texelWidth: number;
  120294. /** @hidden */
  120295. texelHeight: number;
  120296. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120297. private _getDefines;
  120298. }
  120299. }
  120300. declare module BABYLON {
  120301. /** @hidden */
  120302. export var grainPixelShader: {
  120303. name: string;
  120304. shader: string;
  120305. };
  120306. }
  120307. declare module BABYLON {
  120308. /**
  120309. * The GrainPostProcess adds noise to the image at mid luminance levels
  120310. */
  120311. export class GrainPostProcess extends PostProcess {
  120312. /**
  120313. * The intensity of the grain added (default: 30)
  120314. */
  120315. intensity: number;
  120316. /**
  120317. * If the grain should be randomized on every frame
  120318. */
  120319. animated: boolean;
  120320. /**
  120321. * Creates a new instance of @see GrainPostProcess
  120322. * @param name The name of the effect.
  120323. * @param options The required width/height ratio to downsize to before computing the render pass.
  120324. * @param camera The camera to apply the render pass to.
  120325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120326. * @param engine The engine which the post process will be applied. (default: current engine)
  120327. * @param reusable If the post process can be reused on the same frame. (default: false)
  120328. * @param textureType Type of textures used when performing the post process. (default: 0)
  120329. * @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)
  120330. */
  120331. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120332. }
  120333. }
  120334. declare module BABYLON {
  120335. /** @hidden */
  120336. export var highlightsPixelShader: {
  120337. name: string;
  120338. shader: string;
  120339. };
  120340. }
  120341. declare module BABYLON {
  120342. /**
  120343. * Extracts highlights from the image
  120344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120345. */
  120346. export class HighlightsPostProcess extends PostProcess {
  120347. /**
  120348. * Extracts highlights from the image
  120349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120350. * @param name The name of the effect.
  120351. * @param options The required width/height ratio to downsize to before computing the render pass.
  120352. * @param camera The camera to apply the render pass to.
  120353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120354. * @param engine The engine which the post process will be applied. (default: current engine)
  120355. * @param reusable If the post process can be reused on the same frame. (default: false)
  120356. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  120357. */
  120358. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120359. }
  120360. }
  120361. declare module BABYLON {
  120362. /** @hidden */
  120363. export var mrtFragmentDeclaration: {
  120364. name: string;
  120365. shader: string;
  120366. };
  120367. }
  120368. declare module BABYLON {
  120369. /** @hidden */
  120370. export var geometryPixelShader: {
  120371. name: string;
  120372. shader: string;
  120373. };
  120374. }
  120375. declare module BABYLON {
  120376. /** @hidden */
  120377. export var geometryVertexShader: {
  120378. name: string;
  120379. shader: string;
  120380. };
  120381. }
  120382. declare module BABYLON {
  120383. /** @hidden */
  120384. interface ISavedTransformationMatrix {
  120385. world: Matrix;
  120386. viewProjection: Matrix;
  120387. }
  120388. /**
  120389. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  120390. */
  120391. export class GeometryBufferRenderer {
  120392. /**
  120393. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120394. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120395. */
  120396. static readonly POSITION_TEXTURE_TYPE: number;
  120397. /**
  120398. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120399. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  120400. */
  120401. static readonly VELOCITY_TEXTURE_TYPE: number;
  120402. /**
  120403. * Dictionary used to store the previous transformation matrices of each rendered mesh
  120404. * in order to compute objects velocities when enableVelocity is set to "true"
  120405. * @hidden
  120406. */
  120407. _previousTransformationMatrices: {
  120408. [index: number]: ISavedTransformationMatrix;
  120409. };
  120410. /**
  120411. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  120412. * in order to compute objects velocities when enableVelocity is set to "true"
  120413. * @hidden
  120414. */
  120415. _previousBonesTransformationMatrices: {
  120416. [index: number]: Float32Array;
  120417. };
  120418. /**
  120419. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  120420. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  120421. */
  120422. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  120423. private _scene;
  120424. private _multiRenderTarget;
  120425. private _ratio;
  120426. private _enablePosition;
  120427. private _enableVelocity;
  120428. private _positionIndex;
  120429. private _velocityIndex;
  120430. protected _effect: Effect;
  120431. protected _cachedDefines: string;
  120432. /**
  120433. * Set the render list (meshes to be rendered) used in the G buffer.
  120434. */
  120435. renderList: Mesh[];
  120436. /**
  120437. * Gets wether or not G buffer are supported by the running hardware.
  120438. * This requires draw buffer supports
  120439. */
  120440. readonly isSupported: boolean;
  120441. /**
  120442. * Returns the index of the given texture type in the G-Buffer textures array
  120443. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  120444. * @returns the index of the given texture type in the G-Buffer textures array
  120445. */
  120446. getTextureIndex(textureType: number): number;
  120447. /**
  120448. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  120449. */
  120450. /**
  120451. * Sets whether or not objects positions are enabled for the G buffer.
  120452. */
  120453. enablePosition: boolean;
  120454. /**
  120455. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  120456. */
  120457. /**
  120458. * Sets wether or not objects velocities are enabled for the G buffer.
  120459. */
  120460. enableVelocity: boolean;
  120461. /**
  120462. * Gets the scene associated with the buffer.
  120463. */
  120464. readonly scene: Scene;
  120465. /**
  120466. * Gets the ratio used by the buffer during its creation.
  120467. * How big is the buffer related to the main canvas.
  120468. */
  120469. readonly ratio: number;
  120470. /** @hidden */
  120471. static _SceneComponentInitialization: (scene: Scene) => void;
  120472. /**
  120473. * Creates a new G Buffer for the scene
  120474. * @param scene The scene the buffer belongs to
  120475. * @param ratio How big is the buffer related to the main canvas.
  120476. */
  120477. constructor(scene: Scene, ratio?: number);
  120478. /**
  120479. * Checks wether everything is ready to render a submesh to the G buffer.
  120480. * @param subMesh the submesh to check readiness for
  120481. * @param useInstances is the mesh drawn using instance or not
  120482. * @returns true if ready otherwise false
  120483. */
  120484. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120485. /**
  120486. * Gets the current underlying G Buffer.
  120487. * @returns the buffer
  120488. */
  120489. getGBuffer(): MultiRenderTarget;
  120490. /**
  120491. * Gets the number of samples used to render the buffer (anti aliasing).
  120492. */
  120493. /**
  120494. * Sets the number of samples used to render the buffer (anti aliasing).
  120495. */
  120496. samples: number;
  120497. /**
  120498. * Disposes the renderer and frees up associated resources.
  120499. */
  120500. dispose(): void;
  120501. protected _createRenderTargets(): void;
  120502. private _copyBonesTransformationMatrices;
  120503. }
  120504. }
  120505. declare module BABYLON {
  120506. interface Scene {
  120507. /** @hidden (Backing field) */
  120508. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  120509. /**
  120510. * Gets or Sets the current geometry buffer associated to the scene.
  120511. */
  120512. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  120513. /**
  120514. * Enables a GeometryBufferRender and associates it with the scene
  120515. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  120516. * @returns the GeometryBufferRenderer
  120517. */
  120518. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  120519. /**
  120520. * Disables the GeometryBufferRender associated with the scene
  120521. */
  120522. disableGeometryBufferRenderer(): void;
  120523. }
  120524. /**
  120525. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  120526. * in several rendering techniques.
  120527. */
  120528. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  120529. /**
  120530. * The component name helpful to identify the component in the list of scene components.
  120531. */
  120532. readonly name: string;
  120533. /**
  120534. * The scene the component belongs to.
  120535. */
  120536. scene: Scene;
  120537. /**
  120538. * Creates a new instance of the component for the given scene
  120539. * @param scene Defines the scene to register the component in
  120540. */
  120541. constructor(scene: Scene);
  120542. /**
  120543. * Registers the component in a given scene
  120544. */
  120545. register(): void;
  120546. /**
  120547. * Rebuilds the elements related to this component in case of
  120548. * context lost for instance.
  120549. */
  120550. rebuild(): void;
  120551. /**
  120552. * Disposes the component and the associated ressources
  120553. */
  120554. dispose(): void;
  120555. private _gatherRenderTargets;
  120556. }
  120557. }
  120558. declare module BABYLON {
  120559. /** @hidden */
  120560. export var motionBlurPixelShader: {
  120561. name: string;
  120562. shader: string;
  120563. };
  120564. }
  120565. declare module BABYLON {
  120566. /**
  120567. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  120568. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  120569. * As an example, all you have to do is to create the post-process:
  120570. * var mb = new BABYLON.MotionBlurPostProcess(
  120571. * 'mb', // The name of the effect.
  120572. * scene, // The scene containing the objects to blur according to their velocity.
  120573. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  120574. * camera // The camera to apply the render pass to.
  120575. * );
  120576. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  120577. */
  120578. export class MotionBlurPostProcess extends PostProcess {
  120579. /**
  120580. * Defines how much the image is blurred by the movement. Default value is equal to 1
  120581. */
  120582. motionStrength: number;
  120583. /**
  120584. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  120585. */
  120586. /**
  120587. * Sets the number of iterations to be used for motion blur quality
  120588. */
  120589. motionBlurSamples: number;
  120590. private _motionBlurSamples;
  120591. private _geometryBufferRenderer;
  120592. /**
  120593. * Creates a new instance MotionBlurPostProcess
  120594. * @param name The name of the effect.
  120595. * @param scene The scene containing the objects to blur according to their velocity.
  120596. * @param options The required width/height ratio to downsize to before computing the render pass.
  120597. * @param camera The camera to apply the render pass to.
  120598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120599. * @param engine The engine which the post process will be applied. (default: current engine)
  120600. * @param reusable If the post process can be reused on the same frame. (default: false)
  120601. * @param textureType Type of textures used when performing the post process. (default: 0)
  120602. * @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)
  120603. */
  120604. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120605. /**
  120606. * Excludes the given skinned mesh from computing bones velocities.
  120607. * 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.
  120608. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  120609. */
  120610. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  120611. /**
  120612. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  120613. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  120614. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  120615. */
  120616. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  120617. /**
  120618. * Disposes the post process.
  120619. * @param camera The camera to dispose the post process on.
  120620. */
  120621. dispose(camera?: Camera): void;
  120622. }
  120623. }
  120624. declare module BABYLON {
  120625. /** @hidden */
  120626. export var refractionPixelShader: {
  120627. name: string;
  120628. shader: string;
  120629. };
  120630. }
  120631. declare module BABYLON {
  120632. /**
  120633. * Post process which applies a refractin texture
  120634. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  120635. */
  120636. export class RefractionPostProcess extends PostProcess {
  120637. /** the base color of the refraction (used to taint the rendering) */
  120638. color: Color3;
  120639. /** simulated refraction depth */
  120640. depth: number;
  120641. /** the coefficient of the base color (0 to remove base color tainting) */
  120642. colorLevel: number;
  120643. private _refTexture;
  120644. private _ownRefractionTexture;
  120645. /**
  120646. * Gets or sets the refraction texture
  120647. * Please note that you are responsible for disposing the texture if you set it manually
  120648. */
  120649. refractionTexture: Texture;
  120650. /**
  120651. * Initializes the RefractionPostProcess
  120652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  120653. * @param name The name of the effect.
  120654. * @param refractionTextureUrl Url of the refraction texture to use
  120655. * @param color the base color of the refraction (used to taint the rendering)
  120656. * @param depth simulated refraction depth
  120657. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  120658. * @param camera The camera to apply the render pass to.
  120659. * @param options The required width/height ratio to downsize to before computing the render pass.
  120660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120661. * @param engine The engine which the post process will be applied. (default: current engine)
  120662. * @param reusable If the post process can be reused on the same frame. (default: false)
  120663. */
  120664. constructor(name: string, refractionTextureUrl: string,
  120665. /** the base color of the refraction (used to taint the rendering) */
  120666. color: Color3,
  120667. /** simulated refraction depth */
  120668. depth: number,
  120669. /** the coefficient of the base color (0 to remove base color tainting) */
  120670. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120671. /**
  120672. * Disposes of the post process
  120673. * @param camera Camera to dispose post process on
  120674. */
  120675. dispose(camera: Camera): void;
  120676. }
  120677. }
  120678. declare module BABYLON {
  120679. /** @hidden */
  120680. export var sharpenPixelShader: {
  120681. name: string;
  120682. shader: string;
  120683. };
  120684. }
  120685. declare module BABYLON {
  120686. /**
  120687. * The SharpenPostProcess applies a sharpen kernel to every pixel
  120688. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120689. */
  120690. export class SharpenPostProcess extends PostProcess {
  120691. /**
  120692. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  120693. */
  120694. colorAmount: number;
  120695. /**
  120696. * How much sharpness should be applied (default: 0.3)
  120697. */
  120698. edgeAmount: number;
  120699. /**
  120700. * Creates a new instance ConvolutionPostProcess
  120701. * @param name The name of the effect.
  120702. * @param options The required width/height ratio to downsize to before computing the render pass.
  120703. * @param camera The camera to apply the render pass to.
  120704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120705. * @param engine The engine which the post process will be applied. (default: current engine)
  120706. * @param reusable If the post process can be reused on the same frame. (default: false)
  120707. * @param textureType Type of textures used when performing the post process. (default: 0)
  120708. * @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)
  120709. */
  120710. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120711. }
  120712. }
  120713. declare module BABYLON {
  120714. /**
  120715. * PostProcessRenderPipeline
  120716. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120717. */
  120718. export class PostProcessRenderPipeline {
  120719. private engine;
  120720. private _renderEffects;
  120721. private _renderEffectsForIsolatedPass;
  120722. /**
  120723. * List of inspectable custom properties (used by the Inspector)
  120724. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  120725. */
  120726. inspectableCustomProperties: IInspectable[];
  120727. /**
  120728. * @hidden
  120729. */
  120730. protected _cameras: Camera[];
  120731. /** @hidden */
  120732. _name: string;
  120733. /**
  120734. * Gets pipeline name
  120735. */
  120736. readonly name: string;
  120737. /**
  120738. * Initializes a PostProcessRenderPipeline
  120739. * @param engine engine to add the pipeline to
  120740. * @param name name of the pipeline
  120741. */
  120742. constructor(engine: Engine, name: string);
  120743. /**
  120744. * Gets the class name
  120745. * @returns "PostProcessRenderPipeline"
  120746. */
  120747. getClassName(): string;
  120748. /**
  120749. * If all the render effects in the pipeline are supported
  120750. */
  120751. readonly isSupported: boolean;
  120752. /**
  120753. * Adds an effect to the pipeline
  120754. * @param renderEffect the effect to add
  120755. */
  120756. addEffect(renderEffect: PostProcessRenderEffect): void;
  120757. /** @hidden */
  120758. _rebuild(): void;
  120759. /** @hidden */
  120760. _enableEffect(renderEffectName: string, cameras: Camera): void;
  120761. /** @hidden */
  120762. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  120763. /** @hidden */
  120764. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  120765. /** @hidden */
  120766. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  120767. /** @hidden */
  120768. _attachCameras(cameras: Camera, unique: boolean): void;
  120769. /** @hidden */
  120770. _attachCameras(cameras: Camera[], unique: boolean): void;
  120771. /** @hidden */
  120772. _detachCameras(cameras: Camera): void;
  120773. /** @hidden */
  120774. _detachCameras(cameras: Nullable<Camera[]>): void;
  120775. /** @hidden */
  120776. _update(): void;
  120777. /** @hidden */
  120778. _reset(): void;
  120779. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  120780. /**
  120781. * Disposes of the pipeline
  120782. */
  120783. dispose(): void;
  120784. }
  120785. }
  120786. declare module BABYLON {
  120787. /**
  120788. * PostProcessRenderPipelineManager class
  120789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120790. */
  120791. export class PostProcessRenderPipelineManager {
  120792. private _renderPipelines;
  120793. /**
  120794. * Initializes a PostProcessRenderPipelineManager
  120795. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120796. */
  120797. constructor();
  120798. /**
  120799. * Gets the list of supported render pipelines
  120800. */
  120801. readonly supportedPipelines: PostProcessRenderPipeline[];
  120802. /**
  120803. * Adds a pipeline to the manager
  120804. * @param renderPipeline The pipeline to add
  120805. */
  120806. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  120807. /**
  120808. * Attaches a camera to the pipeline
  120809. * @param renderPipelineName The name of the pipeline to attach to
  120810. * @param cameras the camera to attach
  120811. * @param unique if the camera can be attached multiple times to the pipeline
  120812. */
  120813. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  120814. /**
  120815. * Detaches a camera from the pipeline
  120816. * @param renderPipelineName The name of the pipeline to detach from
  120817. * @param cameras the camera to detach
  120818. */
  120819. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  120820. /**
  120821. * Enables an effect by name on a pipeline
  120822. * @param renderPipelineName the name of the pipeline to enable the effect in
  120823. * @param renderEffectName the name of the effect to enable
  120824. * @param cameras the cameras that the effect should be enabled on
  120825. */
  120826. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  120827. /**
  120828. * Disables an effect by name on a pipeline
  120829. * @param renderPipelineName the name of the pipeline to disable the effect in
  120830. * @param renderEffectName the name of the effect to disable
  120831. * @param cameras the cameras that the effect should be disabled on
  120832. */
  120833. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  120834. /**
  120835. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  120836. */
  120837. update(): void;
  120838. /** @hidden */
  120839. _rebuild(): void;
  120840. /**
  120841. * Disposes of the manager and pipelines
  120842. */
  120843. dispose(): void;
  120844. }
  120845. }
  120846. declare module BABYLON {
  120847. interface Scene {
  120848. /** @hidden (Backing field) */
  120849. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  120850. /**
  120851. * Gets the postprocess render pipeline manager
  120852. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120853. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  120854. */
  120855. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  120856. }
  120857. /**
  120858. * Defines the Render Pipeline scene component responsible to rendering pipelines
  120859. */
  120860. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  120861. /**
  120862. * The component name helpfull to identify the component in the list of scene components.
  120863. */
  120864. readonly name: string;
  120865. /**
  120866. * The scene the component belongs to.
  120867. */
  120868. scene: Scene;
  120869. /**
  120870. * Creates a new instance of the component for the given scene
  120871. * @param scene Defines the scene to register the component in
  120872. */
  120873. constructor(scene: Scene);
  120874. /**
  120875. * Registers the component in a given scene
  120876. */
  120877. register(): void;
  120878. /**
  120879. * Rebuilds the elements related to this component in case of
  120880. * context lost for instance.
  120881. */
  120882. rebuild(): void;
  120883. /**
  120884. * Disposes the component and the associated ressources
  120885. */
  120886. dispose(): void;
  120887. private _gatherRenderTargets;
  120888. }
  120889. }
  120890. declare module BABYLON {
  120891. /**
  120892. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  120893. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  120894. */
  120895. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  120896. private _scene;
  120897. private _camerasToBeAttached;
  120898. /**
  120899. * ID of the sharpen post process,
  120900. */
  120901. private readonly SharpenPostProcessId;
  120902. /**
  120903. * @ignore
  120904. * ID of the image processing post process;
  120905. */
  120906. readonly ImageProcessingPostProcessId: string;
  120907. /**
  120908. * @ignore
  120909. * ID of the Fast Approximate Anti-Aliasing post process;
  120910. */
  120911. readonly FxaaPostProcessId: string;
  120912. /**
  120913. * ID of the chromatic aberration post process,
  120914. */
  120915. private readonly ChromaticAberrationPostProcessId;
  120916. /**
  120917. * ID of the grain post process
  120918. */
  120919. private readonly GrainPostProcessId;
  120920. /**
  120921. * Sharpen post process which will apply a sharpen convolution to enhance edges
  120922. */
  120923. sharpen: SharpenPostProcess;
  120924. private _sharpenEffect;
  120925. private bloom;
  120926. /**
  120927. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  120928. */
  120929. depthOfField: DepthOfFieldEffect;
  120930. /**
  120931. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  120932. */
  120933. fxaa: FxaaPostProcess;
  120934. /**
  120935. * Image post processing pass used to perform operations such as tone mapping or color grading.
  120936. */
  120937. imageProcessing: ImageProcessingPostProcess;
  120938. /**
  120939. * Chromatic aberration post process which will shift rgb colors in the image
  120940. */
  120941. chromaticAberration: ChromaticAberrationPostProcess;
  120942. private _chromaticAberrationEffect;
  120943. /**
  120944. * Grain post process which add noise to the image
  120945. */
  120946. grain: GrainPostProcess;
  120947. private _grainEffect;
  120948. /**
  120949. * Glow post process which adds a glow to emissive areas of the image
  120950. */
  120951. private _glowLayer;
  120952. /**
  120953. * Animations which can be used to tweak settings over a period of time
  120954. */
  120955. animations: Animation[];
  120956. private _imageProcessingConfigurationObserver;
  120957. private _sharpenEnabled;
  120958. private _bloomEnabled;
  120959. private _depthOfFieldEnabled;
  120960. private _depthOfFieldBlurLevel;
  120961. private _fxaaEnabled;
  120962. private _imageProcessingEnabled;
  120963. private _defaultPipelineTextureType;
  120964. private _bloomScale;
  120965. private _chromaticAberrationEnabled;
  120966. private _grainEnabled;
  120967. private _buildAllowed;
  120968. /**
  120969. * Gets active scene
  120970. */
  120971. readonly scene: Scene;
  120972. /**
  120973. * Enable or disable the sharpen process from the pipeline
  120974. */
  120975. sharpenEnabled: boolean;
  120976. private _resizeObserver;
  120977. private _hardwareScaleLevel;
  120978. private _bloomKernel;
  120979. /**
  120980. * Specifies the size of the bloom blur kernel, relative to the final output size
  120981. */
  120982. bloomKernel: number;
  120983. /**
  120984. * Specifies the weight of the bloom in the final rendering
  120985. */
  120986. private _bloomWeight;
  120987. /**
  120988. * Specifies the luma threshold for the area that will be blurred by the bloom
  120989. */
  120990. private _bloomThreshold;
  120991. private _hdr;
  120992. /**
  120993. * The strength of the bloom.
  120994. */
  120995. bloomWeight: number;
  120996. /**
  120997. * The strength of the bloom.
  120998. */
  120999. bloomThreshold: number;
  121000. /**
  121001. * The scale of the bloom, lower value will provide better performance.
  121002. */
  121003. bloomScale: number;
  121004. /**
  121005. * Enable or disable the bloom from the pipeline
  121006. */
  121007. bloomEnabled: boolean;
  121008. private _rebuildBloom;
  121009. /**
  121010. * If the depth of field is enabled.
  121011. */
  121012. depthOfFieldEnabled: boolean;
  121013. /**
  121014. * Blur level of the depth of field effect. (Higher blur will effect performance)
  121015. */
  121016. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  121017. /**
  121018. * If the anti aliasing is enabled.
  121019. */
  121020. fxaaEnabled: boolean;
  121021. private _samples;
  121022. /**
  121023. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121024. */
  121025. samples: number;
  121026. /**
  121027. * If image processing is enabled.
  121028. */
  121029. imageProcessingEnabled: boolean;
  121030. /**
  121031. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  121032. */
  121033. glowLayerEnabled: boolean;
  121034. /**
  121035. * Gets the glow layer (or null if not defined)
  121036. */
  121037. readonly glowLayer: Nullable<GlowLayer>;
  121038. /**
  121039. * Enable or disable the chromaticAberration process from the pipeline
  121040. */
  121041. chromaticAberrationEnabled: boolean;
  121042. /**
  121043. * Enable or disable the grain process from the pipeline
  121044. */
  121045. grainEnabled: boolean;
  121046. /**
  121047. * @constructor
  121048. * @param name - The rendering pipeline name (default: "")
  121049. * @param hdr - If high dynamic range textures should be used (default: true)
  121050. * @param scene - The scene linked to this pipeline (default: the last created scene)
  121051. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  121052. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  121053. */
  121054. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  121055. /**
  121056. * Get the class name
  121057. * @returns "DefaultRenderingPipeline"
  121058. */
  121059. getClassName(): string;
  121060. /**
  121061. * Force the compilation of the entire pipeline.
  121062. */
  121063. prepare(): void;
  121064. private _hasCleared;
  121065. private _prevPostProcess;
  121066. private _prevPrevPostProcess;
  121067. private _setAutoClearAndTextureSharing;
  121068. private _depthOfFieldSceneObserver;
  121069. private _buildPipeline;
  121070. private _disposePostProcesses;
  121071. /**
  121072. * Adds a camera to the pipeline
  121073. * @param camera the camera to be added
  121074. */
  121075. addCamera(camera: Camera): void;
  121076. /**
  121077. * Removes a camera from the pipeline
  121078. * @param camera the camera to remove
  121079. */
  121080. removeCamera(camera: Camera): void;
  121081. /**
  121082. * Dispose of the pipeline and stop all post processes
  121083. */
  121084. dispose(): void;
  121085. /**
  121086. * Serialize the rendering pipeline (Used when exporting)
  121087. * @returns the serialized object
  121088. */
  121089. serialize(): any;
  121090. /**
  121091. * Parse the serialized pipeline
  121092. * @param source Source pipeline.
  121093. * @param scene The scene to load the pipeline to.
  121094. * @param rootUrl The URL of the serialized pipeline.
  121095. * @returns An instantiated pipeline from the serialized object.
  121096. */
  121097. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  121098. }
  121099. }
  121100. declare module BABYLON {
  121101. /** @hidden */
  121102. export var lensHighlightsPixelShader: {
  121103. name: string;
  121104. shader: string;
  121105. };
  121106. }
  121107. declare module BABYLON {
  121108. /** @hidden */
  121109. export var depthOfFieldPixelShader: {
  121110. name: string;
  121111. shader: string;
  121112. };
  121113. }
  121114. declare module BABYLON {
  121115. /**
  121116. * BABYLON.JS Chromatic Aberration GLSL Shader
  121117. * Author: Olivier Guyot
  121118. * Separates very slightly R, G and B colors on the edges of the screen
  121119. * Inspired by Francois Tarlier & Martins Upitis
  121120. */
  121121. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  121122. /**
  121123. * @ignore
  121124. * The chromatic aberration PostProcess id in the pipeline
  121125. */
  121126. LensChromaticAberrationEffect: string;
  121127. /**
  121128. * @ignore
  121129. * The highlights enhancing PostProcess id in the pipeline
  121130. */
  121131. HighlightsEnhancingEffect: string;
  121132. /**
  121133. * @ignore
  121134. * The depth-of-field PostProcess id in the pipeline
  121135. */
  121136. LensDepthOfFieldEffect: string;
  121137. private _scene;
  121138. private _depthTexture;
  121139. private _grainTexture;
  121140. private _chromaticAberrationPostProcess;
  121141. private _highlightsPostProcess;
  121142. private _depthOfFieldPostProcess;
  121143. private _edgeBlur;
  121144. private _grainAmount;
  121145. private _chromaticAberration;
  121146. private _distortion;
  121147. private _highlightsGain;
  121148. private _highlightsThreshold;
  121149. private _dofDistance;
  121150. private _dofAperture;
  121151. private _dofDarken;
  121152. private _dofPentagon;
  121153. private _blurNoise;
  121154. /**
  121155. * @constructor
  121156. *
  121157. * Effect parameters are as follow:
  121158. * {
  121159. * chromatic_aberration: number; // from 0 to x (1 for realism)
  121160. * edge_blur: number; // from 0 to x (1 for realism)
  121161. * distortion: number; // from 0 to x (1 for realism)
  121162. * grain_amount: number; // from 0 to 1
  121163. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  121164. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  121165. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  121166. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  121167. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  121168. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  121169. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  121170. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  121171. * }
  121172. * Note: if an effect parameter is unset, effect is disabled
  121173. *
  121174. * @param name The rendering pipeline name
  121175. * @param parameters - An object containing all parameters (see above)
  121176. * @param scene The scene linked to this pipeline
  121177. * @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)
  121178. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121179. */
  121180. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  121181. /**
  121182. * Get the class name
  121183. * @returns "LensRenderingPipeline"
  121184. */
  121185. getClassName(): string;
  121186. /**
  121187. * Gets associated scene
  121188. */
  121189. readonly scene: Scene;
  121190. /**
  121191. * Gets or sets the edge blur
  121192. */
  121193. edgeBlur: number;
  121194. /**
  121195. * Gets or sets the grain amount
  121196. */
  121197. grainAmount: number;
  121198. /**
  121199. * Gets or sets the chromatic aberration amount
  121200. */
  121201. chromaticAberration: number;
  121202. /**
  121203. * Gets or sets the depth of field aperture
  121204. */
  121205. dofAperture: number;
  121206. /**
  121207. * Gets or sets the edge distortion
  121208. */
  121209. edgeDistortion: number;
  121210. /**
  121211. * Gets or sets the depth of field distortion
  121212. */
  121213. dofDistortion: number;
  121214. /**
  121215. * Gets or sets the darken out of focus amount
  121216. */
  121217. darkenOutOfFocus: number;
  121218. /**
  121219. * Gets or sets a boolean indicating if blur noise is enabled
  121220. */
  121221. blurNoise: boolean;
  121222. /**
  121223. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  121224. */
  121225. pentagonBokeh: boolean;
  121226. /**
  121227. * Gets or sets the highlight grain amount
  121228. */
  121229. highlightsGain: number;
  121230. /**
  121231. * Gets or sets the highlight threshold
  121232. */
  121233. highlightsThreshold: number;
  121234. /**
  121235. * Sets the amount of blur at the edges
  121236. * @param amount blur amount
  121237. */
  121238. setEdgeBlur(amount: number): void;
  121239. /**
  121240. * Sets edge blur to 0
  121241. */
  121242. disableEdgeBlur(): void;
  121243. /**
  121244. * Sets the amout of grain
  121245. * @param amount Amount of grain
  121246. */
  121247. setGrainAmount(amount: number): void;
  121248. /**
  121249. * Set grain amount to 0
  121250. */
  121251. disableGrain(): void;
  121252. /**
  121253. * Sets the chromatic aberration amount
  121254. * @param amount amount of chromatic aberration
  121255. */
  121256. setChromaticAberration(amount: number): void;
  121257. /**
  121258. * Sets chromatic aberration amount to 0
  121259. */
  121260. disableChromaticAberration(): void;
  121261. /**
  121262. * Sets the EdgeDistortion amount
  121263. * @param amount amount of EdgeDistortion
  121264. */
  121265. setEdgeDistortion(amount: number): void;
  121266. /**
  121267. * Sets edge distortion to 0
  121268. */
  121269. disableEdgeDistortion(): void;
  121270. /**
  121271. * Sets the FocusDistance amount
  121272. * @param amount amount of FocusDistance
  121273. */
  121274. setFocusDistance(amount: number): void;
  121275. /**
  121276. * Disables depth of field
  121277. */
  121278. disableDepthOfField(): void;
  121279. /**
  121280. * Sets the Aperture amount
  121281. * @param amount amount of Aperture
  121282. */
  121283. setAperture(amount: number): void;
  121284. /**
  121285. * Sets the DarkenOutOfFocus amount
  121286. * @param amount amount of DarkenOutOfFocus
  121287. */
  121288. setDarkenOutOfFocus(amount: number): void;
  121289. private _pentagonBokehIsEnabled;
  121290. /**
  121291. * Creates a pentagon bokeh effect
  121292. */
  121293. enablePentagonBokeh(): void;
  121294. /**
  121295. * Disables the pentagon bokeh effect
  121296. */
  121297. disablePentagonBokeh(): void;
  121298. /**
  121299. * Enables noise blur
  121300. */
  121301. enableNoiseBlur(): void;
  121302. /**
  121303. * Disables noise blur
  121304. */
  121305. disableNoiseBlur(): void;
  121306. /**
  121307. * Sets the HighlightsGain amount
  121308. * @param amount amount of HighlightsGain
  121309. */
  121310. setHighlightsGain(amount: number): void;
  121311. /**
  121312. * Sets the HighlightsThreshold amount
  121313. * @param amount amount of HighlightsThreshold
  121314. */
  121315. setHighlightsThreshold(amount: number): void;
  121316. /**
  121317. * Disables highlights
  121318. */
  121319. disableHighlights(): void;
  121320. /**
  121321. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  121322. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  121323. */
  121324. dispose(disableDepthRender?: boolean): void;
  121325. private _createChromaticAberrationPostProcess;
  121326. private _createHighlightsPostProcess;
  121327. private _createDepthOfFieldPostProcess;
  121328. private _createGrainTexture;
  121329. }
  121330. }
  121331. declare module BABYLON {
  121332. /** @hidden */
  121333. export var ssao2PixelShader: {
  121334. name: string;
  121335. shader: string;
  121336. };
  121337. }
  121338. declare module BABYLON {
  121339. /** @hidden */
  121340. export var ssaoCombinePixelShader: {
  121341. name: string;
  121342. shader: string;
  121343. };
  121344. }
  121345. declare module BABYLON {
  121346. /**
  121347. * Render pipeline to produce ssao effect
  121348. */
  121349. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  121350. /**
  121351. * @ignore
  121352. * The PassPostProcess id in the pipeline that contains the original scene color
  121353. */
  121354. SSAOOriginalSceneColorEffect: string;
  121355. /**
  121356. * @ignore
  121357. * The SSAO PostProcess id in the pipeline
  121358. */
  121359. SSAORenderEffect: string;
  121360. /**
  121361. * @ignore
  121362. * The horizontal blur PostProcess id in the pipeline
  121363. */
  121364. SSAOBlurHRenderEffect: string;
  121365. /**
  121366. * @ignore
  121367. * The vertical blur PostProcess id in the pipeline
  121368. */
  121369. SSAOBlurVRenderEffect: string;
  121370. /**
  121371. * @ignore
  121372. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121373. */
  121374. SSAOCombineRenderEffect: string;
  121375. /**
  121376. * The output strength of the SSAO post-process. Default value is 1.0.
  121377. */
  121378. totalStrength: number;
  121379. /**
  121380. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  121381. */
  121382. maxZ: number;
  121383. /**
  121384. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  121385. */
  121386. minZAspect: number;
  121387. private _samples;
  121388. /**
  121389. * Number of samples used for the SSAO calculations. Default value is 8
  121390. */
  121391. samples: number;
  121392. private _textureSamples;
  121393. /**
  121394. * Number of samples to use for antialiasing
  121395. */
  121396. textureSamples: number;
  121397. /**
  121398. * Ratio object used for SSAO ratio and blur ratio
  121399. */
  121400. private _ratio;
  121401. /**
  121402. * Dynamically generated sphere sampler.
  121403. */
  121404. private _sampleSphere;
  121405. /**
  121406. * Blur filter offsets
  121407. */
  121408. private _samplerOffsets;
  121409. private _expensiveBlur;
  121410. /**
  121411. * If bilateral blur should be used
  121412. */
  121413. expensiveBlur: boolean;
  121414. /**
  121415. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  121416. */
  121417. radius: number;
  121418. /**
  121419. * The base color of the SSAO post-process
  121420. * The final result is "base + ssao" between [0, 1]
  121421. */
  121422. base: number;
  121423. /**
  121424. * Support test.
  121425. */
  121426. static readonly IsSupported: boolean;
  121427. private _scene;
  121428. private _depthTexture;
  121429. private _normalTexture;
  121430. private _randomTexture;
  121431. private _originalColorPostProcess;
  121432. private _ssaoPostProcess;
  121433. private _blurHPostProcess;
  121434. private _blurVPostProcess;
  121435. private _ssaoCombinePostProcess;
  121436. private _firstUpdate;
  121437. /**
  121438. * Gets active scene
  121439. */
  121440. readonly scene: Scene;
  121441. /**
  121442. * @constructor
  121443. * @param name The rendering pipeline name
  121444. * @param scene The scene linked to this pipeline
  121445. * @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 }
  121446. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121447. */
  121448. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  121449. /**
  121450. * Get the class name
  121451. * @returns "SSAO2RenderingPipeline"
  121452. */
  121453. getClassName(): string;
  121454. /**
  121455. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  121456. */
  121457. dispose(disableGeometryBufferRenderer?: boolean): void;
  121458. private _createBlurPostProcess;
  121459. /** @hidden */
  121460. _rebuild(): void;
  121461. private _bits;
  121462. private _radicalInverse_VdC;
  121463. private _hammersley;
  121464. private _hemisphereSample_uniform;
  121465. private _generateHemisphere;
  121466. private _createSSAOPostProcess;
  121467. private _createSSAOCombinePostProcess;
  121468. private _createRandomTexture;
  121469. /**
  121470. * Serialize the rendering pipeline (Used when exporting)
  121471. * @returns the serialized object
  121472. */
  121473. serialize(): any;
  121474. /**
  121475. * Parse the serialized pipeline
  121476. * @param source Source pipeline.
  121477. * @param scene The scene to load the pipeline to.
  121478. * @param rootUrl The URL of the serialized pipeline.
  121479. * @returns An instantiated pipeline from the serialized object.
  121480. */
  121481. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  121482. }
  121483. }
  121484. declare module BABYLON {
  121485. /** @hidden */
  121486. export var ssaoPixelShader: {
  121487. name: string;
  121488. shader: string;
  121489. };
  121490. }
  121491. declare module BABYLON {
  121492. /**
  121493. * Render pipeline to produce ssao effect
  121494. */
  121495. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  121496. /**
  121497. * @ignore
  121498. * The PassPostProcess id in the pipeline that contains the original scene color
  121499. */
  121500. SSAOOriginalSceneColorEffect: string;
  121501. /**
  121502. * @ignore
  121503. * The SSAO PostProcess id in the pipeline
  121504. */
  121505. SSAORenderEffect: string;
  121506. /**
  121507. * @ignore
  121508. * The horizontal blur PostProcess id in the pipeline
  121509. */
  121510. SSAOBlurHRenderEffect: string;
  121511. /**
  121512. * @ignore
  121513. * The vertical blur PostProcess id in the pipeline
  121514. */
  121515. SSAOBlurVRenderEffect: string;
  121516. /**
  121517. * @ignore
  121518. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121519. */
  121520. SSAOCombineRenderEffect: string;
  121521. /**
  121522. * The output strength of the SSAO post-process. Default value is 1.0.
  121523. */
  121524. totalStrength: number;
  121525. /**
  121526. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  121527. */
  121528. radius: number;
  121529. /**
  121530. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  121531. * Must not be equal to fallOff and superior to fallOff.
  121532. * Default value is 0.0075
  121533. */
  121534. area: number;
  121535. /**
  121536. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  121537. * Must not be equal to area and inferior to area.
  121538. * Default value is 0.000001
  121539. */
  121540. fallOff: number;
  121541. /**
  121542. * The base color of the SSAO post-process
  121543. * The final result is "base + ssao" between [0, 1]
  121544. */
  121545. base: number;
  121546. private _scene;
  121547. private _depthTexture;
  121548. private _randomTexture;
  121549. private _originalColorPostProcess;
  121550. private _ssaoPostProcess;
  121551. private _blurHPostProcess;
  121552. private _blurVPostProcess;
  121553. private _ssaoCombinePostProcess;
  121554. private _firstUpdate;
  121555. /**
  121556. * Gets active scene
  121557. */
  121558. readonly scene: Scene;
  121559. /**
  121560. * @constructor
  121561. * @param name - The rendering pipeline name
  121562. * @param scene - The scene linked to this pipeline
  121563. * @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 }
  121564. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  121565. */
  121566. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  121567. /**
  121568. * Get the class name
  121569. * @returns "SSAORenderingPipeline"
  121570. */
  121571. getClassName(): string;
  121572. /**
  121573. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  121574. */
  121575. dispose(disableDepthRender?: boolean): void;
  121576. private _createBlurPostProcess;
  121577. /** @hidden */
  121578. _rebuild(): void;
  121579. private _createSSAOPostProcess;
  121580. private _createSSAOCombinePostProcess;
  121581. private _createRandomTexture;
  121582. }
  121583. }
  121584. declare module BABYLON {
  121585. /** @hidden */
  121586. export var standardPixelShader: {
  121587. name: string;
  121588. shader: string;
  121589. };
  121590. }
  121591. declare module BABYLON {
  121592. /**
  121593. * Standard rendering pipeline
  121594. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  121595. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  121596. */
  121597. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121598. /**
  121599. * Public members
  121600. */
  121601. /**
  121602. * Post-process which contains the original scene color before the pipeline applies all the effects
  121603. */
  121604. originalPostProcess: Nullable<PostProcess>;
  121605. /**
  121606. * Post-process used to down scale an image x4
  121607. */
  121608. downSampleX4PostProcess: Nullable<PostProcess>;
  121609. /**
  121610. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  121611. */
  121612. brightPassPostProcess: Nullable<PostProcess>;
  121613. /**
  121614. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  121615. */
  121616. blurHPostProcesses: PostProcess[];
  121617. /**
  121618. * Post-process array storing all the vertical blur post-processes used by the pipeline
  121619. */
  121620. blurVPostProcesses: PostProcess[];
  121621. /**
  121622. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  121623. */
  121624. textureAdderPostProcess: Nullable<PostProcess>;
  121625. /**
  121626. * Post-process used to create volumetric lighting effect
  121627. */
  121628. volumetricLightPostProcess: Nullable<PostProcess>;
  121629. /**
  121630. * Post-process used to smooth the previous volumetric light post-process on the X axis
  121631. */
  121632. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  121633. /**
  121634. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  121635. */
  121636. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  121637. /**
  121638. * Post-process used to merge the volumetric light effect and the real scene color
  121639. */
  121640. volumetricLightMergePostProces: Nullable<PostProcess>;
  121641. /**
  121642. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  121643. */
  121644. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  121645. /**
  121646. * Base post-process used to calculate the average luminance of the final image for HDR
  121647. */
  121648. luminancePostProcess: Nullable<PostProcess>;
  121649. /**
  121650. * Post-processes used to create down sample post-processes in order to get
  121651. * the average luminance of the final image for HDR
  121652. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  121653. */
  121654. luminanceDownSamplePostProcesses: PostProcess[];
  121655. /**
  121656. * Post-process used to create a HDR effect (light adaptation)
  121657. */
  121658. hdrPostProcess: Nullable<PostProcess>;
  121659. /**
  121660. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  121661. */
  121662. textureAdderFinalPostProcess: Nullable<PostProcess>;
  121663. /**
  121664. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  121665. */
  121666. lensFlareFinalPostProcess: Nullable<PostProcess>;
  121667. /**
  121668. * Post-process used to merge the final HDR post-process and the real scene color
  121669. */
  121670. hdrFinalPostProcess: Nullable<PostProcess>;
  121671. /**
  121672. * Post-process used to create a lens flare effect
  121673. */
  121674. lensFlarePostProcess: Nullable<PostProcess>;
  121675. /**
  121676. * Post-process that merges the result of the lens flare post-process and the real scene color
  121677. */
  121678. lensFlareComposePostProcess: Nullable<PostProcess>;
  121679. /**
  121680. * Post-process used to create a motion blur effect
  121681. */
  121682. motionBlurPostProcess: Nullable<PostProcess>;
  121683. /**
  121684. * Post-process used to create a depth of field effect
  121685. */
  121686. depthOfFieldPostProcess: Nullable<PostProcess>;
  121687. /**
  121688. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121689. */
  121690. fxaaPostProcess: Nullable<FxaaPostProcess>;
  121691. /**
  121692. * Represents the brightness threshold in order to configure the illuminated surfaces
  121693. */
  121694. brightThreshold: number;
  121695. /**
  121696. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  121697. */
  121698. blurWidth: number;
  121699. /**
  121700. * Sets if the blur for highlighted surfaces must be only horizontal
  121701. */
  121702. horizontalBlur: boolean;
  121703. /**
  121704. * Gets the overall exposure used by the pipeline
  121705. */
  121706. /**
  121707. * Sets the overall exposure used by the pipeline
  121708. */
  121709. exposure: number;
  121710. /**
  121711. * Texture used typically to simulate "dirty" on camera lens
  121712. */
  121713. lensTexture: Nullable<Texture>;
  121714. /**
  121715. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  121716. */
  121717. volumetricLightCoefficient: number;
  121718. /**
  121719. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  121720. */
  121721. volumetricLightPower: number;
  121722. /**
  121723. * Used the set the blur intensity to smooth the volumetric lights
  121724. */
  121725. volumetricLightBlurScale: number;
  121726. /**
  121727. * Light (spot or directional) used to generate the volumetric lights rays
  121728. * The source light must have a shadow generate so the pipeline can get its
  121729. * depth map
  121730. */
  121731. sourceLight: Nullable<SpotLight | DirectionalLight>;
  121732. /**
  121733. * For eye adaptation, represents the minimum luminance the eye can see
  121734. */
  121735. hdrMinimumLuminance: number;
  121736. /**
  121737. * For eye adaptation, represents the decrease luminance speed
  121738. */
  121739. hdrDecreaseRate: number;
  121740. /**
  121741. * For eye adaptation, represents the increase luminance speed
  121742. */
  121743. hdrIncreaseRate: number;
  121744. /**
  121745. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  121746. */
  121747. /**
  121748. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  121749. */
  121750. hdrAutoExposure: boolean;
  121751. /**
  121752. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  121753. */
  121754. lensColorTexture: Nullable<Texture>;
  121755. /**
  121756. * The overall strengh for the lens flare effect
  121757. */
  121758. lensFlareStrength: number;
  121759. /**
  121760. * Dispersion coefficient for lens flare ghosts
  121761. */
  121762. lensFlareGhostDispersal: number;
  121763. /**
  121764. * Main lens flare halo width
  121765. */
  121766. lensFlareHaloWidth: number;
  121767. /**
  121768. * Based on the lens distortion effect, defines how much the lens flare result
  121769. * is distorted
  121770. */
  121771. lensFlareDistortionStrength: number;
  121772. /**
  121773. * Lens star texture must be used to simulate rays on the flares and is available
  121774. * in the documentation
  121775. */
  121776. lensStarTexture: Nullable<Texture>;
  121777. /**
  121778. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  121779. * flare effect by taking account of the dirt texture
  121780. */
  121781. lensFlareDirtTexture: Nullable<Texture>;
  121782. /**
  121783. * Represents the focal length for the depth of field effect
  121784. */
  121785. depthOfFieldDistance: number;
  121786. /**
  121787. * Represents the blur intensity for the blurred part of the depth of field effect
  121788. */
  121789. depthOfFieldBlurWidth: number;
  121790. /**
  121791. * Gets how much the image is blurred by the movement while using the motion blur post-process
  121792. */
  121793. /**
  121794. * Sets how much the image is blurred by the movement while using the motion blur post-process
  121795. */
  121796. motionStrength: number;
  121797. /**
  121798. * Gets wether or not the motion blur post-process is object based or screen based.
  121799. */
  121800. /**
  121801. * Sets wether or not the motion blur post-process should be object based or screen based
  121802. */
  121803. objectBasedMotionBlur: boolean;
  121804. /**
  121805. * List of animations for the pipeline (IAnimatable implementation)
  121806. */
  121807. animations: Animation[];
  121808. /**
  121809. * Private members
  121810. */
  121811. private _scene;
  121812. private _currentDepthOfFieldSource;
  121813. private _basePostProcess;
  121814. private _fixedExposure;
  121815. private _currentExposure;
  121816. private _hdrAutoExposure;
  121817. private _hdrCurrentLuminance;
  121818. private _motionStrength;
  121819. private _isObjectBasedMotionBlur;
  121820. private _floatTextureType;
  121821. private _ratio;
  121822. private _bloomEnabled;
  121823. private _depthOfFieldEnabled;
  121824. private _vlsEnabled;
  121825. private _lensFlareEnabled;
  121826. private _hdrEnabled;
  121827. private _motionBlurEnabled;
  121828. private _fxaaEnabled;
  121829. private _motionBlurSamples;
  121830. private _volumetricLightStepsCount;
  121831. private _samples;
  121832. /**
  121833. * @ignore
  121834. * Specifies if the bloom pipeline is enabled
  121835. */
  121836. BloomEnabled: boolean;
  121837. /**
  121838. * @ignore
  121839. * Specifies if the depth of field pipeline is enabed
  121840. */
  121841. DepthOfFieldEnabled: boolean;
  121842. /**
  121843. * @ignore
  121844. * Specifies if the lens flare pipeline is enabed
  121845. */
  121846. LensFlareEnabled: boolean;
  121847. /**
  121848. * @ignore
  121849. * Specifies if the HDR pipeline is enabled
  121850. */
  121851. HDREnabled: boolean;
  121852. /**
  121853. * @ignore
  121854. * Specifies if the volumetric lights scattering effect is enabled
  121855. */
  121856. VLSEnabled: boolean;
  121857. /**
  121858. * @ignore
  121859. * Specifies if the motion blur effect is enabled
  121860. */
  121861. MotionBlurEnabled: boolean;
  121862. /**
  121863. * Specifies if anti-aliasing is enabled
  121864. */
  121865. fxaaEnabled: boolean;
  121866. /**
  121867. * Specifies the number of steps used to calculate the volumetric lights
  121868. * Typically in interval [50, 200]
  121869. */
  121870. volumetricLightStepsCount: number;
  121871. /**
  121872. * Specifies the number of samples used for the motion blur effect
  121873. * Typically in interval [16, 64]
  121874. */
  121875. motionBlurSamples: number;
  121876. /**
  121877. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121878. */
  121879. samples: number;
  121880. /**
  121881. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  121882. * @constructor
  121883. * @param name The rendering pipeline name
  121884. * @param scene The scene linked to this pipeline
  121885. * @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)
  121886. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  121887. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121888. */
  121889. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  121890. private _buildPipeline;
  121891. private _createDownSampleX4PostProcess;
  121892. private _createBrightPassPostProcess;
  121893. private _createBlurPostProcesses;
  121894. private _createTextureAdderPostProcess;
  121895. private _createVolumetricLightPostProcess;
  121896. private _createLuminancePostProcesses;
  121897. private _createHdrPostProcess;
  121898. private _createLensFlarePostProcess;
  121899. private _createDepthOfFieldPostProcess;
  121900. private _createMotionBlurPostProcess;
  121901. private _getDepthTexture;
  121902. private _disposePostProcesses;
  121903. /**
  121904. * Dispose of the pipeline and stop all post processes
  121905. */
  121906. dispose(): void;
  121907. /**
  121908. * Serialize the rendering pipeline (Used when exporting)
  121909. * @returns the serialized object
  121910. */
  121911. serialize(): any;
  121912. /**
  121913. * Parse the serialized pipeline
  121914. * @param source Source pipeline.
  121915. * @param scene The scene to load the pipeline to.
  121916. * @param rootUrl The URL of the serialized pipeline.
  121917. * @returns An instantiated pipeline from the serialized object.
  121918. */
  121919. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  121920. /**
  121921. * Luminance steps
  121922. */
  121923. static LuminanceSteps: number;
  121924. }
  121925. }
  121926. declare module BABYLON {
  121927. /** @hidden */
  121928. export var tonemapPixelShader: {
  121929. name: string;
  121930. shader: string;
  121931. };
  121932. }
  121933. declare module BABYLON {
  121934. /** Defines operator used for tonemapping */
  121935. export enum TonemappingOperator {
  121936. /** Hable */
  121937. Hable = 0,
  121938. /** Reinhard */
  121939. Reinhard = 1,
  121940. /** HejiDawson */
  121941. HejiDawson = 2,
  121942. /** Photographic */
  121943. Photographic = 3
  121944. }
  121945. /**
  121946. * Defines a post process to apply tone mapping
  121947. */
  121948. export class TonemapPostProcess extends PostProcess {
  121949. private _operator;
  121950. /** Defines the required exposure adjustement */
  121951. exposureAdjustment: number;
  121952. /**
  121953. * Creates a new TonemapPostProcess
  121954. * @param name defines the name of the postprocess
  121955. * @param _operator defines the operator to use
  121956. * @param exposureAdjustment defines the required exposure adjustement
  121957. * @param camera defines the camera to use (can be null)
  121958. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  121959. * @param engine defines the hosting engine (can be ignore if camera is set)
  121960. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121961. */
  121962. constructor(name: string, _operator: TonemappingOperator,
  121963. /** Defines the required exposure adjustement */
  121964. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  121965. }
  121966. }
  121967. declare module BABYLON {
  121968. /** @hidden */
  121969. export var depthVertexShader: {
  121970. name: string;
  121971. shader: string;
  121972. };
  121973. }
  121974. declare module BABYLON {
  121975. /** @hidden */
  121976. export var volumetricLightScatteringPixelShader: {
  121977. name: string;
  121978. shader: string;
  121979. };
  121980. }
  121981. declare module BABYLON {
  121982. /** @hidden */
  121983. export var volumetricLightScatteringPassPixelShader: {
  121984. name: string;
  121985. shader: string;
  121986. };
  121987. }
  121988. declare module BABYLON {
  121989. /**
  121990. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  121991. */
  121992. export class VolumetricLightScatteringPostProcess extends PostProcess {
  121993. private _volumetricLightScatteringPass;
  121994. private _volumetricLightScatteringRTT;
  121995. private _viewPort;
  121996. private _screenCoordinates;
  121997. private _cachedDefines;
  121998. /**
  121999. * If not undefined, the mesh position is computed from the attached node position
  122000. */
  122001. attachedNode: {
  122002. position: Vector3;
  122003. };
  122004. /**
  122005. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  122006. */
  122007. customMeshPosition: Vector3;
  122008. /**
  122009. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  122010. */
  122011. useCustomMeshPosition: boolean;
  122012. /**
  122013. * If the post-process should inverse the light scattering direction
  122014. */
  122015. invert: boolean;
  122016. /**
  122017. * The internal mesh used by the post-process
  122018. */
  122019. mesh: Mesh;
  122020. /**
  122021. * @hidden
  122022. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  122023. */
  122024. useDiffuseColor: boolean;
  122025. /**
  122026. * Array containing the excluded meshes not rendered in the internal pass
  122027. */
  122028. excludedMeshes: AbstractMesh[];
  122029. /**
  122030. * Controls the overall intensity of the post-process
  122031. */
  122032. exposure: number;
  122033. /**
  122034. * Dissipates each sample's contribution in range [0, 1]
  122035. */
  122036. decay: number;
  122037. /**
  122038. * Controls the overall intensity of each sample
  122039. */
  122040. weight: number;
  122041. /**
  122042. * Controls the density of each sample
  122043. */
  122044. density: number;
  122045. /**
  122046. * @constructor
  122047. * @param name The post-process name
  122048. * @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)
  122049. * @param camera The camera that the post-process will be attached to
  122050. * @param mesh The mesh used to create the light scattering
  122051. * @param samples The post-process quality, default 100
  122052. * @param samplingModeThe post-process filtering mode
  122053. * @param engine The babylon engine
  122054. * @param reusable If the post-process is reusable
  122055. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  122056. */
  122057. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  122058. /**
  122059. * Returns the string "VolumetricLightScatteringPostProcess"
  122060. * @returns "VolumetricLightScatteringPostProcess"
  122061. */
  122062. getClassName(): string;
  122063. private _isReady;
  122064. /**
  122065. * Sets the new light position for light scattering effect
  122066. * @param position The new custom light position
  122067. */
  122068. setCustomMeshPosition(position: Vector3): void;
  122069. /**
  122070. * Returns the light position for light scattering effect
  122071. * @return Vector3 The custom light position
  122072. */
  122073. getCustomMeshPosition(): Vector3;
  122074. /**
  122075. * Disposes the internal assets and detaches the post-process from the camera
  122076. */
  122077. dispose(camera: Camera): void;
  122078. /**
  122079. * Returns the render target texture used by the post-process
  122080. * @return the render target texture used by the post-process
  122081. */
  122082. getPass(): RenderTargetTexture;
  122083. private _meshExcluded;
  122084. private _createPass;
  122085. private _updateMeshScreenCoordinates;
  122086. /**
  122087. * Creates a default mesh for the Volumeric Light Scattering post-process
  122088. * @param name The mesh name
  122089. * @param scene The scene where to create the mesh
  122090. * @return the default mesh
  122091. */
  122092. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  122093. }
  122094. }
  122095. declare module BABYLON {
  122096. interface Scene {
  122097. /** @hidden (Backing field) */
  122098. _boundingBoxRenderer: BoundingBoxRenderer;
  122099. /** @hidden (Backing field) */
  122100. _forceShowBoundingBoxes: boolean;
  122101. /**
  122102. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  122103. */
  122104. forceShowBoundingBoxes: boolean;
  122105. /**
  122106. * Gets the bounding box renderer associated with the scene
  122107. * @returns a BoundingBoxRenderer
  122108. */
  122109. getBoundingBoxRenderer(): BoundingBoxRenderer;
  122110. }
  122111. interface AbstractMesh {
  122112. /** @hidden (Backing field) */
  122113. _showBoundingBox: boolean;
  122114. /**
  122115. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  122116. */
  122117. showBoundingBox: boolean;
  122118. }
  122119. /**
  122120. * Component responsible of rendering the bounding box of the meshes in a scene.
  122121. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  122122. */
  122123. export class BoundingBoxRenderer implements ISceneComponent {
  122124. /**
  122125. * The component name helpfull to identify the component in the list of scene components.
  122126. */
  122127. readonly name: string;
  122128. /**
  122129. * The scene the component belongs to.
  122130. */
  122131. scene: Scene;
  122132. /**
  122133. * Color of the bounding box lines placed in front of an object
  122134. */
  122135. frontColor: Color3;
  122136. /**
  122137. * Color of the bounding box lines placed behind an object
  122138. */
  122139. backColor: Color3;
  122140. /**
  122141. * Defines if the renderer should show the back lines or not
  122142. */
  122143. showBackLines: boolean;
  122144. /**
  122145. * @hidden
  122146. */
  122147. renderList: SmartArray<BoundingBox>;
  122148. private _colorShader;
  122149. private _vertexBuffers;
  122150. private _indexBuffer;
  122151. private _fillIndexBuffer;
  122152. private _fillIndexData;
  122153. /**
  122154. * Instantiates a new bounding box renderer in a scene.
  122155. * @param scene the scene the renderer renders in
  122156. */
  122157. constructor(scene: Scene);
  122158. /**
  122159. * Registers the component in a given scene
  122160. */
  122161. register(): void;
  122162. private _evaluateSubMesh;
  122163. private _activeMesh;
  122164. private _prepareRessources;
  122165. private _createIndexBuffer;
  122166. /**
  122167. * Rebuilds the elements related to this component in case of
  122168. * context lost for instance.
  122169. */
  122170. rebuild(): void;
  122171. /**
  122172. * @hidden
  122173. */
  122174. reset(): void;
  122175. /**
  122176. * Render the bounding boxes of a specific rendering group
  122177. * @param renderingGroupId defines the rendering group to render
  122178. */
  122179. render(renderingGroupId: number): void;
  122180. /**
  122181. * In case of occlusion queries, we can render the occlusion bounding box through this method
  122182. * @param mesh Define the mesh to render the occlusion bounding box for
  122183. */
  122184. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  122185. /**
  122186. * Dispose and release the resources attached to this renderer.
  122187. */
  122188. dispose(): void;
  122189. }
  122190. }
  122191. declare module BABYLON {
  122192. /** @hidden */
  122193. export var depthPixelShader: {
  122194. name: string;
  122195. shader: string;
  122196. };
  122197. }
  122198. declare module BABYLON {
  122199. /**
  122200. * This represents a depth renderer in Babylon.
  122201. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  122202. */
  122203. export class DepthRenderer {
  122204. private _scene;
  122205. private _depthMap;
  122206. private _effect;
  122207. private readonly _storeNonLinearDepth;
  122208. private readonly _clearColor;
  122209. /** Get if the depth renderer is using packed depth or not */
  122210. readonly isPacked: boolean;
  122211. private _cachedDefines;
  122212. private _camera;
  122213. /**
  122214. * Specifiess that the depth renderer will only be used within
  122215. * the camera it is created for.
  122216. * This can help forcing its rendering during the camera processing.
  122217. */
  122218. useOnlyInActiveCamera: boolean;
  122219. /** @hidden */
  122220. static _SceneComponentInitialization: (scene: Scene) => void;
  122221. /**
  122222. * Instantiates a depth renderer
  122223. * @param scene The scene the renderer belongs to
  122224. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  122225. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  122226. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122227. */
  122228. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  122229. /**
  122230. * Creates the depth rendering effect and checks if the effect is ready.
  122231. * @param subMesh The submesh to be used to render the depth map of
  122232. * @param useInstances If multiple world instances should be used
  122233. * @returns if the depth renderer is ready to render the depth map
  122234. */
  122235. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122236. /**
  122237. * Gets the texture which the depth map will be written to.
  122238. * @returns The depth map texture
  122239. */
  122240. getDepthMap(): RenderTargetTexture;
  122241. /**
  122242. * Disposes of the depth renderer.
  122243. */
  122244. dispose(): void;
  122245. }
  122246. }
  122247. declare module BABYLON {
  122248. interface Scene {
  122249. /** @hidden (Backing field) */
  122250. _depthRenderer: {
  122251. [id: string]: DepthRenderer;
  122252. };
  122253. /**
  122254. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  122255. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  122256. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122257. * @returns the created depth renderer
  122258. */
  122259. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  122260. /**
  122261. * Disables a depth renderer for a given camera
  122262. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  122263. */
  122264. disableDepthRenderer(camera?: Nullable<Camera>): void;
  122265. }
  122266. /**
  122267. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  122268. * in several rendering techniques.
  122269. */
  122270. export class DepthRendererSceneComponent implements ISceneComponent {
  122271. /**
  122272. * The component name helpfull to identify the component in the list of scene components.
  122273. */
  122274. readonly name: string;
  122275. /**
  122276. * The scene the component belongs to.
  122277. */
  122278. scene: Scene;
  122279. /**
  122280. * Creates a new instance of the component for the given scene
  122281. * @param scene Defines the scene to register the component in
  122282. */
  122283. constructor(scene: Scene);
  122284. /**
  122285. * Registers the component in a given scene
  122286. */
  122287. register(): void;
  122288. /**
  122289. * Rebuilds the elements related to this component in case of
  122290. * context lost for instance.
  122291. */
  122292. rebuild(): void;
  122293. /**
  122294. * Disposes the component and the associated ressources
  122295. */
  122296. dispose(): void;
  122297. private _gatherRenderTargets;
  122298. private _gatherActiveCameraRenderTargets;
  122299. }
  122300. }
  122301. declare module BABYLON {
  122302. /** @hidden */
  122303. export var outlinePixelShader: {
  122304. name: string;
  122305. shader: string;
  122306. };
  122307. }
  122308. declare module BABYLON {
  122309. /** @hidden */
  122310. export var outlineVertexShader: {
  122311. name: string;
  122312. shader: string;
  122313. };
  122314. }
  122315. declare module BABYLON {
  122316. interface Scene {
  122317. /** @hidden */
  122318. _outlineRenderer: OutlineRenderer;
  122319. /**
  122320. * Gets the outline renderer associated with the scene
  122321. * @returns a OutlineRenderer
  122322. */
  122323. getOutlineRenderer(): OutlineRenderer;
  122324. }
  122325. interface AbstractMesh {
  122326. /** @hidden (Backing field) */
  122327. _renderOutline: boolean;
  122328. /**
  122329. * Gets or sets a boolean indicating if the outline must be rendered as well
  122330. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  122331. */
  122332. renderOutline: boolean;
  122333. /** @hidden (Backing field) */
  122334. _renderOverlay: boolean;
  122335. /**
  122336. * Gets or sets a boolean indicating if the overlay must be rendered as well
  122337. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  122338. */
  122339. renderOverlay: boolean;
  122340. }
  122341. /**
  122342. * This class is responsible to draw bothe outline/overlay of meshes.
  122343. * It should not be used directly but through the available method on mesh.
  122344. */
  122345. export class OutlineRenderer implements ISceneComponent {
  122346. /**
  122347. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  122348. */
  122349. private static _StencilReference;
  122350. /**
  122351. * The name of the component. Each component must have a unique name.
  122352. */
  122353. name: string;
  122354. /**
  122355. * The scene the component belongs to.
  122356. */
  122357. scene: Scene;
  122358. /**
  122359. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  122360. */
  122361. zOffset: number;
  122362. private _engine;
  122363. private _effect;
  122364. private _cachedDefines;
  122365. private _savedDepthWrite;
  122366. /**
  122367. * Instantiates a new outline renderer. (There could be only one per scene).
  122368. * @param scene Defines the scene it belongs to
  122369. */
  122370. constructor(scene: Scene);
  122371. /**
  122372. * Register the component to one instance of a scene.
  122373. */
  122374. register(): void;
  122375. /**
  122376. * Rebuilds the elements related to this component in case of
  122377. * context lost for instance.
  122378. */
  122379. rebuild(): void;
  122380. /**
  122381. * Disposes the component and the associated ressources.
  122382. */
  122383. dispose(): void;
  122384. /**
  122385. * Renders the outline in the canvas.
  122386. * @param subMesh Defines the sumesh to render
  122387. * @param batch Defines the batch of meshes in case of instances
  122388. * @param useOverlay Defines if the rendering is for the overlay or the outline
  122389. */
  122390. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  122391. /**
  122392. * Returns whether or not the outline renderer is ready for a given submesh.
  122393. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  122394. * @param subMesh Defines the submesh to check readyness for
  122395. * @param useInstances Defines wheter wee are trying to render instances or not
  122396. * @returns true if ready otherwise false
  122397. */
  122398. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122399. private _beforeRenderingMesh;
  122400. private _afterRenderingMesh;
  122401. }
  122402. }
  122403. declare module BABYLON {
  122404. /**
  122405. * Defines the list of states available for a task inside a AssetsManager
  122406. */
  122407. export enum AssetTaskState {
  122408. /**
  122409. * Initialization
  122410. */
  122411. INIT = 0,
  122412. /**
  122413. * Running
  122414. */
  122415. RUNNING = 1,
  122416. /**
  122417. * Done
  122418. */
  122419. DONE = 2,
  122420. /**
  122421. * Error
  122422. */
  122423. ERROR = 3
  122424. }
  122425. /**
  122426. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  122427. */
  122428. export abstract class AbstractAssetTask {
  122429. /**
  122430. * Task name
  122431. */ name: string;
  122432. /**
  122433. * Callback called when the task is successful
  122434. */
  122435. onSuccess: (task: any) => void;
  122436. /**
  122437. * Callback called when the task is not successful
  122438. */
  122439. onError: (task: any, message?: string, exception?: any) => void;
  122440. /**
  122441. * Creates a new AssetsManager
  122442. * @param name defines the name of the task
  122443. */
  122444. constructor(
  122445. /**
  122446. * Task name
  122447. */ name: string);
  122448. private _isCompleted;
  122449. private _taskState;
  122450. private _errorObject;
  122451. /**
  122452. * Get if the task is completed
  122453. */
  122454. readonly isCompleted: boolean;
  122455. /**
  122456. * Gets the current state of the task
  122457. */
  122458. readonly taskState: AssetTaskState;
  122459. /**
  122460. * Gets the current error object (if task is in error)
  122461. */
  122462. readonly errorObject: {
  122463. message?: string;
  122464. exception?: any;
  122465. };
  122466. /**
  122467. * Internal only
  122468. * @hidden
  122469. */
  122470. _setErrorObject(message?: string, exception?: any): void;
  122471. /**
  122472. * Execute the current task
  122473. * @param scene defines the scene where you want your assets to be loaded
  122474. * @param onSuccess is a callback called when the task is successfully executed
  122475. * @param onError is a callback called if an error occurs
  122476. */
  122477. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122478. /**
  122479. * Execute the current task
  122480. * @param scene defines the scene where you want your assets to be loaded
  122481. * @param onSuccess is a callback called when the task is successfully executed
  122482. * @param onError is a callback called if an error occurs
  122483. */
  122484. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122485. /**
  122486. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  122487. * This can be used with failed tasks that have the reason for failure fixed.
  122488. */
  122489. reset(): void;
  122490. private onErrorCallback;
  122491. private onDoneCallback;
  122492. }
  122493. /**
  122494. * Define the interface used by progress events raised during assets loading
  122495. */
  122496. export interface IAssetsProgressEvent {
  122497. /**
  122498. * Defines the number of remaining tasks to process
  122499. */
  122500. remainingCount: number;
  122501. /**
  122502. * Defines the total number of tasks
  122503. */
  122504. totalCount: number;
  122505. /**
  122506. * Defines the task that was just processed
  122507. */
  122508. task: AbstractAssetTask;
  122509. }
  122510. /**
  122511. * Class used to share progress information about assets loading
  122512. */
  122513. export class AssetsProgressEvent implements IAssetsProgressEvent {
  122514. /**
  122515. * Defines the number of remaining tasks to process
  122516. */
  122517. remainingCount: number;
  122518. /**
  122519. * Defines the total number of tasks
  122520. */
  122521. totalCount: number;
  122522. /**
  122523. * Defines the task that was just processed
  122524. */
  122525. task: AbstractAssetTask;
  122526. /**
  122527. * Creates a AssetsProgressEvent
  122528. * @param remainingCount defines the number of remaining tasks to process
  122529. * @param totalCount defines the total number of tasks
  122530. * @param task defines the task that was just processed
  122531. */
  122532. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  122533. }
  122534. /**
  122535. * Define a task used by AssetsManager to load meshes
  122536. */
  122537. export class MeshAssetTask extends AbstractAssetTask {
  122538. /**
  122539. * Defines the name of the task
  122540. */
  122541. name: string;
  122542. /**
  122543. * Defines the list of mesh's names you want to load
  122544. */
  122545. meshesNames: any;
  122546. /**
  122547. * Defines the root url to use as a base to load your meshes and associated resources
  122548. */
  122549. rootUrl: string;
  122550. /**
  122551. * Defines the filename of the scene to load from
  122552. */
  122553. sceneFilename: string;
  122554. /**
  122555. * Gets the list of loaded meshes
  122556. */
  122557. loadedMeshes: Array<AbstractMesh>;
  122558. /**
  122559. * Gets the list of loaded particle systems
  122560. */
  122561. loadedParticleSystems: Array<IParticleSystem>;
  122562. /**
  122563. * Gets the list of loaded skeletons
  122564. */
  122565. loadedSkeletons: Array<Skeleton>;
  122566. /**
  122567. * Gets the list of loaded animation groups
  122568. */
  122569. loadedAnimationGroups: Array<AnimationGroup>;
  122570. /**
  122571. * Callback called when the task is successful
  122572. */
  122573. onSuccess: (task: MeshAssetTask) => void;
  122574. /**
  122575. * Callback called when the task is successful
  122576. */
  122577. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  122578. /**
  122579. * Creates a new MeshAssetTask
  122580. * @param name defines the name of the task
  122581. * @param meshesNames defines the list of mesh's names you want to load
  122582. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  122583. * @param sceneFilename defines the filename of the scene to load from
  122584. */
  122585. constructor(
  122586. /**
  122587. * Defines the name of the task
  122588. */
  122589. name: string,
  122590. /**
  122591. * Defines the list of mesh's names you want to load
  122592. */
  122593. meshesNames: any,
  122594. /**
  122595. * Defines the root url to use as a base to load your meshes and associated resources
  122596. */
  122597. rootUrl: string,
  122598. /**
  122599. * Defines the filename of the scene to load from
  122600. */
  122601. sceneFilename: string);
  122602. /**
  122603. * Execute the current task
  122604. * @param scene defines the scene where you want your assets to be loaded
  122605. * @param onSuccess is a callback called when the task is successfully executed
  122606. * @param onError is a callback called if an error occurs
  122607. */
  122608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122609. }
  122610. /**
  122611. * Define a task used by AssetsManager to load text content
  122612. */
  122613. export class TextFileAssetTask extends AbstractAssetTask {
  122614. /**
  122615. * Defines the name of the task
  122616. */
  122617. name: string;
  122618. /**
  122619. * Defines the location of the file to load
  122620. */
  122621. url: string;
  122622. /**
  122623. * Gets the loaded text string
  122624. */
  122625. text: string;
  122626. /**
  122627. * Callback called when the task is successful
  122628. */
  122629. onSuccess: (task: TextFileAssetTask) => void;
  122630. /**
  122631. * Callback called when the task is successful
  122632. */
  122633. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  122634. /**
  122635. * Creates a new TextFileAssetTask object
  122636. * @param name defines the name of the task
  122637. * @param url defines the location of the file to load
  122638. */
  122639. constructor(
  122640. /**
  122641. * Defines the name of the task
  122642. */
  122643. name: string,
  122644. /**
  122645. * Defines the location of the file to load
  122646. */
  122647. url: string);
  122648. /**
  122649. * Execute the current task
  122650. * @param scene defines the scene where you want your assets to be loaded
  122651. * @param onSuccess is a callback called when the task is successfully executed
  122652. * @param onError is a callback called if an error occurs
  122653. */
  122654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122655. }
  122656. /**
  122657. * Define a task used by AssetsManager to load binary data
  122658. */
  122659. export class BinaryFileAssetTask extends AbstractAssetTask {
  122660. /**
  122661. * Defines the name of the task
  122662. */
  122663. name: string;
  122664. /**
  122665. * Defines the location of the file to load
  122666. */
  122667. url: string;
  122668. /**
  122669. * Gets the lodaded data (as an array buffer)
  122670. */
  122671. data: ArrayBuffer;
  122672. /**
  122673. * Callback called when the task is successful
  122674. */
  122675. onSuccess: (task: BinaryFileAssetTask) => void;
  122676. /**
  122677. * Callback called when the task is successful
  122678. */
  122679. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  122680. /**
  122681. * Creates a new BinaryFileAssetTask object
  122682. * @param name defines the name of the new task
  122683. * @param url defines the location of the file to load
  122684. */
  122685. constructor(
  122686. /**
  122687. * Defines the name of the task
  122688. */
  122689. name: string,
  122690. /**
  122691. * Defines the location of the file to load
  122692. */
  122693. url: string);
  122694. /**
  122695. * Execute the current task
  122696. * @param scene defines the scene where you want your assets to be loaded
  122697. * @param onSuccess is a callback called when the task is successfully executed
  122698. * @param onError is a callback called if an error occurs
  122699. */
  122700. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122701. }
  122702. /**
  122703. * Define a task used by AssetsManager to load images
  122704. */
  122705. export class ImageAssetTask extends AbstractAssetTask {
  122706. /**
  122707. * Defines the name of the task
  122708. */
  122709. name: string;
  122710. /**
  122711. * Defines the location of the image to load
  122712. */
  122713. url: string;
  122714. /**
  122715. * Gets the loaded images
  122716. */
  122717. image: HTMLImageElement;
  122718. /**
  122719. * Callback called when the task is successful
  122720. */
  122721. onSuccess: (task: ImageAssetTask) => void;
  122722. /**
  122723. * Callback called when the task is successful
  122724. */
  122725. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  122726. /**
  122727. * Creates a new ImageAssetTask
  122728. * @param name defines the name of the task
  122729. * @param url defines the location of the image to load
  122730. */
  122731. constructor(
  122732. /**
  122733. * Defines the name of the task
  122734. */
  122735. name: string,
  122736. /**
  122737. * Defines the location of the image to load
  122738. */
  122739. url: string);
  122740. /**
  122741. * Execute the current task
  122742. * @param scene defines the scene where you want your assets to be loaded
  122743. * @param onSuccess is a callback called when the task is successfully executed
  122744. * @param onError is a callback called if an error occurs
  122745. */
  122746. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122747. }
  122748. /**
  122749. * Defines the interface used by texture loading tasks
  122750. */
  122751. export interface ITextureAssetTask<TEX extends BaseTexture> {
  122752. /**
  122753. * Gets the loaded texture
  122754. */
  122755. texture: TEX;
  122756. }
  122757. /**
  122758. * Define a task used by AssetsManager to load 2D textures
  122759. */
  122760. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  122761. /**
  122762. * Defines the name of the task
  122763. */
  122764. name: string;
  122765. /**
  122766. * Defines the location of the file to load
  122767. */
  122768. url: string;
  122769. /**
  122770. * Defines if mipmap should not be generated (default is false)
  122771. */
  122772. noMipmap?: boolean | undefined;
  122773. /**
  122774. * Defines if texture must be inverted on Y axis (default is false)
  122775. */
  122776. invertY?: boolean | undefined;
  122777. /**
  122778. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  122779. */
  122780. samplingMode: number;
  122781. /**
  122782. * Gets the loaded texture
  122783. */
  122784. texture: Texture;
  122785. /**
  122786. * Callback called when the task is successful
  122787. */
  122788. onSuccess: (task: TextureAssetTask) => void;
  122789. /**
  122790. * Callback called when the task is successful
  122791. */
  122792. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  122793. /**
  122794. * Creates a new TextureAssetTask object
  122795. * @param name defines the name of the task
  122796. * @param url defines the location of the file to load
  122797. * @param noMipmap defines if mipmap should not be generated (default is false)
  122798. * @param invertY defines if texture must be inverted on Y axis (default is false)
  122799. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  122800. */
  122801. constructor(
  122802. /**
  122803. * Defines the name of the task
  122804. */
  122805. name: string,
  122806. /**
  122807. * Defines the location of the file to load
  122808. */
  122809. url: string,
  122810. /**
  122811. * Defines if mipmap should not be generated (default is false)
  122812. */
  122813. noMipmap?: boolean | undefined,
  122814. /**
  122815. * Defines if texture must be inverted on Y axis (default is false)
  122816. */
  122817. invertY?: boolean | undefined,
  122818. /**
  122819. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  122820. */
  122821. samplingMode?: number);
  122822. /**
  122823. * Execute the current task
  122824. * @param scene defines the scene where you want your assets to be loaded
  122825. * @param onSuccess is a callback called when the task is successfully executed
  122826. * @param onError is a callback called if an error occurs
  122827. */
  122828. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122829. }
  122830. /**
  122831. * Define a task used by AssetsManager to load cube textures
  122832. */
  122833. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  122834. /**
  122835. * Defines the name of the task
  122836. */
  122837. name: string;
  122838. /**
  122839. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  122840. */
  122841. url: string;
  122842. /**
  122843. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  122844. */
  122845. extensions?: string[] | undefined;
  122846. /**
  122847. * Defines if mipmaps should not be generated (default is false)
  122848. */
  122849. noMipmap?: boolean | undefined;
  122850. /**
  122851. * Defines the explicit list of files (undefined by default)
  122852. */
  122853. files?: string[] | undefined;
  122854. /**
  122855. * Gets the loaded texture
  122856. */
  122857. texture: CubeTexture;
  122858. /**
  122859. * Callback called when the task is successful
  122860. */
  122861. onSuccess: (task: CubeTextureAssetTask) => void;
  122862. /**
  122863. * Callback called when the task is successful
  122864. */
  122865. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  122866. /**
  122867. * Creates a new CubeTextureAssetTask
  122868. * @param name defines the name of the task
  122869. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  122870. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  122871. * @param noMipmap defines if mipmaps should not be generated (default is false)
  122872. * @param files defines the explicit list of files (undefined by default)
  122873. */
  122874. constructor(
  122875. /**
  122876. * Defines the name of the task
  122877. */
  122878. name: string,
  122879. /**
  122880. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  122881. */
  122882. url: string,
  122883. /**
  122884. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  122885. */
  122886. extensions?: string[] | undefined,
  122887. /**
  122888. * Defines if mipmaps should not be generated (default is false)
  122889. */
  122890. noMipmap?: boolean | undefined,
  122891. /**
  122892. * Defines the explicit list of files (undefined by default)
  122893. */
  122894. files?: string[] | undefined);
  122895. /**
  122896. * Execute the current task
  122897. * @param scene defines the scene where you want your assets to be loaded
  122898. * @param onSuccess is a callback called when the task is successfully executed
  122899. * @param onError is a callback called if an error occurs
  122900. */
  122901. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122902. }
  122903. /**
  122904. * Define a task used by AssetsManager to load HDR cube textures
  122905. */
  122906. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  122907. /**
  122908. * Defines the name of the task
  122909. */
  122910. name: string;
  122911. /**
  122912. * Defines the location of the file to load
  122913. */
  122914. url: string;
  122915. /**
  122916. * Defines the desired size (the more it increases the longer the generation will be)
  122917. */
  122918. size: number;
  122919. /**
  122920. * Defines if mipmaps should not be generated (default is false)
  122921. */
  122922. noMipmap: boolean;
  122923. /**
  122924. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  122925. */
  122926. generateHarmonics: boolean;
  122927. /**
  122928. * 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)
  122929. */
  122930. gammaSpace: boolean;
  122931. /**
  122932. * Internal Use Only
  122933. */
  122934. reserved: boolean;
  122935. /**
  122936. * Gets the loaded texture
  122937. */
  122938. texture: HDRCubeTexture;
  122939. /**
  122940. * Callback called when the task is successful
  122941. */
  122942. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  122943. /**
  122944. * Callback called when the task is successful
  122945. */
  122946. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  122947. /**
  122948. * Creates a new HDRCubeTextureAssetTask object
  122949. * @param name defines the name of the task
  122950. * @param url defines the location of the file to load
  122951. * @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.
  122952. * @param noMipmap defines if mipmaps should not be generated (default is false)
  122953. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  122954. * @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)
  122955. * @param reserved Internal use only
  122956. */
  122957. constructor(
  122958. /**
  122959. * Defines the name of the task
  122960. */
  122961. name: string,
  122962. /**
  122963. * Defines the location of the file to load
  122964. */
  122965. url: string,
  122966. /**
  122967. * Defines the desired size (the more it increases the longer the generation will be)
  122968. */
  122969. size: number,
  122970. /**
  122971. * Defines if mipmaps should not be generated (default is false)
  122972. */
  122973. noMipmap?: boolean,
  122974. /**
  122975. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  122976. */
  122977. generateHarmonics?: boolean,
  122978. /**
  122979. * 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)
  122980. */
  122981. gammaSpace?: boolean,
  122982. /**
  122983. * Internal Use Only
  122984. */
  122985. reserved?: boolean);
  122986. /**
  122987. * Execute the current task
  122988. * @param scene defines the scene where you want your assets to be loaded
  122989. * @param onSuccess is a callback called when the task is successfully executed
  122990. * @param onError is a callback called if an error occurs
  122991. */
  122992. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122993. }
  122994. /**
  122995. * Define a task used by AssetsManager to load Equirectangular cube textures
  122996. */
  122997. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  122998. /**
  122999. * Defines the name of the task
  123000. */
  123001. name: string;
  123002. /**
  123003. * Defines the location of the file to load
  123004. */
  123005. url: string;
  123006. /**
  123007. * Defines the desired size (the more it increases the longer the generation will be)
  123008. */
  123009. size: number;
  123010. /**
  123011. * Defines if mipmaps should not be generated (default is false)
  123012. */
  123013. noMipmap: boolean;
  123014. /**
  123015. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123016. * but the standard material would require them in Gamma space) (default is true)
  123017. */
  123018. gammaSpace: boolean;
  123019. /**
  123020. * Gets the loaded texture
  123021. */
  123022. texture: EquiRectangularCubeTexture;
  123023. /**
  123024. * Callback called when the task is successful
  123025. */
  123026. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  123027. /**
  123028. * Callback called when the task is successful
  123029. */
  123030. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  123031. /**
  123032. * Creates a new EquiRectangularCubeTextureAssetTask object
  123033. * @param name defines the name of the task
  123034. * @param url defines the location of the file to load
  123035. * @param size defines the desired size (the more it increases the longer the generation will be)
  123036. * If the size is omitted this implies you are using a preprocessed cubemap.
  123037. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123038. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  123039. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  123040. * (default is true)
  123041. */
  123042. constructor(
  123043. /**
  123044. * Defines the name of the task
  123045. */
  123046. name: string,
  123047. /**
  123048. * Defines the location of the file to load
  123049. */
  123050. url: string,
  123051. /**
  123052. * Defines the desired size (the more it increases the longer the generation will be)
  123053. */
  123054. size: number,
  123055. /**
  123056. * Defines if mipmaps should not be generated (default is false)
  123057. */
  123058. noMipmap?: boolean,
  123059. /**
  123060. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123061. * but the standard material would require them in Gamma space) (default is true)
  123062. */
  123063. gammaSpace?: boolean);
  123064. /**
  123065. * Execute the current task
  123066. * @param scene defines the scene where you want your assets to be loaded
  123067. * @param onSuccess is a callback called when the task is successfully executed
  123068. * @param onError is a callback called if an error occurs
  123069. */
  123070. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123071. }
  123072. /**
  123073. * This class can be used to easily import assets into a scene
  123074. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  123075. */
  123076. export class AssetsManager {
  123077. private _scene;
  123078. private _isLoading;
  123079. protected _tasks: AbstractAssetTask[];
  123080. protected _waitingTasksCount: number;
  123081. protected _totalTasksCount: number;
  123082. /**
  123083. * Callback called when all tasks are processed
  123084. */
  123085. onFinish: (tasks: AbstractAssetTask[]) => void;
  123086. /**
  123087. * Callback called when a task is successful
  123088. */
  123089. onTaskSuccess: (task: AbstractAssetTask) => void;
  123090. /**
  123091. * Callback called when a task had an error
  123092. */
  123093. onTaskError: (task: AbstractAssetTask) => void;
  123094. /**
  123095. * Callback called when a task is done (whatever the result is)
  123096. */
  123097. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  123098. /**
  123099. * Observable called when all tasks are processed
  123100. */
  123101. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  123102. /**
  123103. * Observable called when a task had an error
  123104. */
  123105. onTaskErrorObservable: Observable<AbstractAssetTask>;
  123106. /**
  123107. * Observable called when all tasks were executed
  123108. */
  123109. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  123110. /**
  123111. * Observable called when a task is done (whatever the result is)
  123112. */
  123113. onProgressObservable: Observable<IAssetsProgressEvent>;
  123114. /**
  123115. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  123116. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123117. */
  123118. useDefaultLoadingScreen: boolean;
  123119. /**
  123120. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  123121. * when all assets have been downloaded.
  123122. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  123123. */
  123124. autoHideLoadingUI: boolean;
  123125. /**
  123126. * Creates a new AssetsManager
  123127. * @param scene defines the scene to work on
  123128. */
  123129. constructor(scene: Scene);
  123130. /**
  123131. * Add a MeshAssetTask to the list of active tasks
  123132. * @param taskName defines the name of the new task
  123133. * @param meshesNames defines the name of meshes to load
  123134. * @param rootUrl defines the root url to use to locate files
  123135. * @param sceneFilename defines the filename of the scene file
  123136. * @returns a new MeshAssetTask object
  123137. */
  123138. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  123139. /**
  123140. * Add a TextFileAssetTask to the list of active tasks
  123141. * @param taskName defines the name of the new task
  123142. * @param url defines the url of the file to load
  123143. * @returns a new TextFileAssetTask object
  123144. */
  123145. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  123146. /**
  123147. * Add a BinaryFileAssetTask to the list of active tasks
  123148. * @param taskName defines the name of the new task
  123149. * @param url defines the url of the file to load
  123150. * @returns a new BinaryFileAssetTask object
  123151. */
  123152. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  123153. /**
  123154. * Add a ImageAssetTask to the list of active tasks
  123155. * @param taskName defines the name of the new task
  123156. * @param url defines the url of the file to load
  123157. * @returns a new ImageAssetTask object
  123158. */
  123159. addImageTask(taskName: string, url: string): ImageAssetTask;
  123160. /**
  123161. * Add a TextureAssetTask to the list of active tasks
  123162. * @param taskName defines the name of the new task
  123163. * @param url defines the url of the file to load
  123164. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123165. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  123166. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123167. * @returns a new TextureAssetTask object
  123168. */
  123169. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  123170. /**
  123171. * Add a CubeTextureAssetTask to the list of active tasks
  123172. * @param taskName defines the name of the new task
  123173. * @param url defines the url of the file to load
  123174. * @param extensions defines the extension to use to load the cube map (can be null)
  123175. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123176. * @param files defines the list of files to load (can be null)
  123177. * @returns a new CubeTextureAssetTask object
  123178. */
  123179. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  123180. /**
  123181. *
  123182. * Add a HDRCubeTextureAssetTask to the list of active tasks
  123183. * @param taskName defines the name of the new task
  123184. * @param url defines the url of the file to load
  123185. * @param size defines the size you want for the cubemap (can be null)
  123186. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123187. * @param generateHarmonics defines if you want to automatically generate (true by default)
  123188. * @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)
  123189. * @param reserved Internal use only
  123190. * @returns a new HDRCubeTextureAssetTask object
  123191. */
  123192. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  123193. /**
  123194. *
  123195. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  123196. * @param taskName defines the name of the new task
  123197. * @param url defines the url of the file to load
  123198. * @param size defines the size you want for the cubemap (can be null)
  123199. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123200. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  123201. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  123202. * @returns a new EquiRectangularCubeTextureAssetTask object
  123203. */
  123204. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  123205. /**
  123206. * Remove a task from the assets manager.
  123207. * @param task the task to remove
  123208. */
  123209. removeTask(task: AbstractAssetTask): void;
  123210. private _decreaseWaitingTasksCount;
  123211. private _runTask;
  123212. /**
  123213. * Reset the AssetsManager and remove all tasks
  123214. * @return the current instance of the AssetsManager
  123215. */
  123216. reset(): AssetsManager;
  123217. /**
  123218. * Start the loading process
  123219. * @return the current instance of the AssetsManager
  123220. */
  123221. load(): AssetsManager;
  123222. /**
  123223. * Start the loading process as an async operation
  123224. * @return a promise returning the list of failed tasks
  123225. */
  123226. loadAsync(): Promise<void>;
  123227. }
  123228. }
  123229. declare module BABYLON {
  123230. /**
  123231. * Wrapper class for promise with external resolve and reject.
  123232. */
  123233. export class Deferred<T> {
  123234. /**
  123235. * The promise associated with this deferred object.
  123236. */
  123237. readonly promise: Promise<T>;
  123238. private _resolve;
  123239. private _reject;
  123240. /**
  123241. * The resolve method of the promise associated with this deferred object.
  123242. */
  123243. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  123244. /**
  123245. * The reject method of the promise associated with this deferred object.
  123246. */
  123247. readonly reject: (reason?: any) => void;
  123248. /**
  123249. * Constructor for this deferred object.
  123250. */
  123251. constructor();
  123252. }
  123253. }
  123254. declare module BABYLON {
  123255. /**
  123256. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  123257. */
  123258. export class MeshExploder {
  123259. private _centerMesh;
  123260. private _meshes;
  123261. private _meshesOrigins;
  123262. private _toCenterVectors;
  123263. private _scaledDirection;
  123264. private _newPosition;
  123265. private _centerPosition;
  123266. /**
  123267. * Explodes meshes from a center mesh.
  123268. * @param meshes The meshes to explode.
  123269. * @param centerMesh The mesh to be center of explosion.
  123270. */
  123271. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  123272. private _setCenterMesh;
  123273. /**
  123274. * Get class name
  123275. * @returns "MeshExploder"
  123276. */
  123277. getClassName(): string;
  123278. /**
  123279. * "Exploded meshes"
  123280. * @returns Array of meshes with the centerMesh at index 0.
  123281. */
  123282. getMeshes(): Array<Mesh>;
  123283. /**
  123284. * Explodes meshes giving a specific direction
  123285. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  123286. */
  123287. explode(direction?: number): void;
  123288. }
  123289. }
  123290. declare module BABYLON {
  123291. /**
  123292. * Class used to help managing file picking and drag'n'drop
  123293. */
  123294. export class FilesInput {
  123295. /**
  123296. * List of files ready to be loaded
  123297. */
  123298. static readonly FilesToLoad: {
  123299. [key: string]: File;
  123300. };
  123301. /**
  123302. * Callback called when a file is processed
  123303. */
  123304. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  123305. private _engine;
  123306. private _currentScene;
  123307. private _sceneLoadedCallback;
  123308. private _progressCallback;
  123309. private _additionalRenderLoopLogicCallback;
  123310. private _textureLoadingCallback;
  123311. private _startingProcessingFilesCallback;
  123312. private _onReloadCallback;
  123313. private _errorCallback;
  123314. private _elementToMonitor;
  123315. private _sceneFileToLoad;
  123316. private _filesToLoad;
  123317. /**
  123318. * Creates a new FilesInput
  123319. * @param engine defines the rendering engine
  123320. * @param scene defines the hosting scene
  123321. * @param sceneLoadedCallback callback called when scene is loaded
  123322. * @param progressCallback callback called to track progress
  123323. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  123324. * @param textureLoadingCallback callback called when a texture is loading
  123325. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  123326. * @param onReloadCallback callback called when a reload is requested
  123327. * @param errorCallback callback call if an error occurs
  123328. */
  123329. 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);
  123330. private _dragEnterHandler;
  123331. private _dragOverHandler;
  123332. private _dropHandler;
  123333. /**
  123334. * Calls this function to listen to drag'n'drop events on a specific DOM element
  123335. * @param elementToMonitor defines the DOM element to track
  123336. */
  123337. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  123338. /**
  123339. * Release all associated resources
  123340. */
  123341. dispose(): void;
  123342. private renderFunction;
  123343. private drag;
  123344. private drop;
  123345. private _traverseFolder;
  123346. private _processFiles;
  123347. /**
  123348. * Load files from a drop event
  123349. * @param event defines the drop event to use as source
  123350. */
  123351. loadFiles(event: any): void;
  123352. private _processReload;
  123353. /**
  123354. * Reload the current scene from the loaded files
  123355. */
  123356. reload(): void;
  123357. }
  123358. }
  123359. declare module BABYLON {
  123360. /**
  123361. * Defines the root class used to create scene optimization to use with SceneOptimizer
  123362. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123363. */
  123364. export class SceneOptimization {
  123365. /**
  123366. * Defines the priority of this optimization (0 by default which means first in the list)
  123367. */
  123368. priority: number;
  123369. /**
  123370. * Gets a string describing the action executed by the current optimization
  123371. * @returns description string
  123372. */
  123373. getDescription(): string;
  123374. /**
  123375. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123376. * @param scene defines the current scene where to apply this optimization
  123377. * @param optimizer defines the current optimizer
  123378. * @returns true if everything that can be done was applied
  123379. */
  123380. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123381. /**
  123382. * Creates the SceneOptimization object
  123383. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123384. * @param desc defines the description associated with the optimization
  123385. */
  123386. constructor(
  123387. /**
  123388. * Defines the priority of this optimization (0 by default which means first in the list)
  123389. */
  123390. priority?: number);
  123391. }
  123392. /**
  123393. * Defines an optimization used to reduce the size of render target textures
  123394. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123395. */
  123396. export class TextureOptimization extends SceneOptimization {
  123397. /**
  123398. * Defines the priority of this optimization (0 by default which means first in the list)
  123399. */
  123400. priority: number;
  123401. /**
  123402. * 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
  123403. */
  123404. maximumSize: number;
  123405. /**
  123406. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123407. */
  123408. step: number;
  123409. /**
  123410. * Gets a string describing the action executed by the current optimization
  123411. * @returns description string
  123412. */
  123413. getDescription(): string;
  123414. /**
  123415. * Creates the TextureOptimization object
  123416. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123417. * @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
  123418. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123419. */
  123420. constructor(
  123421. /**
  123422. * Defines the priority of this optimization (0 by default which means first in the list)
  123423. */
  123424. priority?: number,
  123425. /**
  123426. * 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
  123427. */
  123428. maximumSize?: number,
  123429. /**
  123430. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123431. */
  123432. step?: number);
  123433. /**
  123434. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123435. * @param scene defines the current scene where to apply this optimization
  123436. * @param optimizer defines the current optimizer
  123437. * @returns true if everything that can be done was applied
  123438. */
  123439. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123440. }
  123441. /**
  123442. * Defines an optimization used to increase or decrease the rendering resolution
  123443. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123444. */
  123445. export class HardwareScalingOptimization extends SceneOptimization {
  123446. /**
  123447. * Defines the priority of this optimization (0 by default which means first in the list)
  123448. */
  123449. priority: number;
  123450. /**
  123451. * Defines the maximum scale to use (2 by default)
  123452. */
  123453. maximumScale: number;
  123454. /**
  123455. * Defines the step to use between two passes (0.5 by default)
  123456. */
  123457. step: number;
  123458. private _currentScale;
  123459. private _directionOffset;
  123460. /**
  123461. * Gets a string describing the action executed by the current optimization
  123462. * @return description string
  123463. */
  123464. getDescription(): string;
  123465. /**
  123466. * Creates the HardwareScalingOptimization object
  123467. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123468. * @param maximumScale defines the maximum scale to use (2 by default)
  123469. * @param step defines the step to use between two passes (0.5 by default)
  123470. */
  123471. constructor(
  123472. /**
  123473. * Defines the priority of this optimization (0 by default which means first in the list)
  123474. */
  123475. priority?: number,
  123476. /**
  123477. * Defines the maximum scale to use (2 by default)
  123478. */
  123479. maximumScale?: number,
  123480. /**
  123481. * Defines the step to use between two passes (0.5 by default)
  123482. */
  123483. step?: number);
  123484. /**
  123485. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123486. * @param scene defines the current scene where to apply this optimization
  123487. * @param optimizer defines the current optimizer
  123488. * @returns true if everything that can be done was applied
  123489. */
  123490. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123491. }
  123492. /**
  123493. * Defines an optimization used to remove shadows
  123494. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123495. */
  123496. export class ShadowsOptimization extends SceneOptimization {
  123497. /**
  123498. * Gets a string describing the action executed by the current optimization
  123499. * @return description string
  123500. */
  123501. getDescription(): string;
  123502. /**
  123503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123504. * @param scene defines the current scene where to apply this optimization
  123505. * @param optimizer defines the current optimizer
  123506. * @returns true if everything that can be done was applied
  123507. */
  123508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123509. }
  123510. /**
  123511. * Defines an optimization used to turn post-processes off
  123512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123513. */
  123514. export class PostProcessesOptimization extends SceneOptimization {
  123515. /**
  123516. * Gets a string describing the action executed by the current optimization
  123517. * @return description string
  123518. */
  123519. getDescription(): string;
  123520. /**
  123521. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123522. * @param scene defines the current scene where to apply this optimization
  123523. * @param optimizer defines the current optimizer
  123524. * @returns true if everything that can be done was applied
  123525. */
  123526. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123527. }
  123528. /**
  123529. * Defines an optimization used to turn lens flares off
  123530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123531. */
  123532. export class LensFlaresOptimization extends SceneOptimization {
  123533. /**
  123534. * Gets a string describing the action executed by the current optimization
  123535. * @return description string
  123536. */
  123537. getDescription(): string;
  123538. /**
  123539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123540. * @param scene defines the current scene where to apply this optimization
  123541. * @param optimizer defines the current optimizer
  123542. * @returns true if everything that can be done was applied
  123543. */
  123544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123545. }
  123546. /**
  123547. * Defines an optimization based on user defined callback.
  123548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123549. */
  123550. export class CustomOptimization extends SceneOptimization {
  123551. /**
  123552. * Callback called to apply the custom optimization.
  123553. */
  123554. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  123555. /**
  123556. * Callback called to get custom description
  123557. */
  123558. onGetDescription: () => string;
  123559. /**
  123560. * Gets a string describing the action executed by the current optimization
  123561. * @returns description string
  123562. */
  123563. getDescription(): string;
  123564. /**
  123565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123566. * @param scene defines the current scene where to apply this optimization
  123567. * @param optimizer defines the current optimizer
  123568. * @returns true if everything that can be done was applied
  123569. */
  123570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123571. }
  123572. /**
  123573. * Defines an optimization used to turn particles off
  123574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123575. */
  123576. export class ParticlesOptimization extends SceneOptimization {
  123577. /**
  123578. * Gets a string describing the action executed by the current optimization
  123579. * @return description string
  123580. */
  123581. getDescription(): string;
  123582. /**
  123583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123584. * @param scene defines the current scene where to apply this optimization
  123585. * @param optimizer defines the current optimizer
  123586. * @returns true if everything that can be done was applied
  123587. */
  123588. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123589. }
  123590. /**
  123591. * Defines an optimization used to turn render targets off
  123592. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123593. */
  123594. export class RenderTargetsOptimization extends SceneOptimization {
  123595. /**
  123596. * Gets a string describing the action executed by the current optimization
  123597. * @return description string
  123598. */
  123599. getDescription(): string;
  123600. /**
  123601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123602. * @param scene defines the current scene where to apply this optimization
  123603. * @param optimizer defines the current optimizer
  123604. * @returns true if everything that can be done was applied
  123605. */
  123606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123607. }
  123608. /**
  123609. * Defines an optimization used to merge meshes with compatible materials
  123610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123611. */
  123612. export class MergeMeshesOptimization extends SceneOptimization {
  123613. private static _UpdateSelectionTree;
  123614. /**
  123615. * Gets or sets a boolean which defines if optimization octree has to be updated
  123616. */
  123617. /**
  123618. * Gets or sets a boolean which defines if optimization octree has to be updated
  123619. */
  123620. static UpdateSelectionTree: boolean;
  123621. /**
  123622. * Gets a string describing the action executed by the current optimization
  123623. * @return description string
  123624. */
  123625. getDescription(): string;
  123626. private _canBeMerged;
  123627. /**
  123628. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123629. * @param scene defines the current scene where to apply this optimization
  123630. * @param optimizer defines the current optimizer
  123631. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  123632. * @returns true if everything that can be done was applied
  123633. */
  123634. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  123635. }
  123636. /**
  123637. * Defines a list of options used by SceneOptimizer
  123638. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123639. */
  123640. export class SceneOptimizerOptions {
  123641. /**
  123642. * Defines the target frame rate to reach (60 by default)
  123643. */
  123644. targetFrameRate: number;
  123645. /**
  123646. * Defines the interval between two checkes (2000ms by default)
  123647. */
  123648. trackerDuration: number;
  123649. /**
  123650. * Gets the list of optimizations to apply
  123651. */
  123652. optimizations: SceneOptimization[];
  123653. /**
  123654. * Creates a new list of options used by SceneOptimizer
  123655. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  123656. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  123657. */
  123658. constructor(
  123659. /**
  123660. * Defines the target frame rate to reach (60 by default)
  123661. */
  123662. targetFrameRate?: number,
  123663. /**
  123664. * Defines the interval between two checkes (2000ms by default)
  123665. */
  123666. trackerDuration?: number);
  123667. /**
  123668. * Add a new optimization
  123669. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  123670. * @returns the current SceneOptimizerOptions
  123671. */
  123672. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  123673. /**
  123674. * Add a new custom optimization
  123675. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  123676. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  123677. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123678. * @returns the current SceneOptimizerOptions
  123679. */
  123680. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  123681. /**
  123682. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  123683. * @param targetFrameRate defines the target frame rate (60 by default)
  123684. * @returns a SceneOptimizerOptions object
  123685. */
  123686. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  123687. /**
  123688. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  123689. * @param targetFrameRate defines the target frame rate (60 by default)
  123690. * @returns a SceneOptimizerOptions object
  123691. */
  123692. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  123693. /**
  123694. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  123695. * @param targetFrameRate defines the target frame rate (60 by default)
  123696. * @returns a SceneOptimizerOptions object
  123697. */
  123698. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  123699. }
  123700. /**
  123701. * Class used to run optimizations in order to reach a target frame rate
  123702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123703. */
  123704. export class SceneOptimizer implements IDisposable {
  123705. private _isRunning;
  123706. private _options;
  123707. private _scene;
  123708. private _currentPriorityLevel;
  123709. private _targetFrameRate;
  123710. private _trackerDuration;
  123711. private _currentFrameRate;
  123712. private _sceneDisposeObserver;
  123713. private _improvementMode;
  123714. /**
  123715. * Defines an observable called when the optimizer reaches the target frame rate
  123716. */
  123717. onSuccessObservable: Observable<SceneOptimizer>;
  123718. /**
  123719. * Defines an observable called when the optimizer enables an optimization
  123720. */
  123721. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  123722. /**
  123723. * Defines an observable called when the optimizer is not able to reach the target frame rate
  123724. */
  123725. onFailureObservable: Observable<SceneOptimizer>;
  123726. /**
  123727. * Gets a boolean indicating if the optimizer is in improvement mode
  123728. */
  123729. readonly isInImprovementMode: boolean;
  123730. /**
  123731. * Gets the current priority level (0 at start)
  123732. */
  123733. readonly currentPriorityLevel: number;
  123734. /**
  123735. * Gets the current frame rate checked by the SceneOptimizer
  123736. */
  123737. readonly currentFrameRate: number;
  123738. /**
  123739. * Gets or sets the current target frame rate (60 by default)
  123740. */
  123741. /**
  123742. * Gets or sets the current target frame rate (60 by default)
  123743. */
  123744. targetFrameRate: number;
  123745. /**
  123746. * Gets or sets the current interval between two checks (every 2000ms by default)
  123747. */
  123748. /**
  123749. * Gets or sets the current interval between two checks (every 2000ms by default)
  123750. */
  123751. trackerDuration: number;
  123752. /**
  123753. * Gets the list of active optimizations
  123754. */
  123755. readonly optimizations: SceneOptimization[];
  123756. /**
  123757. * Creates a new SceneOptimizer
  123758. * @param scene defines the scene to work on
  123759. * @param options defines the options to use with the SceneOptimizer
  123760. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  123761. * @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)
  123762. */
  123763. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  123764. /**
  123765. * Stops the current optimizer
  123766. */
  123767. stop(): void;
  123768. /**
  123769. * Reset the optimizer to initial step (current priority level = 0)
  123770. */
  123771. reset(): void;
  123772. /**
  123773. * Start the optimizer. By default it will try to reach a specific framerate
  123774. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  123775. */
  123776. start(): void;
  123777. private _checkCurrentState;
  123778. /**
  123779. * Release all resources
  123780. */
  123781. dispose(): void;
  123782. /**
  123783. * Helper function to create a SceneOptimizer with one single line of code
  123784. * @param scene defines the scene to work on
  123785. * @param options defines the options to use with the SceneOptimizer
  123786. * @param onSuccess defines a callback to call on success
  123787. * @param onFailure defines a callback to call on failure
  123788. * @returns the new SceneOptimizer object
  123789. */
  123790. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  123791. }
  123792. }
  123793. declare module BABYLON {
  123794. /**
  123795. * Class used to serialize a scene into a string
  123796. */
  123797. export class SceneSerializer {
  123798. /**
  123799. * Clear cache used by a previous serialization
  123800. */
  123801. static ClearCache(): void;
  123802. /**
  123803. * Serialize a scene into a JSON compatible object
  123804. * @param scene defines the scene to serialize
  123805. * @returns a JSON compatible object
  123806. */
  123807. static Serialize(scene: Scene): any;
  123808. /**
  123809. * Serialize a mesh into a JSON compatible object
  123810. * @param toSerialize defines the mesh to serialize
  123811. * @param withParents defines if parents must be serialized as well
  123812. * @param withChildren defines if children must be serialized as well
  123813. * @returns a JSON compatible object
  123814. */
  123815. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  123816. }
  123817. }
  123818. declare module BABYLON {
  123819. /**
  123820. * Class used to host texture specific utilities
  123821. */
  123822. export class TextureTools {
  123823. /**
  123824. * Uses the GPU to create a copy texture rescaled at a given size
  123825. * @param texture Texture to copy from
  123826. * @param width defines the desired width
  123827. * @param height defines the desired height
  123828. * @param useBilinearMode defines if bilinear mode has to be used
  123829. * @return the generated texture
  123830. */
  123831. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  123832. }
  123833. }
  123834. declare module BABYLON {
  123835. /**
  123836. * This represents the different options available for the video capture.
  123837. */
  123838. export interface VideoRecorderOptions {
  123839. /** Defines the mime type of the video. */
  123840. mimeType: string;
  123841. /** Defines the FPS the video should be recorded at. */
  123842. fps: number;
  123843. /** Defines the chunk size for the recording data. */
  123844. recordChunckSize: number;
  123845. /** The audio tracks to attach to the recording. */
  123846. audioTracks?: MediaStreamTrack[];
  123847. }
  123848. /**
  123849. * This can help with recording videos from BabylonJS.
  123850. * This is based on the available WebRTC functionalities of the browser.
  123851. *
  123852. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  123853. */
  123854. export class VideoRecorder {
  123855. private static readonly _defaultOptions;
  123856. /**
  123857. * Returns whether or not the VideoRecorder is available in your browser.
  123858. * @param engine Defines the Babylon Engine.
  123859. * @returns true if supported otherwise false.
  123860. */
  123861. static IsSupported(engine: Engine): boolean;
  123862. private readonly _options;
  123863. private _canvas;
  123864. private _mediaRecorder;
  123865. private _recordedChunks;
  123866. private _fileName;
  123867. private _resolve;
  123868. private _reject;
  123869. /**
  123870. * True when a recording is already in progress.
  123871. */
  123872. readonly isRecording: boolean;
  123873. /**
  123874. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  123875. * @param engine Defines the BabylonJS Engine you wish to record.
  123876. * @param options Defines options that can be used to customize the capture.
  123877. */
  123878. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  123879. /**
  123880. * Stops the current recording before the default capture timeout passed in the startRecording function.
  123881. */
  123882. stopRecording(): void;
  123883. /**
  123884. * Starts recording the canvas for a max duration specified in parameters.
  123885. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  123886. * If null no automatic download will start and you can rely on the promise to get the data back.
  123887. * @param maxDuration Defines the maximum recording time in seconds.
  123888. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  123889. * @return A promise callback at the end of the recording with the video data in Blob.
  123890. */
  123891. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  123892. /**
  123893. * Releases internal resources used during the recording.
  123894. */
  123895. dispose(): void;
  123896. private _handleDataAvailable;
  123897. private _handleError;
  123898. private _handleStop;
  123899. }
  123900. }
  123901. declare module BABYLON {
  123902. /**
  123903. * Class containing a set of static utilities functions for screenshots
  123904. */
  123905. export class ScreenshotTools {
  123906. /**
  123907. * Captures a screenshot of the current rendering
  123908. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  123909. * @param engine defines the rendering engine
  123910. * @param camera defines the source camera
  123911. * @param size This parameter can be set to a single number or to an object with the
  123912. * following (optional) properties: precision, width, height. If a single number is passed,
  123913. * it will be used for both width and height. If an object is passed, the screenshot size
  123914. * will be derived from the parameters. The precision property is a multiplier allowing
  123915. * rendering at a higher or lower resolution
  123916. * @param successCallback defines the callback receives a single parameter which contains the
  123917. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123918. * src parameter of an <img> to display it
  123919. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123920. * Check your browser for supported MIME types
  123921. */
  123922. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  123923. /**
  123924. * Generates an image screenshot from the specified camera.
  123925. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  123926. * @param engine The engine to use for rendering
  123927. * @param camera The camera to use for rendering
  123928. * @param size This parameter can be set to a single number or to an object with the
  123929. * following (optional) properties: precision, width, height. If a single number is passed,
  123930. * it will be used for both width and height. If an object is passed, the screenshot size
  123931. * will be derived from the parameters. The precision property is a multiplier allowing
  123932. * rendering at a higher or lower resolution
  123933. * @param successCallback The callback receives a single parameter which contains the
  123934. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123935. * src parameter of an <img> to display it
  123936. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123937. * Check your browser for supported MIME types
  123938. * @param samples Texture samples (default: 1)
  123939. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123940. * @param fileName A name for for the downloaded file.
  123941. */
  123942. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123943. }
  123944. }
  123945. declare module BABYLON {
  123946. /**
  123947. * A cursor which tracks a point on a path
  123948. */
  123949. export class PathCursor {
  123950. private path;
  123951. /**
  123952. * Stores path cursor callbacks for when an onchange event is triggered
  123953. */
  123954. private _onchange;
  123955. /**
  123956. * The value of the path cursor
  123957. */
  123958. value: number;
  123959. /**
  123960. * The animation array of the path cursor
  123961. */
  123962. animations: Animation[];
  123963. /**
  123964. * Initializes the path cursor
  123965. * @param path The path to track
  123966. */
  123967. constructor(path: Path2);
  123968. /**
  123969. * Gets the cursor point on the path
  123970. * @returns A point on the path cursor at the cursor location
  123971. */
  123972. getPoint(): Vector3;
  123973. /**
  123974. * Moves the cursor ahead by the step amount
  123975. * @param step The amount to move the cursor forward
  123976. * @returns This path cursor
  123977. */
  123978. moveAhead(step?: number): PathCursor;
  123979. /**
  123980. * Moves the cursor behind by the step amount
  123981. * @param step The amount to move the cursor back
  123982. * @returns This path cursor
  123983. */
  123984. moveBack(step?: number): PathCursor;
  123985. /**
  123986. * Moves the cursor by the step amount
  123987. * If the step amount is greater than one, an exception is thrown
  123988. * @param step The amount to move the cursor
  123989. * @returns This path cursor
  123990. */
  123991. move(step: number): PathCursor;
  123992. /**
  123993. * Ensures that the value is limited between zero and one
  123994. * @returns This path cursor
  123995. */
  123996. private ensureLimits;
  123997. /**
  123998. * Runs onchange callbacks on change (used by the animation engine)
  123999. * @returns This path cursor
  124000. */
  124001. private raiseOnChange;
  124002. /**
  124003. * Executes a function on change
  124004. * @param f A path cursor onchange callback
  124005. * @returns This path cursor
  124006. */
  124007. onchange(f: (cursor: PathCursor) => void): PathCursor;
  124008. }
  124009. }
  124010. declare module BABYLON {
  124011. /** @hidden */
  124012. export var blurPixelShader: {
  124013. name: string;
  124014. shader: string;
  124015. };
  124016. }
  124017. declare module BABYLON {
  124018. /** @hidden */
  124019. export var pointCloudVertexDeclaration: {
  124020. name: string;
  124021. shader: string;
  124022. };
  124023. }
  124024. // Mixins
  124025. interface Window {
  124026. mozIndexedDB: IDBFactory;
  124027. webkitIndexedDB: IDBFactory;
  124028. msIndexedDB: IDBFactory;
  124029. webkitURL: typeof URL;
  124030. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  124031. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  124032. WebGLRenderingContext: WebGLRenderingContext;
  124033. MSGesture: MSGesture;
  124034. CANNON: any;
  124035. AudioContext: AudioContext;
  124036. webkitAudioContext: AudioContext;
  124037. PointerEvent: any;
  124038. Math: Math;
  124039. Uint8Array: Uint8ArrayConstructor;
  124040. Float32Array: Float32ArrayConstructor;
  124041. mozURL: typeof URL;
  124042. msURL: typeof URL;
  124043. VRFrameData: any; // WebVR, from specs 1.1
  124044. DracoDecoderModule: any;
  124045. setImmediate(handler: (...args: any[]) => void): number;
  124046. }
  124047. interface HTMLCanvasElement {
  124048. requestPointerLock(): void;
  124049. msRequestPointerLock?(): void;
  124050. mozRequestPointerLock?(): void;
  124051. webkitRequestPointerLock?(): void;
  124052. /** Track wether a record is in progress */
  124053. isRecording: boolean;
  124054. /** Capture Stream method defined by some browsers */
  124055. captureStream(fps?: number): MediaStream;
  124056. }
  124057. interface CanvasRenderingContext2D {
  124058. msImageSmoothingEnabled: boolean;
  124059. }
  124060. interface MouseEvent {
  124061. mozMovementX: number;
  124062. mozMovementY: number;
  124063. webkitMovementX: number;
  124064. webkitMovementY: number;
  124065. msMovementX: number;
  124066. msMovementY: number;
  124067. }
  124068. interface Navigator {
  124069. mozGetVRDevices: (any: any) => any;
  124070. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124071. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124072. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124073. webkitGetGamepads(): Gamepad[];
  124074. msGetGamepads(): Gamepad[];
  124075. webkitGamepads(): Gamepad[];
  124076. }
  124077. interface HTMLVideoElement {
  124078. mozSrcObject: any;
  124079. }
  124080. interface Math {
  124081. fround(x: number): number;
  124082. imul(a: number, b: number): number;
  124083. }
  124084. interface WebGLRenderingContext {
  124085. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  124086. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  124087. vertexAttribDivisor(index: number, divisor: number): void;
  124088. createVertexArray(): any;
  124089. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  124090. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  124091. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  124092. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  124093. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  124094. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  124095. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  124096. // Queries
  124097. createQuery(): WebGLQuery;
  124098. deleteQuery(query: WebGLQuery): void;
  124099. beginQuery(target: number, query: WebGLQuery): void;
  124100. endQuery(target: number): void;
  124101. getQueryParameter(query: WebGLQuery, pname: number): any;
  124102. getQuery(target: number, pname: number): any;
  124103. MAX_SAMPLES: number;
  124104. RGBA8: number;
  124105. READ_FRAMEBUFFER: number;
  124106. DRAW_FRAMEBUFFER: number;
  124107. UNIFORM_BUFFER: number;
  124108. HALF_FLOAT_OES: number;
  124109. RGBA16F: number;
  124110. RGBA32F: number;
  124111. R32F: number;
  124112. RG32F: number;
  124113. RGB32F: number;
  124114. R16F: number;
  124115. RG16F: number;
  124116. RGB16F: number;
  124117. RED: number;
  124118. RG: number;
  124119. R8: number;
  124120. RG8: number;
  124121. UNSIGNED_INT_24_8: number;
  124122. DEPTH24_STENCIL8: number;
  124123. /* Multiple Render Targets */
  124124. drawBuffers(buffers: number[]): void;
  124125. readBuffer(src: number): void;
  124126. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  124127. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  124128. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  124129. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  124130. // Occlusion Query
  124131. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  124132. ANY_SAMPLES_PASSED: number;
  124133. QUERY_RESULT_AVAILABLE: number;
  124134. QUERY_RESULT: number;
  124135. }
  124136. interface WebGLProgram {
  124137. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  124138. }
  124139. interface EXT_disjoint_timer_query {
  124140. QUERY_COUNTER_BITS_EXT: number;
  124141. TIME_ELAPSED_EXT: number;
  124142. TIMESTAMP_EXT: number;
  124143. GPU_DISJOINT_EXT: number;
  124144. QUERY_RESULT_EXT: number;
  124145. QUERY_RESULT_AVAILABLE_EXT: number;
  124146. queryCounterEXT(query: WebGLQuery, target: number): void;
  124147. createQueryEXT(): WebGLQuery;
  124148. beginQueryEXT(target: number, query: WebGLQuery): void;
  124149. endQueryEXT(target: number): void;
  124150. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  124151. deleteQueryEXT(query: WebGLQuery): void;
  124152. }
  124153. interface WebGLUniformLocation {
  124154. _currentState: any;
  124155. }
  124156. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  124157. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  124158. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  124159. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124160. interface WebGLRenderingContext {
  124161. readonly RASTERIZER_DISCARD: number;
  124162. readonly DEPTH_COMPONENT24: number;
  124163. readonly TEXTURE_3D: number;
  124164. readonly TEXTURE_2D_ARRAY: number;
  124165. readonly TEXTURE_COMPARE_FUNC: number;
  124166. readonly TEXTURE_COMPARE_MODE: number;
  124167. readonly COMPARE_REF_TO_TEXTURE: number;
  124168. readonly TEXTURE_WRAP_R: number;
  124169. readonly HALF_FLOAT: number;
  124170. readonly RGB8: number;
  124171. readonly RED_INTEGER: number;
  124172. readonly RG_INTEGER: number;
  124173. readonly RGB_INTEGER: number;
  124174. readonly RGBA_INTEGER: number;
  124175. readonly R8_SNORM: number;
  124176. readonly RG8_SNORM: number;
  124177. readonly RGB8_SNORM: number;
  124178. readonly RGBA8_SNORM: number;
  124179. readonly R8I: number;
  124180. readonly RG8I: number;
  124181. readonly RGB8I: number;
  124182. readonly RGBA8I: number;
  124183. readonly R8UI: number;
  124184. readonly RG8UI: number;
  124185. readonly RGB8UI: number;
  124186. readonly RGBA8UI: number;
  124187. readonly R16I: number;
  124188. readonly RG16I: number;
  124189. readonly RGB16I: number;
  124190. readonly RGBA16I: number;
  124191. readonly R16UI: number;
  124192. readonly RG16UI: number;
  124193. readonly RGB16UI: number;
  124194. readonly RGBA16UI: number;
  124195. readonly R32I: number;
  124196. readonly RG32I: number;
  124197. readonly RGB32I: number;
  124198. readonly RGBA32I: number;
  124199. readonly R32UI: number;
  124200. readonly RG32UI: number;
  124201. readonly RGB32UI: number;
  124202. readonly RGBA32UI: number;
  124203. readonly RGB10_A2UI: number;
  124204. readonly R11F_G11F_B10F: number;
  124205. readonly RGB9_E5: number;
  124206. readonly RGB10_A2: number;
  124207. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  124208. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  124209. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  124210. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  124211. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  124212. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  124213. 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;
  124214. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  124215. readonly TRANSFORM_FEEDBACK: number;
  124216. readonly INTERLEAVED_ATTRIBS: number;
  124217. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  124218. createTransformFeedback(): WebGLTransformFeedback;
  124219. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  124220. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  124221. beginTransformFeedback(primitiveMode: number): void;
  124222. endTransformFeedback(): void;
  124223. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  124224. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124225. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124226. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124227. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  124228. }
  124229. interface ImageBitmap {
  124230. readonly width: number;
  124231. readonly height: number;
  124232. close(): void;
  124233. }
  124234. interface WebGLQuery extends WebGLObject {
  124235. }
  124236. declare var WebGLQuery: {
  124237. prototype: WebGLQuery;
  124238. new(): WebGLQuery;
  124239. };
  124240. interface WebGLSampler extends WebGLObject {
  124241. }
  124242. declare var WebGLSampler: {
  124243. prototype: WebGLSampler;
  124244. new(): WebGLSampler;
  124245. };
  124246. interface WebGLSync extends WebGLObject {
  124247. }
  124248. declare var WebGLSync: {
  124249. prototype: WebGLSync;
  124250. new(): WebGLSync;
  124251. };
  124252. interface WebGLTransformFeedback extends WebGLObject {
  124253. }
  124254. declare var WebGLTransformFeedback: {
  124255. prototype: WebGLTransformFeedback;
  124256. new(): WebGLTransformFeedback;
  124257. };
  124258. interface WebGLVertexArrayObject extends WebGLObject {
  124259. }
  124260. declare var WebGLVertexArrayObject: {
  124261. prototype: WebGLVertexArrayObject;
  124262. new(): WebGLVertexArrayObject;
  124263. };
  124264. // Type definitions for WebVR API
  124265. // Project: https://w3c.github.io/webvr/
  124266. // Definitions by: six a <https://github.com/lostfictions>
  124267. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124268. interface VRDisplay extends EventTarget {
  124269. /**
  124270. * Dictionary of capabilities describing the VRDisplay.
  124271. */
  124272. readonly capabilities: VRDisplayCapabilities;
  124273. /**
  124274. * z-depth defining the far plane of the eye view frustum
  124275. * enables mapping of values in the render target depth
  124276. * attachment to scene coordinates. Initially set to 10000.0.
  124277. */
  124278. depthFar: number;
  124279. /**
  124280. * z-depth defining the near plane of the eye view frustum
  124281. * enables mapping of values in the render target depth
  124282. * attachment to scene coordinates. Initially set to 0.01.
  124283. */
  124284. depthNear: number;
  124285. /**
  124286. * An identifier for this distinct VRDisplay. Used as an
  124287. * association point in the Gamepad API.
  124288. */
  124289. readonly displayId: number;
  124290. /**
  124291. * A display name, a user-readable name identifying it.
  124292. */
  124293. readonly displayName: string;
  124294. readonly isConnected: boolean;
  124295. readonly isPresenting: boolean;
  124296. /**
  124297. * If this VRDisplay supports room-scale experiences, the optional
  124298. * stage attribute contains details on the room-scale parameters.
  124299. */
  124300. readonly stageParameters: VRStageParameters | null;
  124301. /**
  124302. * Passing the value returned by `requestAnimationFrame` to
  124303. * `cancelAnimationFrame` will unregister the callback.
  124304. * @param handle Define the hanle of the request to cancel
  124305. */
  124306. cancelAnimationFrame(handle: number): void;
  124307. /**
  124308. * Stops presenting to the VRDisplay.
  124309. * @returns a promise to know when it stopped
  124310. */
  124311. exitPresent(): Promise<void>;
  124312. /**
  124313. * Return the current VREyeParameters for the given eye.
  124314. * @param whichEye Define the eye we want the parameter for
  124315. * @returns the eye parameters
  124316. */
  124317. getEyeParameters(whichEye: string): VREyeParameters;
  124318. /**
  124319. * Populates the passed VRFrameData with the information required to render
  124320. * the current frame.
  124321. * @param frameData Define the data structure to populate
  124322. * @returns true if ok otherwise false
  124323. */
  124324. getFrameData(frameData: VRFrameData): boolean;
  124325. /**
  124326. * Get the layers currently being presented.
  124327. * @returns the list of VR layers
  124328. */
  124329. getLayers(): VRLayer[];
  124330. /**
  124331. * Return a VRPose containing the future predicted pose of the VRDisplay
  124332. * when the current frame will be presented. The value returned will not
  124333. * change until JavaScript has returned control to the browser.
  124334. *
  124335. * The VRPose will contain the position, orientation, velocity,
  124336. * and acceleration of each of these properties.
  124337. * @returns the pose object
  124338. */
  124339. getPose(): VRPose;
  124340. /**
  124341. * Return the current instantaneous pose of the VRDisplay, with no
  124342. * prediction applied.
  124343. * @returns the current instantaneous pose
  124344. */
  124345. getImmediatePose(): VRPose;
  124346. /**
  124347. * The callback passed to `requestAnimationFrame` will be called
  124348. * any time a new frame should be rendered. When the VRDisplay is
  124349. * presenting the callback will be called at the native refresh
  124350. * rate of the HMD. When not presenting this function acts
  124351. * identically to how window.requestAnimationFrame acts. Content should
  124352. * make no assumptions of frame rate or vsync behavior as the HMD runs
  124353. * asynchronously from other displays and at differing refresh rates.
  124354. * @param callback Define the eaction to run next frame
  124355. * @returns the request handle it
  124356. */
  124357. requestAnimationFrame(callback: FrameRequestCallback): number;
  124358. /**
  124359. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  124360. * Repeat calls while already presenting will update the VRLayers being displayed.
  124361. * @param layers Define the list of layer to present
  124362. * @returns a promise to know when the request has been fulfilled
  124363. */
  124364. requestPresent(layers: VRLayer[]): Promise<void>;
  124365. /**
  124366. * Reset the pose for this display, treating its current position and
  124367. * orientation as the "origin/zero" values. VRPose.position,
  124368. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  124369. * updated when calling resetPose(). This should be called in only
  124370. * sitting-space experiences.
  124371. */
  124372. resetPose(): void;
  124373. /**
  124374. * The VRLayer provided to the VRDisplay will be captured and presented
  124375. * in the HMD. Calling this function has the same effect on the source
  124376. * canvas as any other operation that uses its source image, and canvases
  124377. * created without preserveDrawingBuffer set to true will be cleared.
  124378. * @param pose Define the pose to submit
  124379. */
  124380. submitFrame(pose?: VRPose): void;
  124381. }
  124382. declare var VRDisplay: {
  124383. prototype: VRDisplay;
  124384. new(): VRDisplay;
  124385. };
  124386. interface VRLayer {
  124387. leftBounds?: number[] | Float32Array | null;
  124388. rightBounds?: number[] | Float32Array | null;
  124389. source?: HTMLCanvasElement | null;
  124390. }
  124391. interface VRDisplayCapabilities {
  124392. readonly canPresent: boolean;
  124393. readonly hasExternalDisplay: boolean;
  124394. readonly hasOrientation: boolean;
  124395. readonly hasPosition: boolean;
  124396. readonly maxLayers: number;
  124397. }
  124398. interface VREyeParameters {
  124399. /** @deprecated */
  124400. readonly fieldOfView: VRFieldOfView;
  124401. readonly offset: Float32Array;
  124402. readonly renderHeight: number;
  124403. readonly renderWidth: number;
  124404. }
  124405. interface VRFieldOfView {
  124406. readonly downDegrees: number;
  124407. readonly leftDegrees: number;
  124408. readonly rightDegrees: number;
  124409. readonly upDegrees: number;
  124410. }
  124411. interface VRFrameData {
  124412. readonly leftProjectionMatrix: Float32Array;
  124413. readonly leftViewMatrix: Float32Array;
  124414. readonly pose: VRPose;
  124415. readonly rightProjectionMatrix: Float32Array;
  124416. readonly rightViewMatrix: Float32Array;
  124417. readonly timestamp: number;
  124418. }
  124419. interface VRPose {
  124420. readonly angularAcceleration: Float32Array | null;
  124421. readonly angularVelocity: Float32Array | null;
  124422. readonly linearAcceleration: Float32Array | null;
  124423. readonly linearVelocity: Float32Array | null;
  124424. readonly orientation: Float32Array | null;
  124425. readonly position: Float32Array | null;
  124426. readonly timestamp: number;
  124427. }
  124428. interface VRStageParameters {
  124429. sittingToStandingTransform?: Float32Array;
  124430. sizeX?: number;
  124431. sizeY?: number;
  124432. }
  124433. interface Navigator {
  124434. getVRDisplays(): Promise<VRDisplay[]>;
  124435. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  124436. }
  124437. interface Window {
  124438. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  124439. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  124440. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  124441. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124442. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124443. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  124444. }
  124445. interface Gamepad {
  124446. readonly displayId: number;
  124447. }
  124448. type XRSessionMode =
  124449. | "inline"
  124450. | "immersive-vr"
  124451. | "immersive-ar";
  124452. type XRReferenceSpaceType =
  124453. | "viewer"
  124454. | "local"
  124455. | "local-floor"
  124456. | "bounded-floor"
  124457. | "unbounded";
  124458. type XREnvironmentBlendMode =
  124459. | "opaque"
  124460. | "additive"
  124461. | "alpha-blend";
  124462. type XRVisibilityState =
  124463. | "visible"
  124464. | "visible-blurred"
  124465. | "hidden";
  124466. type XRHandedness =
  124467. | "none"
  124468. | "left"
  124469. | "right";
  124470. type XRTargetRayMode =
  124471. | "gaze"
  124472. | "tracked-pointer"
  124473. | "screen";
  124474. type XREye =
  124475. | "none"
  124476. | "left"
  124477. | "right";
  124478. interface XRSpace extends EventTarget {
  124479. }
  124480. interface XRRenderState {
  124481. depthNear?: number;
  124482. depthFar?: number;
  124483. inlineVerticalFieldOfView?: number;
  124484. baseLayer?: XRWebGLLayer;
  124485. }
  124486. interface XRInputSource {
  124487. handedness: XRHandedness;
  124488. targetRayMode: XRTargetRayMode;
  124489. targetRaySpace: XRSpace;
  124490. gripSpace: XRSpace | undefined;
  124491. gamepad: Gamepad | undefined;
  124492. profiles: Array<string>;
  124493. }
  124494. interface XRSession {
  124495. addEventListener: Function;
  124496. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124497. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  124498. requestAnimationFrame: Function;
  124499. end(): Promise<void>;
  124500. renderState: XRRenderState;
  124501. inputSources: Array<XRInputSource>;
  124502. }
  124503. interface XRReferenceSpace extends XRSpace {
  124504. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  124505. onreset: any;
  124506. }
  124507. interface XRFrame {
  124508. session: XRSession;
  124509. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  124510. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  124511. }
  124512. interface XRViewerPose extends XRPose {
  124513. views: Array<XRView>;
  124514. }
  124515. interface XRPose {
  124516. transform: XRRigidTransform;
  124517. emulatedPosition: boolean;
  124518. }
  124519. declare var XRWebGLLayer: {
  124520. prototype: XRWebGLLayer;
  124521. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  124522. };
  124523. interface XRWebGLLayer {
  124524. framebuffer: WebGLFramebuffer;
  124525. framebufferWidth: number;
  124526. framebufferHeight: number;
  124527. getViewport: Function;
  124528. }
  124529. interface XRRigidTransform {
  124530. position: DOMPointReadOnly;
  124531. orientation: DOMPointReadOnly;
  124532. matrix: Float32Array;
  124533. inverse: XRRigidTransform;
  124534. }
  124535. interface XRView {
  124536. eye: XREye;
  124537. projectionMatrix: Float32Array;
  124538. transform: XRRigidTransform;
  124539. }
  124540. interface XRInputSourceChangeEvent {
  124541. session: XRSession;
  124542. removed: Array<XRInputSource>;
  124543. added: Array<XRInputSource>;
  124544. }